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
) $(JAVACFLAGS
) \
22 $(if
$(MODULAR_JAVA
),--release
$(1),-source
$(1) -target
$(1)) \
26 gb_JavaClassSet_JAVACDEBUG
:=
28 # Enforces correct dependency order for possibly generated stuff:
29 # generated sources, jars/classdirs etc.
30 gb_JavaClassSet_get_preparation_target
= $(WORKDIR
)/JavaClassSet
/$(1).prepared
32 ifneq ($(gb_DEBUGLEVEL
),0)
33 gb_JavaClassSet_JAVACDEBUG
:= -g
36 # $(PACKAGEDIRS) inherited from Jar -- assumption is the last part of the path
37 # is top-level java package directory
38 # for Java 9 modules, invoke javac another time, with --patch-module so that
39 # it finds all the class files for whose packages the module-info contains a
41 define gb_JavaClassSet__command
42 $(call gb_Helper_abbreviate_dirs
,\
43 mkdir
-p
$(dir $(1)) && \
44 $(if
$(filter-out $(JARDEPS
),$(4)), \
45 rm -rf
$(call gb_JavaClassSet_get_classdir
,$(2))/* && \
46 RESPONSEFILE
=$(call gb_var2file
,$(shell $(gb_MKTEMP
)),\
47 $(filter-out $(JARDEPS
) $(T_JAVA9FILES
),$(4))) && \
48 $(if
$(3),$(call gb_JavaClassSet_JAVACCOMMAND
,$(JAVA_TARGET_VER
)) \
49 $(gb_JavaClassSet_JAVACDEBUG
) \
50 -classpath
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
51 -d
$(call gb_JavaClassSet_get_classdir
,$(2)) \
53 rm -f
$$RESPONSEFILE &&) \
54 $(if
$(MODULAR_JAVA
),$(if
$(T_MODULENAME
),\
55 RESPONSEFILE
=$(call gb_var2file
,$(shell $(gb_MKTEMP
)),\
57 $(if
$(3),$(call gb_JavaClassSet_JAVACCOMMAND
,9) \
58 $(gb_JavaClassSet_JAVACDEBUG
) \
59 -classpath
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
60 --module-path
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
61 $(if
$(T_MODULENAME
),--patch-module
$(T_MODULENAME
)="$(subst $(WHITESPACE),$(gb_CLASSPATHSEP),$(strip $(dir $(PACKAGEDIRS))))") \
62 -d
$(call gb_JavaClassSet_get_classdir
,$(2)) \
64 rm -f
$$RESPONSEFILE &&)) \
69 $(call gb_JavaClassSet_get_target
,%) :
70 $(call gb_Output_announce
,$*,$(true
),JCS
,3)
71 $(call gb_Trace_StartRange
,$*,JCS
)
72 $(call gb_JavaClassSet__command
,$@
,$*,$?
,$^
)
73 $(call gb_Trace_EndRange
,$*,JCS
)
75 $(call gb_JavaClassSet_get_clean_target
,%) :
76 $(call gb_Output_announce
,$*,$(false
),JCS
,3)
77 $(call gb_Helper_abbreviate_dirs
,\
78 rm -rf
$(dir $(call gb_JavaClassSet_get_target
,$*))) \
79 $(call gb_JavaClassSet_get_preparation_target
,$*)
81 $(call gb_JavaClassSet_get_preparation_target
,%) :
82 mkdir
-p
$(dir $@
) && touch
$@
84 # depend on makefile to enforce a rebuild if files are removed from the classset
85 # call gb_JavaClassSet_JavaClassSet,csname,java9modulename
86 define gb_JavaClassSet_JavaClassSet
87 $(call gb_JavaClassSet_get_target
,$(1)) : \
88 $(gb_Module_CURRENTMAKEFILE
) \
89 $(call gb_JavaClassSet_get_preparation_target
,$(1))
90 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
:= \
91 $(gb_Module_CURRENTMAKEFILE
) \
92 $(call gb_JavaClassSet_get_preparation_target
,$(1))
93 $(call gb_JavaClassSet_get_target
,$(1)) : T_MODULENAME
:= $(2)
94 $(call gb_JavaClassSet_get_target
,$(1)) : T_JAVA9FILES
:=
98 define gb_JavaClassSet__get_sourcefile
102 define gb_JavaClassSet__get_generated_sourcefile
106 define gb_JavaClassSet_add_sourcefile
107 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_sourcefile
,$(2))
111 define gb_JavaClassSet_add_sourcefiles
112 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_sourcefile
,$(1),$(sourcefile
)))
116 define gb_JavaClassSet_add_sourcefile_java9
117 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_sourcefile
,$(2))
118 $(call gb_JavaClassSet_get_target
,$(1)) : T_JAVA9FILES
+= $(call gb_JavaClassSet__get_sourcefile
,$(2))
122 define gb_JavaClassSet_add_sourcefiles_java9
123 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_sourcefile_java9
,$(1),$(sourcefile
)))
127 define gb_JavaClassSet_add_generated_sourcefile
128 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_generated_sourcefile
,$(2))
129 $(call gb_JavaClassSet__get_generated_sourcefile
,$(2)) :|
$(call gb_JavaClassSet_get_preparation_target
,$(1))
133 define gb_JavaClassSet_add_generated_sourcefiles
134 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_generated_sourcefile
,$(1),$(sourcefile
)))
138 define gb_JavaClassSet_add_classpath
139 $(call gb_JavaClassSet_get_target
,$(1)) : T_CP
:= $$(if
$$(T_CP
),$$(T_CP
)$$(gb_CLASSPATHSEP
))$(strip $(2))
143 define gb_JavaClassSet_use_jar
144 ifneq (,$$(filter-out $(gb_Jar_KNOWN
),$(2)))
145 $$(eval
$$(call gb_Output_info
,currently known jars are
: $(sort $(gb_Jar_KNOWN
)),ALL
))
146 $$(eval
$$(call gb_Output_error
,Cannot link against jar
$$(filter-out $(gb_Jar_KNOWN
),$(2)). Jars must be registered in Repository.mk or RepositoryExternal.mk
))
148 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
149 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_Jar_get_target
,$(2))
150 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_Jar_get_target
,$(2)))
154 # this does not generate dependency on the jar
155 define gb_JavaClassSet_use_system_jar
156 $(call gb_JavaClassSet_add_classpath
,$(1),$(2))
160 define gb_JavaClassSet_use_jars
161 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_jar
,$(1),$(jar
)))
165 define gb_JavaClassSet_use_system_jars
166 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_system_jar
,$(1),$(jar
)))
170 # gb_JavaClassSet_use_jar_classset: Like gb_JavaClassSet_use_jar, but instead of
171 # using the jar, use the directory tree with the class files that make up the
172 # jar. This is sometimes necessary in JunitTests that have test classes in
173 # packages that belong to a sealed jar.
174 # $1: token identifying this JavaClassSet
175 # $2: token identifying the Jar being used
176 define gb_JavaClassSet_use_jar_classset
177 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
178 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
179 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_JavaClassSet_get_classdir
,$(call gb_Jar_get_classsetname
,$(2))))
183 define gb_JavaClassSet_use_customtarget
184 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
185 $(call gb_CustomTarget_get_target
,$(2))
186 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_CustomTarget_get_workdir
,$(2)))
190 define gb_JavaClassSet_use_external_project
191 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
192 $(call gb_ExternalProject_get_target
,$(2))
196 # vim: set noet sw=4: