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
) \
23 $(if
$(JAVA_CLASSPATH_NOT_SET
),-Xlint
:-options
)
25 gb_JavaClassSet_JAVACDEBUG
:=
27 # Enforces correct dependency order for possibly generated stuff:
28 # generated sources, jars/classdirs etc.
29 gb_JavaClassSet_get_preparation_target
= $(WORKDIR
)/JavaClassSet
/$(1).prepared
31 ifneq ($(gb_DEBUGLEVEL
),0)
32 gb_JavaClassSet_JAVACDEBUG
:= -g
35 # $(PACKAGEDIRS) inherited from Jar -- assumption is the last part of the path
36 # is top-level java package directory
37 # for Java 9 modules, invoke javac another time, with --patch-module so that
38 # it finds all the class files for whose packages the module-info contains a
40 define gb_JavaClassSet__command
41 $(call gb_Helper_abbreviate_dirs
,\
42 mkdir
-p
$(dir $(1)) && \
43 $(if
$(filter-out $(JARDEPS
),$(4)), \
44 rm -rf
$(call gb_JavaClassSet_get_classdir
,$(2))/* && \
45 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),500,\
46 $(filter-out $(JARDEPS
) $(T_JAVA9FILES
),$(4))) && \
47 $(if
$(3),$(call gb_JavaClassSet_JAVACCOMMAND
,$(JAVA_TARGET_VER
)) \
48 $(gb_JavaClassSet_JAVACDEBUG
) \
49 -classpath
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
50 -d
$(call gb_JavaClassSet_get_classdir
,$(2)) \
52 rm -f
$$RESPONSEFILE &&) \
53 $(if
$(T_MODULENAME
),\
54 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),500,\
56 $(if
$(3),$(call gb_JavaClassSet_JAVACCOMMAND
,9) \
57 $(gb_JavaClassSet_JAVACDEBUG
) \
58 -classpath
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
59 --module-path
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
60 $(if
$(T_MODULENAME
),--patch-module
$(T_MODULENAME
)="$(subst $(WHITESPACE),$(gb_CLASSPATHSEP),$(strip $(dir $(PACKAGEDIRS))))") \
61 -d
$(call gb_JavaClassSet_get_classdir
,$(2)) \
63 rm -f
$$RESPONSEFILE &&) \
68 $(call gb_JavaClassSet_get_target
,%) :
69 $(call gb_Output_announce
,$*,$(true
),JCS
,3)
70 $(call gb_Trace_StartRange
,$*,JCS
)
71 $(call gb_JavaClassSet__command
,$@
,$*,$?
,$^
)
72 $(call gb_Trace_EndRange
,$*,JCS
)
74 $(call gb_JavaClassSet_get_clean_target
,%) :
75 $(call gb_Output_announce
,$*,$(false
),JCS
,3)
76 $(call gb_Helper_abbreviate_dirs
,\
77 rm -rf
$(dir $(call gb_JavaClassSet_get_target
,$*))) \
78 $(call gb_JavaClassSet_get_preparation_target
,$*)
80 $(call gb_JavaClassSet_get_preparation_target
,%) :
81 mkdir
-p
$(dir $@
) && touch
$@
83 # depend on makefile to enforce a rebuild if files are removed from the classset
84 # call gb_JavaClassSet_JavaClassSet,csname,java9modulename
85 define gb_JavaClassSet_JavaClassSet
86 $(call gb_JavaClassSet_get_target
,$(1)) : \
87 $(gb_Module_CURRENTMAKEFILE
) \
88 $(call gb_JavaClassSet_get_preparation_target
,$(1))
89 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
:= \
90 $(gb_Module_CURRENTMAKEFILE
) \
91 $(call gb_JavaClassSet_get_preparation_target
,$(1))
92 $(call gb_JavaClassSet_get_target
,$(1)) : T_MODULENAME
:= $(2)
93 $(call gb_JavaClassSet_get_target
,$(1)) : T_JAVA9FILES
:=
97 define gb_JavaClassSet__get_sourcefile
101 define gb_JavaClassSet__get_generated_sourcefile
105 define gb_JavaClassSet_add_sourcefile
106 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_sourcefile
,$(2))
110 define gb_JavaClassSet_add_sourcefiles
111 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_sourcefile
,$(1),$(sourcefile
)))
115 define gb_JavaClassSet_add_sourcefile_java9
116 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_sourcefile
,$(2))
117 $(call gb_JavaClassSet_get_target
,$(1)) : T_JAVA9FILES
+= $(call gb_JavaClassSet__get_sourcefile
,$(2))
121 define gb_JavaClassSet_add_sourcefiles_java9
122 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_sourcefile_java9
,$(1),$(sourcefile
)))
126 define gb_JavaClassSet_add_generated_sourcefile
127 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_generated_sourcefile
,$(2))
128 $(call gb_JavaClassSet__get_generated_sourcefile
,$(2)) :|
$(call gb_JavaClassSet_get_preparation_target
,$(1))
132 define gb_JavaClassSet_add_generated_sourcefiles
133 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_generated_sourcefile
,$(1),$(sourcefile
)))
137 define gb_JavaClassSet_add_classpath
138 $(call gb_JavaClassSet_get_target
,$(1)) : T_CP
:= $$(if
$$(T_CP
),$$(T_CP
)$$(gb_CLASSPATHSEP
))$(strip $(2))
142 define gb_JavaClassSet_use_jar
143 ifneq (,$$(filter-out $(gb_Jar_KNOWN
),$(2)))
144 $$(eval
$$(call gb_Output_info
,currently known jars are
: $(sort $(gb_Jar_KNOWN
)),ALL
))
145 $$(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
))
147 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
148 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_Jar_get_target
,$(2))
149 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_Jar_get_target
,$(2)))
153 # this does not generate dependency on the jar
154 define gb_JavaClassSet_use_system_jar
155 $(call gb_JavaClassSet_add_classpath
,$(1),$(2))
159 define gb_JavaClassSet_use_jars
160 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_jar
,$(1),$(jar
)))
164 define gb_JavaClassSet_use_system_jars
165 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_system_jar
,$(1),$(jar
)))
169 # gb_JavaClassSet_use_jar_classset: Like gb_JavaClassSet_use_jar, but instead of
170 # using the jar, use the directory tree with the class files that make up the
171 # jar. This is sometimes necessary in JunitTests that have test classes in
172 # packages that belong to a sealed jar.
173 # $1: token identifying this JavaClassSet
174 # $2: token identifying the Jar being used
175 define gb_JavaClassSet_use_jar_classset
176 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
177 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
178 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_JavaClassSet_get_classdir
,$(call gb_Jar_get_classsetname
,$(2))))
182 define gb_JavaClassSet_use_customtarget
183 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
184 $(call gb_CustomTarget_get_target
,$(2))
185 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_CustomTarget_get_workdir
,$(2)))
189 define gb_JavaClassSet_use_external_project
190 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
191 $(call gb_ExternalProject_get_target
,$(2))
195 # vim: set noet sw=4: