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