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
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)) \
45 rm -f
$$RESPONSEFILE &&) \
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))
74 define gb_JavaClassSet__get_sourcefile
78 define gb_JavaClassSet__get_generated_sourcefile
82 define gb_JavaClassSet_add_sourcefile
83 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet__get_sourcefile
,$(2))
87 define gb_JavaClassSet_add_sourcefiles
88 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_sourcefile
,$(1),$(sourcefile
)))
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))
98 define gb_JavaClassSet_add_generated_sourcefiles
99 $(foreach sourcefile
,$(2),$(call gb_JavaClassSet_add_generated_sourcefile
,$(1),$(sourcefile
)))
103 define gb_JavaClassSet_add_classpath
104 $(call gb_JavaClassSet_get_target
,$(1)) : T_CP
:= $$(if
$$(T_CP
),$$(T_CP
)$$(gb_CLASSPATHSEP
))$(strip $(2))
108 define gb_JavaClassSet_use_jar
109 ifneq (,$$(filter-out $(gb_Jar_KNOWN
),$(2)))
110 $$(eval
$$(call gb_Output_info
,currently known jars are
: $(sort $(gb_Jar_KNOWN
)),ALL
))
111 $$(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
))
113 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
114 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_Jar_get_target
,$(2))
115 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_Jar_get_target
,$(2)))
119 # this does not generate dependency on the jar
120 define gb_JavaClassSet_use_system_jar
121 $(call gb_JavaClassSet_add_classpath
,$(1),$(2))
125 define gb_JavaClassSet_use_jars
126 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_jar
,$(1),$(jar
)))
130 define gb_JavaClassSet_use_system_jars
131 $(foreach jar
,$(2),$(call gb_JavaClassSet_use_system_jar
,$(1),$(jar
)))
135 # gb_JavaClassSet_use_jar_classset: Like gb_JavaClassSet_use_jar, but instead of
136 # using the jar, use the directory tree with the class files that make up the
137 # jar. This is sometimes necessary in JunitTests that have test classes in
138 # packages that belong to a sealed jar.
139 # $1: token identifying this JavaClassSet
140 # $2: token identifying the Jar being used
141 define gb_JavaClassSet_use_jar_classset
142 $(call gb_JavaClassSet_get_target
,$(1)) : $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
143 $(call gb_JavaClassSet_get_target
,$(1)) : JARDEPS
+= $(call gb_JavaClassSet_get_target
,$(call gb_Jar_get_classsetname
,$(2)))
144 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_JavaClassSet_get_classdir
,$(call gb_Jar_get_classsetname
,$(2))))
148 define gb_JavaClassSet_use_customtarget
149 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
150 $(call gb_CustomTarget_get_target
,$(2))
151 $(call gb_JavaClassSet_add_classpath
,$(1),$(call gb_CustomTarget_get_workdir
,$(2)))
155 define gb_JavaClassSet_use_external_project
156 $(call gb_JavaClassSet_get_preparation_target
,$(1)) : \
157 $(call gb_ExternalProject_get_target
,$(2))
161 # vim: set noet sw=4: