xref: /trunk/main/solenv/gbuild/Ant.mk (revision d6a83b31)
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
49define gb_Ant_add_dependency
50$(1) : $(2)
51
52endef
53
54# registers target and clean target
55# adds jar files to DeliverLogTarget
56# adds dependency for outdir target to workdir target (pattern rule for delivery is in Package.mk)
57define gb_Ant_Ant
58ifeq ($(OS),WNT)
59$(call gb_Ant_get_target,$(1)) : ANTBUILDFILE := `cygpath -m $(2)`
60$(call gb_Ant_get_clean_target,$(1)) : ANTBUILDFILE := `cygpath -m $(2)`
61else
62$(call gb_Ant_get_target,$(1)) : ANTBUILDFILE := $(2)
63$(call gb_Ant_get_clean_target,$(1)) : ANTBUILDFILE := $(2)
64endif
65$(eval $(call gb_Module_register_target,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Ant_get_clean_target,$(1))))
66$(call gb_Deliver_add_deliverable,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Ant_get_target,$(1)),$(1))
67$(call gb_Jar_get_outdir_target,$(1)) : $(call gb_Ant_get_target,$(1))
68
69$(call gb_Ant_add_dependencies,$(1),$(2))
70
71endef
72
73
74# possible directories for jar files containing UNO services
75gb_Ant_COMPONENTPREFIXES := \
76    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/classes/ \
77    URE:vnd.sun.star.expand:\dURE_INTERNAL_JAVA_DIR/ \
78    INTERN:vnd.sun.star.expand:\dOOO_INBUILD_JAVA_DIR/
79
80# get component prefix from layer name ("OOO", "URE", "INTERN")
81gb_Ant__get_componentprefix = \
82    $(patsubst $(1):%,%,$(or \
83        $(filter $(1):%,$(gb_Ant_COMPONENTPREFIXES)), \
84        $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
85
86# layer must be specified explicitly in this macro (different to libraries)
87define gb_Ant_set_componentfile
88$(call gb_ComponentTarget_ComponentTarget,$(2),$(call gb_Ant__get_componentprefix,$(3)),$(notdir $(call gb_Ant_get_target,$(1))))
89$(call gb_Ant_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2))
90$(call gb_Ant_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2))
91
92endef
93
94# vim: set noet sw=4 ts=4:
95