[PATCH] gbuild: add Package equiv. for copying whole dirs

David Tardon (via Code Review) gerrit at gerrit.libreoffice.org
Sat May 4 06:25:12 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3774

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/74/3774/1

gbuild: add Package equiv. for copying whole dirs

This is in preparation for using doxygen to generate IDL docs. Because
the file names generated by doxygen are essentially random, it is not
possible to use a Package to deliver them. And we really do not want to
go back to using Zip, as unpacking slows the installation down.

Change-Id: I5f4aa6bf10c6aab30a5b1870e04dca723c123317
---
M Makefile.in
M instsetoo_native/util/openoffice.lst.in
A solenv/gbuild/GeneratedPackage.mk
M solenv/gbuild/TargetLocations.mk
M solenv/gbuild/gbuild.mk
5 files changed, 119 insertions(+), 4 deletions(-)



diff --git a/Makefile.in b/Makefile.in
index 892a369..74b53aa 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -108,6 +108,7 @@
 	Extension \
 	ExternalPackage \
 	ExternalProject \
+	GeneratedPackage \
 	InstallModule \
 	InstallScript \
 	InternalUnoApi \
diff --git a/instsetoo_native/util/openoffice.lst.in b/instsetoo_native/util/openoffice.lst.in
index ffef5c7..52e9c2a 100644
--- a/instsetoo_native/util/openoffice.lst.in
+++ b/instsetoo_native/util/openoffice.lst.in
@@ -82,7 +82,7 @@
         downloadname    LibreOffice_{productversion}_{os}_install_{languages}
         langpackdownloadname    LibreOffice_{productversion}_languagepack_{os}_install_{languages}
         helppackdownloadname    LibreOffice_{productversion}_helppack_{os}_install_{languages}
-        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin,{solarpath}/bin.{minor}/ooowoure,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external,{filelistpath}/PackageSet,{filelistpath}/Package
+        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin,{solarpath}/bin.{minor}/ooowoure,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external,{filelistpath}/PackageSet,{filelistpath}/Package,{filelistpath}/GeneratedPackage
     }
 }
 
@@ -138,7 +138,7 @@
         downloadname    LibreOfficeDev_{productversion}_{os}_install_{languages}
         langpackdownloadname    LibreOfficeDev_{productversion}_languagepack_{os}_install_{languages}
         helppackdownloadname    LibreOfficeDev_{productversion}_helppack_{os}_install_{languages}
-        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin/dev,{localpath}/bin,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice_dev,{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external,{filelistpath}/PackageSet,{filelistpath}/Package
+        include         {solarenvpath}/{os}/loader2,.,{localpath}/bin/dev,{localpath}/bin,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor}/desktop-integration/{pkgtype},{solarpath}/bin.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor}/openoffice_dev,{solarpath}/pck.{minor}/openoffice,{solarpath}/pck.{minor},{solarpath}/xml.{minor}/office/instance,{solarpath}/xml.{minor},../../external/common,{solarenvpath}/{os}/OOo_external,{filelistpath}/PackageSet,{filelistpath}/Package,{filelistpath}/GeneratedPackage
     }
 }
 
@@ -177,7 +177,7 @@
         active 1
         compression 5
         script sdkoo
-        include {solarenvpath}/{os}/loader2,{solarpath}/bin.{minor}/sdkoo,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor},{solarpath}/filelists.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor},{solarenvpath}/{os}/MS,{filelistpath}/PackageSet,{filelistpath}/Package
+        include {solarenvpath}/{os}/loader2,{solarpath}/bin.{minor}/sdkoo,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor},{solarpath}/filelists.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor},{solarenvpath}/{os}/MS,{filelistpath}/PackageSet,{filelistpath}/Package,{filelistpath}/GeneratedPackage
     }
 }
 
@@ -223,7 +223,7 @@
         active 1
         compression 5
         script sdkoo
-        include {solarenvpath}/{os}/loader2,{solarpath}/bin.{minor}/sdkoo,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor},{solarpath}/filelists.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor},{solarenvpath}/{os}/MS,{filelistpath}/PackageSet,{filelistpath}/Package
+        include {solarenvpath}/{os}/loader2,{solarpath}/bin.{minor}/sdkoo,{solarpath}/bin.{minor}/osl,{solarpath}/bin.{minor},{solarpath}/filelists.{minor},{solarpath}/lib.{minor},{solarpath}/pck.{minor},{solarenvpath}/{os}/MS,{filelistpath}/PackageSet,{filelistpath}/Package,{filelistpath}/GeneratedPackage
     }
 }
 
diff --git a/solenv/gbuild/GeneratedPackage.mk b/solenv/gbuild/GeneratedPackage.mk
new file mode 100644
index 0000000..91714e9
--- /dev/null
+++ b/solenv/gbuild/GeneratedPackage.mk
@@ -0,0 +1,111 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+# class GeneratedPackage
+
+# Enables to deliver whole directories (of generated files) to $(INSTDIR).
+#
+# GeneratedPackage shall be used as a substitution for Package when the
+# names of the produced files are not known in advance (in older times,
+# we used Zip in these places). It shall only be used to deliver files
+# for installation.
+#
+# If you know the filenames in advance, use Package. Laziness is not an
+# excuse.
+
+gb_GeneratedPackage__get_srcdir = $(lastword $(subst :, ,$(1)))
+gb_GeneratedPackage__get_destdir = $(firstword $(subst :, ,$(1)))
+
+define gb_GeneratedPackage__command_cp
+mkdir -p $(dir $(INSTDIR)/$(2)) && \
+cp -r $(PACKAGE_SOURCEDIR)/$(1) $(INSTDIR)/$(2)
+endef
+
+define gb_GeneratedPackage__command
+$(call gb_Output_announce,$(2),$(true),GPK,2)
+$(call gb_Helper_abbreviate_dirs,\
+	rm -rf $(addprefix $(INSTDIR)/,$(foreach pair,$(PACKAGE_DIRS),$(call gb_GeneratedPackage__get_destdir,$(pair)))) && \
+	$(foreach pair,$(PACKAGE_DIRS),\
+		$(call gb_GeneratedPackage__command_cp,$(call gb_GeneratedPackage__get_srcdir,$(pair)),$(call gb_GeneratedPackage__get_destdir,$(pair))) &&) \
+	find \
+		$(addprefix $(INSTDIR)/,$(foreach pair,$(PACKAGE_DIRS),$(call gb_GeneratedPackage__get_destdir,$(pair)))) \
+		\( -type f -o -type l \) -print \
+		> $(1) \
+)
+endef
+
+define gb_GeneratedPackage__check_dirs
+$(if $(PACKAGE_DIRS),,$(call gb_Ouput_error,no dirs were added))
+$(foreach pair,$(PACKAGE_DIRS),\
+	$(if $(wildcard $(PACKAGE_SOURCEDIR)/$(call gb_GeneratedPackage__get_srcdir,$(pair))),,\
+		$(call gb_Output_error,source dir $(call gb_GeneratedPackage__get_srcdir,$(pair)) does not exist) \
+	) \
+)
+
+endef
+
+$(dir $(call gb_GeneratedPackage_get_target,%)).dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(dir $(call gb_GeneratedPackage_get_target,%))%.dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(call gb_GeneratedPackage_get_target,%) :
+	$(call gb_GeneratedPackage__check_dirs,$*)
+	$(call gb_GeneratedPackage__command,$@,$*)
+
+.PHONY : $(call gb_GeneratedPackage_get_clean_target,%)
+$(call gb_GeneratedPackage_get_clean_target,%) :
+	$(call gb_Output_announce,$*,$(false),GPK,2)
+	rm -rf $(call gb_GeneratedPackage_get_target,$*) $(addprefix $(INSTDIR)/,$(PACKAGE_DIRS))
+
+# Create a generated package.
+#
+# gb_GeneratedPackage_GeneratedPackage package srcdir
+define gb_GeneratedPackage_GeneratedPackage
+$(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_DIRS :=
+$(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_SOURCEDIR := $(2)
+$(call gb_GeneratedPackage_get_clean_target,$(1)) : PACKAGE_DIRS :=
+
+$(call gb_GeneratedPackage_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
+$(call gb_GeneratedPackage_get_target,$(1)) :| $(dir $(call gb_GeneratedPackage_get_target,$(1))).dir
+
+$$(eval $$(call gb_Module_register_target,$(call gb_GeneratedPackage_get_target,$(1)),$(call gb_GeneratedPackage_get_clean_target,$(1))))
+$(call gb_Helper_make_userfriendly_targets,$(1),GeneratedPackage)
+
+endef
+
+# Depend on a custom target.
+#
+# gb_GeneratedPackage_use_customtarget package custom-target
+define gb_GeneratedPackage_use_customtarget
+$(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_CustomTarget_get_target,$(2))
+
+endef
+
+# Depend on an unpacked tarball.
+#
+# gb_GeneratedPackage_use_unpacked package unpacked
+define gb_GeneratedPackage_use_unpacked
+$(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_UnpackedTarball_get_target,$(2))
+
+endef
+
+# Add a dir to the package.
+#
+# The srcdir will be copied to $(INSTDIR) as destdir.
+#
+# gb_GeneratedPackage_add_dir package destdir srcdir
+define gb_GeneratedPackage_add_dir
+$(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_DIRS += $(strip $(2)):$(strip $(3))
+$(call gb_GeneratedPackage_get_clean_target,$(1)) : PACKAGE_DIRS += $(2)
+
+endef
+
+# vim: set noet sw=4 ts=4:
diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index 727e582..a66e11e 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -117,6 +117,7 @@
 gb_ExternalProject_get_preparation_target = $(WORKDIR)/ExternalProject/$(1).prepare
 gb_ExternalProject_get_state_target = $(WORKDIR)/ExternalProject/$(1)/$(2)
 gb_ExternalProject_get_target = $(WORKDIR)/ExternalProject/$(1).done
+gb_GeneratedPackage_get_target = $(WORKDIR)/GeneratedPackage/$(1).filelist
 gb_HelpIndexTarget_get_target = $(WORKDIR)/HelpIndexTarget/$(1).done
 gb_HelpJarTarget_get_target = $(WORKDIR)/HelpJarTarget/$(1).done
 gb_HelpLinkTarget_get_preparation_target = $(WORKDIR)/HelpLinkTarget/$(1).prepare
@@ -269,6 +270,7 @@
 	Dictionary \
 	ExternalPackage \
 	ExtensionTarget \
+	GeneratedPackage \
 	HelpTarget \
 	HelpIndexTarget \
 	HelpJarTarget \
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 50bba72..a72591a 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -346,6 +346,7 @@
 	AutoInstallLibs \
 	Postprocess \
 	PackageSet \
+	GeneratedPackage \
 ,$(GBUILDDIR)/$(class).mk)
 
 $(eval $(call gb_Helper_process_executable_registrations))

-- 
To view, visit https://gerrit.libreoffice.org/3774
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f4aa6bf10c6aab30a5b1870e04dca723c123317
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: David Tardon <dtardon at redhat.com>



More information about the LibreOffice mailing list