xref: /trunk/main/solenv/gbuild/Ant.mk (revision 41f03cd9)
1###############################################################
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20###############################################################
21
22
23
24# Ant class
25
26gb_Ant_ANTCOMMAND := $(ANT)
27
28# clean target
29$(call gb_Ant_get_clean_target,%) :
30	$(call gb_Output_announce,$*,$(false),ANT,3)
31	$(call gb_Helper_abbreviate_dirs,\
32		rm -f $(call gb_Ant_get_target,$*) $(call gb_Jar_get_outdir_target,$*) && \
33		$(gb_Ant_ANTCOMMAND) -f $(ANTBUILDFILE) clean)
34
35# the outdir target depends on the workdir target and is built by delivering the latter
36
37# rule for creating the jar file
38# creates the target folder of the jar file if it doesn't exist
39# creates the jar file
40$(call gb_Ant_get_target,%) : FORCE
41	$(call gb_Output_announce,$*,$(true),ANT,3)
42	$(call gb_Helper_abbreviate_dirs_native,\
43	mkdir -p $(dir $@) && \
44	$(gb_Ant_ANTCOMMAND) -f $(ANTBUILDFILE) )
45
46FORCE:
47
48
49# registers target and clean target
50# adds jar files to DeliverLogTarget
51# adds dependency for outdir target to workdir target (pattern rule for delivery is in Package.mk)
52define gb_Ant_Ant
53$(call gb_Ant_get_target,$(1)) : ANTBUILDFILE := $(2)
54$(call gb_Ant_get_clean_target,$(1)) : ANTBUILDFILE := $(2)
55$(eval $(call gb_Module_register_target,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Ant_get_clean_target,$(1))))
56$(call gb_Deliver_add_deliverable,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Ant_get_target,$(1)),$(1))
57$(call gb_Jar_get_outdir_target,$(1)) : $(call gb_Ant_get_target,$(1))
58
59endef
60
61
62# possible directories for jar files containing UNO services
63gb_Ant_COMPONENTPREFIXES := \
64    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/classes/ \
65    URE:vnd.sun.star.expand:\dURE_INTERNAL_JAVA_DIR/ \
66    INTERN:vnd.sun.star.expand:\dOOO_INBUILD_JAVA_DIR/
67
68# get component prefix from layer name ("OOO", "URE", "INTERN")
69gb_Ant__get_componentprefix = \
70    $(patsubst $(1):%,%,$(or \
71        $(filter $(1):%,$(gb_Ant_COMPONENTPREFIXES)), \
72        $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
73
74# layer must be specified explicitly in this macro (different to libraries)
75define gb_Ant_set_componentfile
76$(call gb_ComponentTarget_ComponentTarget,$(2),$(call gb_Ant__get_componentprefix,$(3)),$(notdir $(call gb_Ant_get_target,$(1))))
77$(call gb_Ant_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2))
78$(call gb_Ant_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2))
79
80endef
81
82# vim: set noet sw=4 ts=4:
83