diff options
-rw-r--r-- | solenv/gbuild/Jar.mk | 159 | ||||
-rw-r--r-- | solenv/gbuild/JavaClassSet.mk | 9 | ||||
-rwxr-xr-x | solenv/gbuild/TargetLocations.mk | 7 | ||||
-rw-r--r-- | solenv/gbuild/Zip.mk | 77 | ||||
-rw-r--r-- | solenv/gbuild/gbuild.mk | 4 |
5 files changed, 255 insertions, 1 deletions
diff --git a/solenv/gbuild/Jar.mk b/solenv/gbuild/Jar.mk new file mode 100644 index 000000000000..a719d73bb1aa --- /dev/null +++ b/solenv/gbuild/Jar.mk @@ -0,0 +1,159 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# if a jar prerequisite has changed, the ClassSet must be recompiled. How? + +# Jar class + +gb_Jar_JAVACOMMAND := $(JAVAINTERPRETER) +gb_Jar_JARCOMMAND := jar + +# location of manifest file in workdir +define gb_Jar_get_manifest_target +$(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(1)))/META-INF/MANIFEST.MF +endef + +# creates classset and META-INF folders if they don't exist +# adds manifest version, class path, solarversion and content from sources to manifest file +# creates the target folder of the jar file if it doesn't exist +# creates the jar file +define gb_Jar__command + $(call gb_Helper_abbreviate_dirs_native,\ + mkdir -p $(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(1)))/META-INF && \ + echo Manifest-Version: 1.0 > $(call gb_Jar_get_manifest_target,$(1)) && \ + echo "Class-Path: $(JARCLASSPATH)" >> $(call gb_Jar_get_manifest_target,$(1)) && \ + echo "Solar-Version: $(RSCREVISION)" >> $(call gb_Jar_get_manifest_target,$(1)) && \ + cat $(MANIFEST) >> $(call gb_Jar_get_manifest_target,$(1)) && \ + mkdir -p $(dir $(2)) && \ + cd $(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(1))) && $(gb_Jar_JARCOMMAND) cfm $(2) $(call gb_Jar_get_manifest_target,$(1)) META-INF $(PACKAGEROOTS) ) +endef + +# clean target reuses clean target of ClassSet +$(call gb_Jar_get_clean_target,%) : $(call gb_JavaClassSet_get_clean_target,$(call gb_Jar_get_classsetname,%)) + $(call gb_Output_announce,$*,$(false),JAR,3) + $(call gb_Helper_abbreviate_dirs,\ + rm -rf $(dir $(call gb_Jar_get_target,$*)) && \ + rm -f $(call gb_Jar_get_final_target,$*) && \ + rm -f $(call gb_Jar_get_outdir_target,$*)) + +# resets scoped variables +# creates a class set and a dependency to it +# registers target and clean target +# creates a rule to move common jar files to solver when needed +# adds jar files to DeliverTarget +define gb_Jar_Jar + +$(call gb_Jar_get_target,$(1)) : CLASSPATH := $(value XCLASSPATH) +$(call gb_Jar_get_target,$(1)) : MANIFEST := +$(call gb_Jar_get_target,$(1)) : JARCLASSPATH := +$(call gb_Jar_get_target,$(1)) : PACKAGEROOTS := + +$(call gb_JavaClassSet_JavaClassSet,$(call gb_Jar_get_classsetname,$(1))) +$(call gb_Jar_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_Jar_get_classsetname,$(1))) + $$(call gb_Jar__command,$(1),$$@,$$*,$$?) + +$(call gb_Jar_get_final_target,$(1)) : $(call gb_Jar_get_outdir_target,$(1)) + $$(call gb_Helper_abbreviate_dirs,\ + touch $$@) + +$(call gb_Jar_get_outdir_target,$(1)) : $(call gb_Jar_get_target,$(1)) + $(call gb_Helper_abbreviate_dirs,\ + $$(call gb_Deliver_deliver,$$<,$$@)) + +$(eval $(call gb_Module_register_target,$(call gb_Jar_get_final_target,$(1)),$(call gb_Jar_get_clean_target,$(1)))) + +$(call gb_Deliver_add_deliverable,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Jar_get_target,$(1))) + +endef + +# source files are forwarded to the ClassSet +define gb_Jar_add_sourcefile +$(call gb_JavaClassSet_add_sourcefile,$(call gb_Jar_get_classsetname,$(1)),$(2)) +endef + +define gb_Jar_set_packageroot +$(call gb_Jar_get_target,$(1)) : PACKAGEROOTS := $(2) +endef + +define gb_Jar_add_sourcefiles +$(foreach sourcefile,$(2),$(call gb_Jar_add_sourcefile,$(1),$(sourcefile))) +endef + +# don't forward it to ClassSet; the ClassSet "inherits" the classpath from the Jar +define gb_JarTest_set_classpath +$(call gb_Jar_get_target,$(1)) : CLASSPATH := $(2) +endef + +# JARCLASSPATH is the class path that is written to the manifest of the jar +define gb_Jar_set_jarclasspath + +$(call gb_Jar_get_target,$(1)) : JARCLASSPATH := $(2) +endef + +# provide a manifest template containing jar specific information to be written into the manifest +# it will be appended to the standard content that is written in the build command explicitly +# the jar file gets a dependency to the manifest template +define gb_Jar_set_manifest +$(call gb_Jar_get_target,$(1)) : MANIFEST := $(2) +$(call gb_Jar_get_target,$(1)) : $(2) + +endef + +# remember: classpath is "inherited" to ClassSet +define gb_Jar_add_jar +$(call gb_Jar_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$(gb_CLASSPATHSEP)$(2) +$(call gb_JavaClassSet_add_jar,$(call gb_Jar_get_classsetname,$(1)),$(2)) + +endef + +# specify jars with imported modules +define gb_Jar_add_jars +$(foreach jar,$(2),$(call gb_Jar_add_jar,$(1),$(jar))) +endef + +# possible directories for jar files containing UNO services +gb_Jar_COMPONENTPREFIXES := \ + OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/classes/ \ + URE:vnd.sun.star.expand:\dURE_INTERNAL_JAVA_DIR/ \ + INTERN:vnd.sun.star.expand:\dOOO_INBUILD_JAVA_DIR/ + +# get component prefix from layer name ("OOO", "URE", "INTERN") +gb_Jar__get_componentprefix = \ + $(patsubst $(1):%,%,$(or \ + $(filter $(1):%,$(gb_Jar_COMPONENTPREFIXES)), \ + $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)'))) + +# layer must be specified explicitly in this macro (different to libraries) +define gb_Jar_set_componentfile +$(call gb_ComponentTarget_ComponentTarget,$(2),$(call gb_Jar__get_componentprefix,$(3)),$(notdir $(call gb_Jar_get_target,$(1)))) +$(call gb_Jar_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2)) +$(call gb_Jar_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2)) + +endef + + +# vim: set noet sw=4 ts=4: diff --git a/solenv/gbuild/JavaClassSet.mk b/solenv/gbuild/JavaClassSet.mk index 655aedbd17d9..6bb859f270d6 100644 --- a/solenv/gbuild/JavaClassSet.mk +++ b/solenv/gbuild/JavaClassSet.mk @@ -52,9 +52,9 @@ $(call gb_JavaClassSet_get_clean_target,%) : $(call gb_Helper_abbreviate_dirs,\ rm -rf $(dir $(call gb_JavaClassSet_get_target,$*))) - $(foreach reponame,$(gb_JavaClassSet_REPOSITORYNAMES),$(eval $(call gb_JavaClassSet__rules,$(reponame)))) +# no initialization of scoped variable CLASSPATH as it is "inherited" from controlling instance (e.g. JUnitTest, Jar) define gb_JavaClassSet_JavaClassSet endef @@ -78,4 +78,11 @@ $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $(2) endef +# problem: currently we can't get these dependencies to work +# build order dependency is a hack to get these prerequisites out of the way in the build command +define gb_JavaClassSet_add_jar +$(foreach reponame,$(gb_JavaClassSet_REPOSITORYNAMES),\ + $(eval $(call gb_JavaClassSet_get_repo_target,$(reponame),$(1)) :| $(2))) + +endef # vim: set noet sw=4 ts=4: diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk index 60e53ec10e15..5015dbdcb65e 100755 --- a/solenv/gbuild/TargetLocations.mk +++ b/solenv/gbuild/TargetLocations.mk @@ -33,6 +33,8 @@ gb_PackagePart_get_destinations = $(OUTDIR)/xml $(OUTDIR)/inc $(OUTDIR)/bin gb_PackagePart_get_target = $(OUTDIR)/$(1) gb_ResTarget_get_outdir_imagelist_target = $(OUTDIR)/res/img/$(1).ilst gb_ResTarget_get_outdir_target = $(OUTDIR)/bin/$(1).res +gb_Jar_get_outdir_target = $(OUTDIR)/bin/$(1).jar +gb_Zip_get_outdir_target = $(OUTDIR)/pck/$(1).zip define gb_Library_get_target $(patsubst $(1):%,$(gb_Library_OUTDIRLOCATION)/%,$(filter $(filter $(1),$(gb_Library_TARGETS)):%,$(gb_Library_FILENAMES))) @@ -56,6 +58,9 @@ gb_CxxObject_get_target = $(WORKDIR)/CxxObject/$(1).o gb_GenCxxObject_get_target = $(WORKDIR)/GenCxxObject/$(1).o gb_Executable_get_external_headers_target = $(WORKDIR)/ExternalHeaders/Executable/$(1) gb_Executable_get_headers_target = $(WORKDIR)/Headers/Executable/$(1) +gb_Jar_get_target = $(WORKDIR)/Jar/$(1)/$(1).jar +gb_Jar_get_final_target = $(WORKDIR)/Jar/$(1).done +gb_Jar_get_classsetname = Jar/$(1) gb_JavaClassSet_get_classdir = $(WORKDIR)/JavaClassSet/$(1) gb_JavaClassSet_get_repo_target = $(WORKDIR)/JavaClassSet/$(2)/$(1).done gb_JavaClassSet_get_target = $(WORKDIR)/JavaClassSet/$(1)/done @@ -82,6 +87,8 @@ gb_SrsPartMergeTarget_get_target = $(WORKDIR)/SrsPartMergeTarget/$(1) gb_SrsPartTarget_get_target = $(WORKDIR)/SrsPartTarget/$(1) gb_SrsTarget_get_target = $(WORKDIR)/SrsTarget/$(1).srs gb_WinResTarget_get_target = $(WORKDIR)/WinResTarget/$(1)$(gb_WinResTarget_POSTFIX) +gb_Zip_get_target = $(WORKDIR)/Zip/$(1)/$(1).zip +gb_Zip_get_final_target = $(WORKDIR)/Zip/$(1).done define gb_Library_get_external_headers_target $(patsubst $(1):%,$(WORKDIR)/ExternalHeaders/Library/%,$(filter $(1):%,$(gb_Library_FILENAMES))) diff --git a/solenv/gbuild/Zip.mk b/solenv/gbuild/Zip.mk new file mode 100644 index 000000000000..6f677c181af1 --- /dev/null +++ b/solenv/gbuild/Zip.mk @@ -0,0 +1,77 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# Zip class + +gb_Zip_ZIPCOMMAND := zip + +# remove zip file in workdir and outdir +$(call gb_Zip_get_clean_target,%) : + $(call gb_Output_announce,$*,$(false),ZIP,3) + $(call gb_Helper_abbreviate_dirs,\ + rm -f $(call gb_Zip_get_target,$*) && \ + rm -f $(call gb_Zip_get_final_target,$*) && \ + rm -f $(call gb_Zip_get_outdir_target,$*)) + +# clear file list, set location (zipping uses relative paths) +# register target and clean target +# add deliverable +define gb_Zip_Zip + +$(call gb_Zip_get_target,$(1)) : FILES := +$(call gb_Zip_get_target,$(1)) : LOCATION := $(2) +gb_Package_Location_$(1) := $(2) + +$(call gb_Zip_get_final_target,$(1)) : $(call gb_Zip_get_outdir_target,$(1)) + touch $$@ + +$(call gb_Zip_get_outdir_target,$(1)) : $(call gb_Zip_get_target,$(1)) + $(call gb_Helper_abbreviate_dirs,\ + $$(call gb_Deliver_deliver,$$<,$$@)) + +$(eval $(call gb_Module_register_target,$(call gb_Zip_get_final_target,$(1)),$(call gb_Zip_get_clean_target,$(1)))) + +$(call gb_Zip_get_target,$(1)) : + $(call gb_Helper_abbreviate_dirs_native,\ + mkdir -p $$(dir $$(call gb_Zip_get_target,$(1))) && \ + cd $$(LOCATION) && $$(gb_Zip_ZIPCOMMAND) -rX -FS $$(call gb_Zip_get_target,$(1)) $$(FILES) ) + +$(call gb_Deliver_add_deliverable,$(call gb_Zip_get_outdir_target,$(1)),$(call gb_Zip_get_target,$(1))) + +endef + +define gb_Zip_add_file +$(call gb_Zip_get_target,$(1)) : FILES += $(2) +$(call gb_Zip_get_target,$(1)) : $(gb_Package_Location_$(1))/$(2) + +endef + +define gb_Zip_add_files +$(foreach file,$(2),$(call gb_Zip_add_file,$(1),$(file))) +endef + +# vim: set noet sw=4 ts=4: diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk index c370ca57ce81..57c8bdcbe978 100644 --- a/solenv/gbuild/gbuild.mk +++ b/solenv/gbuild/gbuild.mk @@ -201,6 +201,8 @@ include $(GBUILDDIR)/Deliver.mk $(eval $(call gb_Deliver_init)) +include $(SOLARENV)/inc/minor.mk + # We are using a set of scopes that we might as well call classes. # It is important to include them in the right order as that is @@ -231,9 +233,11 @@ include $(foreach class, \ CustomTarget \ PrecompiledHeaders \ CppunitTest \ + Jar \ JavaClassSet \ JunitTest \ Module \ + Zip \ ,$(GBUILDDIR)/$(class).mk) # optional extensions that should never be essential |