summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-02-17 16:33:19 +0100
committerMichael Stahl <mstahl@redhat.com>2016-02-18 10:28:09 +0000
commite2884ab9c17b797f39833bf0381bd2fa1b5ea205 (patch)
treee745708d501f6272a9a7203305cbe8807e834d40 /solenv
parent775d93d0c0dc902dab6e3bdb978501b5d6295f8b (diff)
gbuild: AutoInstall: rewrite scp2 file generation in Python
Much more readable. Change-Id: I87c696e3f2f17a98c83eab9ed8149b79902be0fe Reviewed-on: https://gerrit.libreoffice.org/22431 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: David Ostrovsky <david@ostrovsky.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'solenv')
-rw-r--r--solenv/gbuild/AutoInstall.mk94
-rw-r--r--solenv/gbuild/gen-autoinstall.py81
2 files changed, 105 insertions, 70 deletions
diff --git a/solenv/gbuild/AutoInstall.mk b/solenv/gbuild/AutoInstall.mk
index 1fa2d38f05c1..5bf4d985b5cd 100644
--- a/solenv/gbuild/AutoInstall.mk
+++ b/solenv/gbuild/AutoInstall.mk
@@ -9,82 +9,36 @@
# AutoInstall class
-# this is pretty horrible because
-# a) make sucks
-# b) this is an abuse of make anyway
-# c) make 4.0 has $(file) but Apple prefers to ship 10 year old version instead
-# d) Win32 make has an 8k command line lengh limit so needs to use $(file)
-# maybe generation should be moved to some python script or something
-
-define gb_AutoInstall__escape
-$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
-endef
-
-define gb_AutoInstall__make_define
-echo "#define auto_$*_ALL \ " >> $@
-$(foreach binary,$(filter-out $(lastword $(1)),$(1)),echo " $(call gb_AutoInstall__escape,$(binary)), \ " >> $@;)
-echo " $(call gb_AutoInstall__escape,$(lastword $(1)))" >> $@;
-echo "" >> $@
-endef
-
-define gb_AutoInstall__gen_define
-$(file >>$@,#define auto_$*_ALL \)
-$(foreach binary,$(filter-out $(lastword $(1)),$(1)),$(file >>$@,\
- $(call gb_AutoInstall__escape,$(binary)), \))
-$(file >>$@,\
- $(call gb_AutoInstall__escape,$(lastword $(1))))
-
-endef
-
-define gb_AutoInstall__gen_lib
-$(SCP2LIBTEMPLATE)(auto_$*_lib_$(call gb_AutoInstall__escape,$(1)),$(call gb_Library_get_runtime_filename,$(1))$(if $(SCP2COMPONENTCONDITION),$(COMMA)$(SCP2COMPONENTCONDITION)))
-
-endef
-
-define gb_AutoInstall__gen_pkg
-PACKAGE_FILELIST(auto_$*_pkg_$(call gb_AutoInstall__escape,$(1)),$(1).filelist)
-
-endef
-
$(dir $(call gb_AutoInstall_get_target,%)).dir :
$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
$(call gb_AutoInstall_get_target,%) : $(GBUILDDIR)/AutoInstall.mk \
$(SRCDIR)/Repository.mk $(SRCDIR)/RepositoryExternal.mk \
- $(BUILDDIR)/config_host.mk
+ $(BUILDDIR)/config_host.mk \
+ $(call gb_ExternalExecutable_get_dependencies,python)
$(call gb_Output_announce,$*,$(true),AIN,3)
-ifeq ($(HAVE_GNUMAKE_FILE_FUNC),)
- echo "/* autogenerated installs for group $* */" > $@
- $(call gb_AutoInstall__make_define,\
- $(foreach lib,$(gb_Library_MODULE_$*),auto_$*_lib_$(lib)) \
- $(foreach lib,$(gb_SdkLinkLibrary_MODULE_$*),auto_$*_link_$(lib)) \
- $(foreach exe,$(gb_Executable_MODULE_$*),auto_$*_exe_$(exe)) \
- $(foreach jar,$(gb_Jar_MODULE_$*),auto_$*_jar_$(jar)) \
- $(foreach pkg,$(gb_Package_MODULE_$*),auto_$*_pkg_$(pkg)))
- $(foreach lib,$(gb_Library_MODULE_$*),\
- echo '$(SCP2LIBTEMPLATE)(auto_$*_lib_$(call gb_AutoInstall__escape,$(lib)),$(call gb_Library_get_runtime_filename,$(lib))$(if $(SCP2COMPONENTCONDITION),$(COMMA)$(SCP2COMPONENTCONDITION)))' >> $@;)
-else
- $(file >$@,/* autogenerated installs for group $* */)
- $(call gb_AutoInstall__gen_define,\
- $(foreach lib,$(gb_Library_MODULE_$*),auto_$*_lib_$(lib)) \
- $(foreach lib,$(gb_SdkLinkLibrary_MODULE_$*),auto_$*_link_$(lib)) \
- $(foreach exe,$(gb_Executable_MODULE_$*),auto_$*_exe_$(exe)) \
- $(foreach jar,$(gb_Jar_MODULE_$*),auto_$*_jar_$(jar)) \
- $(foreach pkg,$(gb_Package_MODULE_$*),auto_$*_pkg_$(pkg)))
- $(file >>$@,$(foreach lib,$(gb_Library_MODULE_$*),$(call gb_AutoInstall__gen_lib,$(lib))))
-endif
- $(foreach lib,$(gb_SdkLinkLibrary_MODULE_$*),\
- echo 'SDK_LIBRARY_LINK(auto_$*_link_$(lib),$(notdir $(call gb_Library_get_sdk_link_lib,$(lib))),../../program/$(call gb_Library_get_runtime_filename,$(lib)))' >> $@;)
- $(foreach exe,$(gb_Executable_MODULE_$*),\
- echo "$(SCP2EXETEMPLATE)(auto_$*_exe_$(call gb_AutoInstall__escape,$(exe)),$(call gb_Executable_get_filename,$(exe))$(if $(SCP2COMPONENTCONDITION),$(COMMA)$(SCP2COMPONENTCONDITION)))" >> $@;)
- $(foreach jar,$(gb_Jar_MODULE_$*),\
- echo '$(SCP2JARTEMPLATE)(auto_$*_jar_$(call gb_AutoInstall__escape,$(jar)),$(jar).jar)' >> $@;)
-ifeq ($(HAVE_GNUMAKE_FILE_FUNC),)
- $(foreach pkg,$(gb_Package_MODULE_$*),\
- echo 'PACKAGE_FILELIST(auto_$*_pkg_$(call gb_AutoInstall__escape,$(pkg)),$(pkg).filelist)' >> $@;)
-else
- $(file >>$@,$(foreach pkg,$(gb_Package_MODULE_$*),$(call gb_AutoInstall__gen_pkg,$(pkg))))
-endif
+ SDKLIBFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
+ $(foreach lib,$(gb_SdkLinkLibrary_MODULE_$*),\
+ $(lib) \
+ $(notdir $(call gb_Library_get_sdk_link_lib,$(lib))) \
+ ../../program/$(call gb_Library_get_runtime_filename,$(lib)))) \
+ && LIBFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
+ $(foreach lib,$(gb_Library_MODULE_$*),\
+ $(lib) \
+ $(call gb_Library_get_runtime_filename,$(lib)))) \
+ && EXEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
+ $(foreach exe,$(gb_Executable_MODULE_$*),\
+ $(exe) \
+ $(call gb_Executable_get_filename,$(exe)))) \
+ && JARFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(gb_Jar_MODULE_$*)) \
+ && PKGFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(gb_Package_MODULE_$*)) \
+ && $(call gb_ExternalExecutable_get_command,python) \
+ $(GBUILDDIR)/gen-autoinstall.py \
+ '$*' '$(SCP2COMPONENTCONDITION)' \
+ '$(SCP2LIBTEMPLATE)' '$(SCP2EXETEMPLATE)' '$(SCP2JARTEMPLATE)' \
+ $${SDKLIBFILE} $${LIBFILE} $${EXEFILE} $${JARFILE} $${PKGFILE} \
+ > $@ \
+ && rm -f $${SDKLIBFILE} $${LIBFILE} $${EXEFILE} $${JARFILE} $${PKGFILE}
$(call gb_AutoInstall_get_clean_target,%) :
diff --git a/solenv/gbuild/gen-autoinstall.py b/solenv/gbuild/gen-autoinstall.py
new file mode 100644
index 000000000000..6c0e4ad16074
--- /dev/null
+++ b/solenv/gbuild/gen-autoinstall.py
@@ -0,0 +1,81 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+
+# generate AutoInstall files from gbuild data for further scp2 processing
+
+from __future__ import print_function
+
+import sys
+
+module = sys.argv[1]
+scp2componentcondition = sys.argv[2]
+scp2libtemplate = sys.argv[3]
+scp2exetemplate = sys.argv[4]
+scp2jartemplate = sys.argv[5]
+sdklibs = open(sys.argv[6]).readline().split()
+libs = open(sys.argv[7]).readline().split()
+exes = open(sys.argv[8]).readline().split()
+jars = open(sys.argv[9]).readline().split()
+pkgs = open(sys.argv[10]).readline().split()
+
+if len(scp2componentcondition) > 0:
+ scp2componentcondition = "," + scp2componentcondition
+
+def escape(string):
+ return string.replace(".", "_").replace("-", "_").replace("/", "_")
+
+def to_tuple(l):
+ ret = []
+ i = 0
+ while i < len(l):
+ ret.append((l[i], l[i+1]))
+ i += 2
+ return ret
+
+def to_triple(l):
+ ret = []
+ i = 0
+ while i < len(l):
+ ret.append((l[i], l[i+1], l[i+2]))
+ i += 3
+ return ret
+
+print("/* autogenerated installs for group " + module + " */")
+print("#define auto_" + module + "_ALL \\")
+
+autosdklibs = [("auto_" + module + "_link_" + escape(lib),link,target) for (lib,link,target) in to_triple(sdklibs)]
+autolibs = [("auto_" + module + "_lib_" + escape(lib),libfile) for (lib,libfile) in to_tuple(libs)]
+autoexes = [("auto_" + module + "_exe_" + escape(exe),exefile) for (exe,exefile) in to_tuple(exes)]
+autojars = [("auto_" + module + "_jar_" + escape(jar),jar + ".jar") for jar in jars]
+autopkgs = [("auto_" + module + "_pkg_" + escape(pkg),pkg + ".filelist") for pkg in pkgs]
+
+allgids = [gid for (gid,_,_) in autosdklibs] + \
+ [gid for (gid,_) in autolibs] + \
+ [gid for (gid,_) in autoexes] + \
+ [gid for (gid,_) in autojars] + \
+ [gid for (gid,_) in autopkgs]
+
+print(", \\\n".join([" " + gid for gid in allgids]))
+
+for (gid, link, target) in autosdklibs:
+ print("SDK_LIBRARY_LINK(" + gid + "," + link + "," + target + ")")
+
+for (gid, libfile) in autolibs:
+ print(scp2libtemplate + "(" + gid + "," + libfile + scp2componentcondition + ")")
+
+for (gid, exefile) in autoexes:
+ print(scp2exetemplate + "(" + gid + "," + exefile + scp2componentcondition + ")")
+
+for (gid, jarfile) in autojars:
+ print(scp2jartemplate + "(" + gid + "," + jarfile + scp2componentcondition + ")")
+
+for (gid, pkgfilelist) in autopkgs:
+ print("PACKAGE_FILELIST(" + gid + "," + pkgfilelist + scp2componentcondition + ")")
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: