summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-05-07 09:42:22 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2020-05-27 11:40:20 +0200
commit941b567a41569260fef14a7337511e8f42337323 (patch)
treefe04ef41038df279689e2a979dc28e7fe5b37670 /solenv
parent77140de3fe925f75620e94dbd848b1c925935fb5 (diff)
tdf#131572 Add java 9 module info for libreoffice.jar
Add a java module named "org.libreoffice.uno" for this jar. This needs to be compiled with Java 9. But since we want to keep b/c with Java 8, the rest of the jar has to be compiled with Java 8. This bumps the *build* requirement to Java 9 while keeping the *runtime* requirement at Java 8. The gbuild JavaClassSet class is changed to invoke javac twice, where the 2nd invocation compiles with --release 9 and a --patch-modules argument so that it finds the results of the first invocation and also the javamaker generated files in CustomTargets. Change-Id: I888f5dbe097cc37136e68db5919939877c981862 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91105 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'solenv')
-rw-r--r--solenv/gbuild/Jar.mk14
-rw-r--r--solenv/gbuild/JavaClassSet.mk38
-rw-r--r--solenv/gbuild/gbuild.mk2
3 files changed, 49 insertions, 5 deletions
diff --git a/solenv/gbuild/Jar.mk b/solenv/gbuild/Jar.mk
index 76385702f1ab..1bbfeca166eb 100644
--- a/solenv/gbuild/Jar.mk
+++ b/solenv/gbuild/Jar.mk
@@ -94,6 +94,7 @@ endef
# creates a class set and a dependency to it
# registers target and clean target
# adds jar files to DeliverLogTarget
+# call gb_Jar_Jar,jarname,java9modulename
define gb_Jar_Jar
ifeq (,$$(findstring $(1),$$(gb_Jar_KNOWN)))
$$(eval $$(call gb_Output_info,Currently known jars are: $(sort $(gb_Jar_KNOWN)),ALL))
@@ -106,7 +107,7 @@ $(call gb_Jar_get_target,$(1)) : PACKAGEDIRS :=
$(call gb_Jar_get_target,$(1)) : PACKAGEFILES :=
$(call gb_Jar_get_target,$(1)) : \
$(call gb_JavaClassSet_get_target,$(call gb_Jar_get_classsetname,$(1)))
-$(call gb_JavaClassSet_JavaClassSet,$(call gb_Jar_get_classsetname,$(1)))
+$(call gb_JavaClassSet_JavaClassSet,$(call gb_Jar_get_classsetname,$(1)),$(2))
$(eval $(call gb_Module_register_target,$(call gb_Jar_get_target,$(1)),$(call gb_Jar_get_clean_target,$(1))))
$(call gb_Helper_make_userfriendly_targets,$(1),Jar,$(call gb_Jar_get_target,$(1)))
@@ -121,6 +122,12 @@ $(call gb_JavaClassSet_add_sourcefile,$(call gb_Jar_get_classsetname,$(1)),$(2))
endef
+define gb_Jar_add_sourcefile_java9
+$(call gb_JavaClassSet_add_sourcefile_java9,$(call gb_Jar_get_classsetname,$(1)),$(2))
+
+endef
+
+
# PACKAGEROOTS is the list of all root folders created by the JavaClassSet to pack into the jar (without META-INF as this is added automatically)
define gb_Jar_set_packageroot
$(call gb_Jar_get_target,$(1)) : PACKAGEROOTS := $(2)
@@ -159,6 +166,11 @@ $(foreach sourcefile,$(2),$(call gb_Jar_add_sourcefile,$(1),$(sourcefile)))
endef
+define gb_Jar_add_sourcefiles_java9
+$(foreach sourcefile,$(2),$(call gb_Jar_add_sourcefile_java9,$(1),$(sourcefile)))
+
+endef
+
define gb_Jar_add_generated_sourcefile
$(call gb_JavaClassSet_add_generated_sourcefile,$(call gb_Jar_get_classsetname,$(1)),$(2))
diff --git a/solenv/gbuild/JavaClassSet.mk b/solenv/gbuild/JavaClassSet.mk
index dc7d02e8904a..42ca5cfc4910 100644
--- a/solenv/gbuild/JavaClassSet.mk
+++ b/solenv/gbuild/JavaClassSet.mk
@@ -17,10 +17,11 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-gb_JavaClassSet_JAVACCOMMAND := $(ICECREAM_RUN) $(JAVACOMPILER) $(JAVAFLAGS) \
+gb_JavaClassSet_JAVACCOMMAND = $(ICECREAM_RUN) $(JAVACOMPILER) $(JAVAFLAGS) \
-encoding utf8 \
- -source $(JAVA_SOURCE_VER) -target $(JAVA_TARGET_VER) \
+ --release $(1) \
$(if $(JAVA_CLASSPATH_NOT_SET),-Xlint:-options)
+
gb_JavaClassSet_JAVACDEBUG :=
# Enforces correct dependency order for possibly generated stuff:
@@ -31,19 +32,34 @@ ifneq ($(gb_DEBUGLEVEL),0)
gb_JavaClassSet_JAVACDEBUG := -g
endif
+# $(PACKAGEDIRS) inherited from Jar -- assumption is the last part of the path
+# is top-level java package directory
+# for Java 9 modules, invoke javac another time, with --patch-module so that
+# it finds all the class files for whose packages the module-info contains a
+# declaration
define gb_JavaClassSet__command
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $(1)) && \
$(if $(filter-out $(JARDEPS),$(4)), \
rm -rf $(call gb_JavaClassSet_get_classdir,$(2))/* && \
RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,\
- $(filter-out $(JARDEPS),$(4))) && \
- $(if $(3),$(gb_JavaClassSet_JAVACCOMMAND) \
+ $(filter-out $(JARDEPS) $(T_JAVA9FILES),$(4))) && \
+ $(if $(3),$(call gb_JavaClassSet_JAVACCOMMAND,$(JAVA_TARGET_VER)) \
$(gb_JavaClassSet_JAVACDEBUG) \
-classpath "$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
-d $(call gb_JavaClassSet_get_classdir,$(2)) \
@$$RESPONSEFILE &&) \
rm -f $$RESPONSEFILE &&) \
+ $(if $(T_MODULENAME),\
+ RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,\
+ $(T_JAVA9FILES)) && \
+ $(if $(3),$(call gb_JavaClassSet_JAVACCOMMAND,9) \
+ $(gb_JavaClassSet_JAVACDEBUG) \
+ -classpath "$(T_CP)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(2))" \
+ $(if $(T_MODULENAME),--patch-module $(T_MODULENAME)="$(subst $(WHITESPACE),$(gb_CLASSPATHSEP),$(strip $(dir $(PACKAGEDIRS))))") \
+ -d $(call gb_JavaClassSet_get_classdir,$(2)) \
+ @$$RESPONSEFILE &&) \
+ ) \
touch $(1))
endef
@@ -64,6 +80,7 @@ $(call gb_JavaClassSet_get_preparation_target,%) :
mkdir -p $(dir $@) && touch $@
# depend on makefile to enforce a rebuild if files are removed from the classset
+# call gb_JavaClassSet_JavaClassSet,csname,java9modulename
define gb_JavaClassSet_JavaClassSet
$(call gb_JavaClassSet_get_target,$(1)) : \
$(gb_Module_CURRENTMAKEFILE) \
@@ -71,6 +88,8 @@ $(call gb_JavaClassSet_get_target,$(1)) : \
$(call gb_JavaClassSet_get_target,$(1)) : JARDEPS := \
$(gb_Module_CURRENTMAKEFILE) \
$(call gb_JavaClassSet_get_preparation_target,$(1))
+$(call gb_JavaClassSet_get_target,$(1)) : T_MODULENAME := $(2)
+$(call gb_JavaClassSet_get_target,$(1)) : T_JAVA9FILES :=
endef
@@ -92,6 +111,17 @@ $(foreach sourcefile,$(2),$(call gb_JavaClassSet_add_sourcefile,$(1),$(sourcefil
endef
+define gb_JavaClassSet_add_sourcefile_java9
+$(call gb_JavaClassSet_get_target,$(1)) : $(call gb_JavaClassSet__get_sourcefile,$(2))
+$(call gb_JavaClassSet_get_target,$(1)) : T_JAVA9FILES += $(call gb_JavaClassSet__get_sourcefile,$(2))
+
+endef
+
+define gb_JavaClassSet_add_sourcefiles_java9
+$(foreach sourcefile,$(2),$(call gb_JavaClassSet_add_sourcefile_java9,$(1),$(sourcefile)))
+
+endef
+
define gb_JavaClassSet_add_generated_sourcefile
$(call gb_JavaClassSet_get_target,$(1)) : $(call gb_JavaClassSet__get_generated_sourcefile,$(2))
$(call gb_JavaClassSet__get_generated_sourcefile,$(2)) :| $(call gb_JavaClassSet_get_preparation_target,$(1))
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 99547941ef8c..97d2879dcc9b 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -60,6 +60,8 @@ COMMA :=,
OPEN_PAREN :=(
CLOSE_PAREN :=)
+gb_SPACE:=$(gb_SPACE) $(gb_SPACE)
+
gb_VERBOSE := $(verbose)
include $(GBUILDDIR)/Helper.mk