bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / JavaClassSet.mk
blob64a2fdc6661bb95142200600d4fff79091cddf1f
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 gb_JavaClassSet_JAVACCOMMAND := $(ICECREAM_RUN) $(JAVACOMPILER) $(JAVAFLAGS) \
21 -source $(JAVA_SOURCE_VER) -target $(JAVA_TARGET_VER) \
22 $(if $(JAVA_CLASSPATH_NOT_SET),-Xlint:-options)
23 gb_JavaClassSet_JAVACDEBUG :=
25 # Enforces correct dependency order for possibly generated stuff:
26 # generated sources, jars/classdirs etc.
27 gb_JavaClassSet_get_preparation_target = $(WORKDIR)/JavaClassSet/$(1).prepared
29 ifneq ($(gb_DEBUGLEVEL),0)
30 gb_JavaClassSet_JAVACDEBUG := -g
31 endif
33 define gb_JavaClassSet__command
34 $(call gb_Helper_abbreviate_dirs,\
35 mkdir -p $(dir $(1)) && \
36 $(if $(filter-out $(JARDEPS),$(4)), \
37 rm -rf $(call gb_JavaClassSet_get_classdir,$(2))/* && \
38 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,\
39 $(filter-out $(JARDEPS),$(4))) && \
40 $(if $(3),$(gb_JavaClassSet_JAVACCOMMAND) \
41 $(gb_JavaClassSet_JAVACDEBUG) \
42 -classpath "$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
43 -d $(call gb_JavaClassSet_get_classdir,$(2)) \
44 @$$RESPONSEFILE &&) \
45 rm -f $$RESPONSEFILE &&) \
46 touch $(1))
48 endef
50 $(call gb_JavaClassSet_get_target,%) :
51 $(call gb_Output_announce,$*,$(true),JCS,3)
52 $(call gb_JavaClassSet__command,$@,$*,$?,$^)
54 $(call gb_JavaClassSet_get_clean_target,%) :
55 $(call gb_Output_announce,$*,$(false),JCS,3)
56 $(call gb_Helper_abbreviate_dirs,\
57 rm -rf $(dir $(call gb_JavaClassSet_get_target,$*))) \
58 $(call gb_JavaClassSet_get_preparation_target,$*)
60 $(call gb_JavaClassSet_get_preparation_target,%) :
61 mkdir -p $(dir $@) && touch $@
63 # depend on makefile to enforce a rebuild if files are removed from the classset
64 define gb_JavaClassSet_JavaClassSet
65 $(call gb_JavaClassSet_get_target,$(1)) : \
66 $(gb_Module_CURRENTMAKEFILE) \
67 $(call gb_JavaClassSet_get_preparation_target,$(1))
68 $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS := \
69 $(gb_Module_CURRENTMAKEFILE) \
70 $(call gb_JavaClassSet_get_preparation_target,$(1))
72 endef
74 define gb_JavaClassSet__get_sourcefile
75 $(SRCDIR)/$(1).java
76 endef
78 define gb_JavaClassSet__get_generated_sourcefile
79 $(WORKDIR)/$(1).java
80 endef
82 define gb_JavaClassSet_add_sourcefile
83 $(call gb_JavaClassSet_get_target,$(1)) : $(call gb_JavaClassSet__get_sourcefile,$(2))
85 endef
87 define gb_JavaClassSet_add_sourcefiles
88 $(foreach sourcefile,$(2),$(call gb_JavaClassSet_add_sourcefile,$(1),$(sourcefile)))
90 endef
92 define gb_JavaClassSet_add_generated_sourcefile
93 $(call gb_JavaClassSet_get_target,$(1)) : $(call gb_JavaClassSet__get_generated_sourcefile,$(2))
94 $(call gb_JavaClassSet__get_generated_sourcefile,$(2)) :| $(call gb_JavaClassSet_get_preparation_target,$(1))
96 endef
98 define gb_JavaClassSet_add_generated_sourcefiles
99 $(foreach sourcefile,$(2),$(call gb_JavaClassSet_add_generated_sourcefile,$(1),$(sourcefile)))
101 endef
103 define gb_JavaClassSet_set_classpath
104 $$(call gb_Output_error,\
105 gb_JavaClassSet_set_classpath: use gb_JavaClassSet_add_classpath instead.)
106 endef
108 define gb_JavaClassSet_add_classpath
109 $(call gb_JavaClassSet_get_target,$(1)) : T_CP := $$(if $$(T_CP),$$(T_CP)$$(gb_CLASSPATHSEP))$(strip $(2))
111 endef
113 define gb_JavaClassSet_add_jar
114 $$(call gb_Output_error,\
115 gb_JavaClassSet_add_jar: use gb_JavaClassSet_use_jar instead.)
116 endef
118 define gb_JavaClassSet_use_jar
119 ifneq (,$$(filter-out $(gb_Jar_KNOWN),$(2)))
120 $$(eval $$(call gb_Output_info,currently known jars are: $(sort $(gb_Jar_KNOWN)),ALL))
121 $$(eval $$(call gb_Output_error,Cannot link against jar $$(filter-out $(gb_Jar_KNOWN),$(2)). Jars must be registered in Repository.mk))
122 endif
123 $(call gb_JavaClassSet_get_target,$(1)) : $(call gb_Jar_get_outdir_target,$(2))
124 $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS += $(call gb_Jar_get_outdir_target,$(2))
125 $(call gb_JavaClassSet_add_classpath,$(1),$(call gb_Jar_get_outdir_target,$(2)))
127 endef
129 # this does not generate dependency on the jar
130 define gb_JavaClassSet_add_system_jar
131 $$(call gb_Output_error,\
132 gb_JavaClassSet_add_system_jar: use gb_JavaClassSet_use_system_jar instead.)
133 endef
135 define gb_JavaClassSet_use_system_jar
136 $(call gb_JavaClassSet_add_classpath,$(1),$(2))
138 endef
140 define gb_JavaClassSet_add_jars
141 $$(call gb_Output_error,\
142 gb_JavaClassSet_add_jars: use gb_JavaClassSet_use_jars instead.)
143 endef
145 define gb_JavaClassSet_use_jars
146 $(foreach jar,$(2),$(call gb_JavaClassSet_use_jar,$(1),$(jar)))
148 endef
150 define gb_JavaClassSet_add_system_jars
151 $$(call gb_Output_error,\
152 gb_JavaClassSet_add_system_jars: use gb_JavaClassSet_use_system_jars instead.)
153 endef
155 define gb_JavaClassSet_use_system_jars
156 $(foreach jar,$(2),$(call gb_JavaClassSet_use_system_jar,$(1),$(jar)))
158 endef
160 define gb_JavaClassSet_add_jar_classset
161 $$(call gb_Output_error,\
162 gb_JavaClassSet_add_jar_classset: use gb_JavaClassSet_use_jar_classset instead.)
163 endef
165 # gb_JavaClassSet_use_jar_classset: Like gb_JavaClassSet_use_jar, but instead of
166 # using the jar, use the directory tree with the class files that make up the
167 # jar. This is sometimes necessary in JunitTests that have test classes in
168 # packages that belong to a sealed jar.
169 # $1: token identifying this JavaClassSet
170 # $2: token identifying the Jar being used
171 define gb_JavaClassSet_use_jar_classset
172 $(call gb_JavaClassSet_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_Jar_get_classsetname,$(2)))
173 $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS += $(call gb_JavaClassSet_get_target,$(call gb_Jar_get_classsetname,$(2)))
174 $(call gb_JavaClassSet_add_classpath,$(1),$(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(2))))
176 endef
178 define gb_JavaClassSet_use_external
179 $$(call gb_Output_error,\
180 gb_JavaClassSet_use_external: use gb_Jar_use_external instead.)
181 endef
183 define gb_JavaClassSet_use_externals
184 $(foreach external,$(2),$(call gb_JavaClassSet_use_external,$(1),$(external)))
186 endef
188 define gb_JavaClassSet_add_customtarget_dependency
189 $$(call gb_Output_error,\
190 gb_JavaClassSet_add_customtarget_dependency: use gb_JavaClassSet_use_customtarget instead.)
191 endef
193 define gb_JavaClassSet_use_customtarget
194 $(call gb_JavaClassSet_get_preparation_target,$(1)) : \
195 $(call gb_CustomTarget_get_target,$(2))
196 $(call gb_JavaClassSet_add_classpath,$(1),$(call gb_CustomTarget_get_workdir,$(2)))
198 endef
200 # vim: set noet sw=4: