xref: /aoo42x/main/solenv/gbuild/JavaClassSet.mk (revision 69f987b1)
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
24gb_JavaClassSet_REPOSITORYNAMES := $(gb_Helper_REPOSITORYNAMES)
25gb_JavaClassSet_JAVACCOMMAND := $(JAVACOMPILER) $(JAVAFLAGS)
26
27define gb_JavaClassSet__command
28$(call gb_Helper_abbreviate_dirs_native,\
29	mkdir -p $(dir $(1)) && \
30	$(gb_JavaClassSet_JAVACCOMMAND) -cp "$(CLASSPATH)" -encoding UTF8 \
31			-d $(call gb_JavaClassSet_get_classdir,$(2)) $(if $(filter-out $(JARDEPS),$(3)),\
32			$(filter-out $(JARDEPS),$(3)),\
33			$(filter-out $(JARDEPS),$(4))) &&\
34	touch $(1))
35
36endef
37
38$(call gb_JavaClassSet_get_target,%) :
39	$(call gb_Output_announce,$*,$(true),JCS,3)
40	$(call gb_JavaClassSet__command,$@,$*,$?,$^)
41
42$(call gb_JavaClassSet_get_clean_target,%) :
43	$(call gb_Output_announce,$*,$(false),JCS,3)
44	$(call gb_Helper_abbreviate_dirs,\
45		rm -rf $(dir $(call gb_JavaClassSet_get_target,$*)))
46
47# no initialization of scoped variable CLASSPATH as it is "inherited" from controlling instance (e.g. JUnitTest, Jar)
48# UGLY: cannot use target local variable for REPO because it's needed in prereq
49define gb_JavaClassSet_JavaClassSet
50$(if $(filter $(2),$(gb_JavaClassSet_REPOSITORYNAMES)),,\
51  $(error JavaClassSet: no or invalid repository given; known repositories: \
52  $(gb_JavaClassSet_REPOSITORYNAMES)))
53gb_JavaClassSet_REPO_$(1) := $(2)
54$(call gb_JavaClassSet_get_target,$(1)) : JARDEPS :=
55endef
56
57define gb_JavaClassSet__get_sourcefile
58$($(1))/$(2).java
59endef
60
61define gb_JavaClassSet_add_sourcefile
62$(eval $(call gb_JavaClassSet_get_target,$(1)) : \
63	$(call gb_JavaClassSet__get_sourcefile,$(gb_JavaClassSet_REPO_$(1)),$(2)))
64endef
65
66define gb_JavaClassSet_add_sourcefiles
67$(foreach sourcefile,$(2),$(call gb_JavaClassSet_add_sourcefile,$(1),$(sourcefile)))
68endef
69
70define gb_JavaClassSet_set_classpath
71$(eval $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $(2))
72endef
73
74# problem: currently we can't get these dependencies to work
75# build order dependency is a hack to get these prerequisites out of the way in the build command
76define gb_JavaClassSet_add_jar
77$(eval $(call gb_JavaClassSet_get_target,$(1)) : $(2))
78$(eval $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$$(gb_CLASSPATHSEP)$(strip $(2)))
79$(eval $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS += $(2))
80endef
81
82# this does not generate dependency on the jar
83define gb_JavaClassSet_add_system_jar
84$(eval $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$$(gb_CLASSPATHSEP)$(strip $(2)))
85$(eval $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS += $(2))
86endef
87
88define gb_JavaClassSet_add_jars
89$(foreach jar,$(2),$(call gb_JavaClassSet_add_jar,$(1),$(jar)))
90endef
91
92define gb_JavaClassSet_add_system_jars
93$(foreach jar,$(2),$(call gb_JavaClassSet_add_system_jar,$(1),$(jar)))
94endef
95
96# this forwards to functions that must be defined in RepositoryExternal.mk.
97# $(call gb_LinkTarget_use_external,library,external)
98define gb_JavaClassSet_use_external
99$(eval $(if $(value gb_JavaClassSet__use_$(2)),\
100  $(call gb_JavaClassSet__use_$(2),$(1)),\
101  $(error gb_JavaClassSet_use_external: unknown external: $(2))))
102endef
103
104define gb_JavaClassSet_use_externals
105$(foreach external,$(2),$(call gb_JavaClassSet_use_external,$(1),$(external)))
106endef
107
108# vim: set noet sw=4 ts=4:
109