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
) \
22 -source
$(JAVA_SOURCE_VER
) -target
$(JAVA_TARGET_VER
) \
23 $(if
$(JAVA_CLASSPATH_NOT_SET
),-Xlint
:-options
)
24 gb_JavaClassSet_JAVACDEBUG
:=
26 # Enforces correct dependency order for possibly generated stuff:
27 # generated sources, jars/classdirs etc.
28 gb_JavaClassSet_get_preparation_target
= $(WORKDIR
)/JavaClassSet
/$(1).prepared
30 ifneq ($(gb_DEBUGLEVEL
),0)
31 gb_JavaClassSet_JAVACDEBUG
:= -g
34 define gb_JavaClassSet__command
35 $(call gb_Helper_abbreviate_dirs
,\
36 mkdir
-p
$(dir $(1)) && \
37 $(if
$(filter-out $(JARDEPS
),$(4)), \
38 rm -rf
$(call gb_JavaClassSet_get_classdir
,$(2))/* && \
39 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),500,\
40 $(filter-out $(JARDEPS
),$(4))) && \
41 $(if
$(3),$(gb_JavaClassSet_JAVACCOMMAND
) \
42 $(gb_JavaClassSet_JAVACDEBUG
) \
43 -classpath
"$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
44 -d
$(call gb_JavaClassSet_get_classdir
,$(2)) \
46 rm -f
$$RESPONSEFILE &&) \
51 $(call gb_JavaClassSet_get_target
,%) :
52 $(call gb_Output_announce
,$*,$(true
),JCS
,3)
53 $(call gb_JavaClassSet__command
,$@
,$*,$?
,$^
)
55 $(call gb_JavaClassSet_get_clean_target
,%) :
56 $(call gb_Output_announce
,$*,$(false
),JCS
,3)
57 $(call gb_Helper_abbreviate_dirs
,\
58 rm -rf
$(dir $(call gb_JavaClassSet_get_target
,$*))) \
59 $(call gb_JavaClassSet_get_preparation_target
,$*)
61 $(call gb_JavaClassSet_get_preparation_target
,%) :
62 mkdir
-p
$(dir $@
) && touch
$@
64 # depend on makefile to enforce a rebuild if files are removed from the classset
65 define gb_JavaClassSet_JavaClassSet
66 $(call gb_JavaClassSet_get_target
,$(1)) : \
67 $(gb_Module_CURRENTMAKEFILE
) \
68 $(call gb_JavaClassSet_get_preparation_target
,$(1))
69 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
:= \
70 $(gb_Module_CURRENTMAKEFILE
) \
71 $(call gb_JavaClassSet_get_preparation_target
,$(1))
75 define gb_JavaClassSet__get_sourcefile
79 define gb_JavaClassSet__get_generated_sourcefile
83 define gb_JavaClassSet_add_sourcefile
84 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_sourcefile
,$(2))
88 define gb_JavaClassSet_add_sourcefiles
89 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_sourcefile
,$(1),$(sourcefile
)))
93 define gb_JavaClassSet_add_generated_sourcefile
94 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_generated_sourcefile
,$(2))
95 $(call gb_JavaClassSet__get_generated_sourcefile
,$(2)) :|
$(call gb_JavaClassSet_get_preparation_target
,$(1))
99 define gb_JavaClassSet_add_generated_sourcefiles
100 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_generated_sourcefile
,$(1),$(sourcefile
)))
104 define gb_JavaClassSet_add_classpath
105 $(call gb_JavaClassSet_get_target
,$(1)) : T_CP
:= $$(if
$$(T_CP
),$$(T_CP
)$$(gb_CLASSPATHSEP
))$(strip $(2))
109 define gb_JavaClassSet_use_jar
110 ifneq (,$$(filter-out $(gb_Jar_KNOWN
),$(2)))
111 $$(eval
$$(call gb_Output_info
,currently known jars are
: $(sort $(gb_Jar_KNOWN
)),ALL
))
112 $$(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
))
114 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
115 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_Jar_get_target
,$(2))
116 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_Jar_get_target
,$(2)))
120 # this does not generate dependency on the jar
121 define gb_JavaClassSet_use_system_jar
122 $(call gb_JavaClassSet_add_classpath
,$(1),$(2))
126 define gb_JavaClassSet_use_jars
127 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_jar
,$(1),$(jar
)))
131 define gb_JavaClassSet_use_system_jars
132 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_system_jar
,$(1),$(jar
)))
136 # gb_JavaClassSet_use_jar_classset: Like gb_JavaClassSet_use_jar, but instead of
137 # using the jar, use the directory tree with the class files that make up the
138 # jar. This is sometimes necessary in JunitTests that have test classes in
139 # packages that belong to a sealed jar.
140 # $1: token identifying this JavaClassSet
141 # $2: token identifying the Jar being used
142 define gb_JavaClassSet_use_jar_classset
143 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
144 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
145 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_JavaClassSet_get_classdir
,$(call gb_Jar_get_classsetname
,$(2))))
149 define gb_JavaClassSet_use_customtarget
150 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
151 $(call gb_CustomTarget_get_target
,$(2))
152 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_CustomTarget_get_workdir
,$(2)))
156 define gb_JavaClassSet_use_external_project
157 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
158 $(call gb_ExternalProject_get_target
,$(2))
162 # vim: set noet sw=4: