From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- solenv/qa/python/gbuildtojson.py | 157 +++++++++++++++++++++ .../selftest/Executable_gbuildselftestexe.mk | 16 +++ .../qa/python/selftest/Library_gbuildselftest.mk | 37 +++++ .../python/selftest/Library_gbuildselftestdep.mk | 15 ++ solenv/qa/python/selftest/Makefile | 21 +++ solenv/qa/python/selftest/Module_selftest.mk | 18 +++ solenv/qa/python/selftest/selftestdepobject.cxx | 0 solenv/qa/python/selftest/selftestexeobject.cxx | 1 + solenv/qa/python/selftest/selftestobject.cxx | 0 9 files changed, 265 insertions(+) create mode 100644 solenv/qa/python/gbuildtojson.py create mode 100644 solenv/qa/python/selftest/Executable_gbuildselftestexe.mk create mode 100644 solenv/qa/python/selftest/Library_gbuildselftest.mk create mode 100644 solenv/qa/python/selftest/Library_gbuildselftestdep.mk create mode 100644 solenv/qa/python/selftest/Makefile create mode 100644 solenv/qa/python/selftest/Module_selftest.mk create mode 100644 solenv/qa/python/selftest/selftestdepobject.cxx create mode 100644 solenv/qa/python/selftest/selftestexeobject.cxx create mode 100644 solenv/qa/python/selftest/selftestobject.cxx (limited to 'solenv/qa/python') diff --git a/solenv/qa/python/gbuildtojson.py b/solenv/qa/python/gbuildtojson.py new file mode 100644 index 000000000..b54c901e9 --- /dev/null +++ b/solenv/qa/python/gbuildtojson.py @@ -0,0 +1,157 @@ +# -*- 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/. + +''' + +import subprocess +import unittest +import json +import os +import os.path +import tempfile +import shutil + + +# these contortions seem unavoidable for windows +def getgbuildtesttools(testcase): + with open(os.path.join(os.environ['WORKDIR'], 'CustomTarget', 'solenv', 'gbuildtesttools.done'), 'r') as f: + gbuildtesttools = json.load(f) + testcase.make = gbuildtesttools['MAKE'] + testcase.bash = gbuildtesttools['BASH'] + testcase.gbuildtojson = gbuildtesttools['GBUILDTOJSON'] + +makeenvvars = ['MAKEOVERRIDES', 'MAKEFLAGS', 'MAKE_TERMERR', 'MAKE_TERMOUT', 'MAKELEVEL', 'MFLAGS', 'GBUILD_TRACE'] +def clearmakevars(): + if 'LD_LIBRARY_PATH' in os.environ: + os.environ['GBUILDTOJSON_LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + del(os.environ['LD_LIBRARY_PATH']) # built with ASAN; prevent that + for makeenvvar in makeenvvars: + if makeenvvar in os.environ: + del os.environ[makeenvvar] + + +class CheckGbuildToJson(unittest.TestCase): + def setUp(self): + getgbuildtesttools(self) + clearmakevars() + self.tempwork = tempfile.mkdtemp(prefix='gbuild') + + def tearDown(self): + shutil.rmtree(self.tempwork) + + def test_gbuildtojson(self): + os.makedirs(os.path.join(self.tempwork, 'LinkTarget', 'Executable')) + shutil.copy(self.gbuildtojson, os.path.join(self.tempwork, 'LinkTarget', 'Executable')) + (bashscripthandle, bashscriptname) = tempfile.mkstemp('gbuild') + bashscript = os.fdopen(bashscripthandle, 'w', newline='\n') + bashscript.write("set -e\n") + bashscript.write("cd %s/solenv/qa/python/selftest\n" % os.environ['SRCDIR']) + bashscript.write("%s gbuildtojson WORKDIR=%s\n" % (self.make, self.tempwork.replace('\\', '/'))) + bashscript.close() + subprocess.check_call([self.bash, bashscriptname.replace('\\', '/')]) + os.remove(bashscriptname) + jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToJson', 'Library')) + gbuildlibs = [] + for jsonfilename in jsonfiles: + with open(os.path.join(self.tempwork, 'GbuildToJson', 'Library', jsonfilename), 'r') as f: + gbuildlibs.append(json.load(f)) + foundlibs = set() + for lib in gbuildlibs: + self.assertEqual(set(lib.keys()), set(['MAKEFILE', 'ASMOBJECTS', 'CFLAGS', 'CFLAGSAPPEND', 'COBJECTS', 'CXXCLRFLAGS', 'CXXCLRFLAGSAPPEND', 'CXXCLROBJECTS', 'CXXFLAGS', 'CXXFLAGSAPPEND', 'CXXOBJECTS', 'DEFS', 'LEXOBJECTS', 'GENCOBJECTS', 'GENCXXOBJECTS', 'GENCXXCLROBJECTS', 'ILIBTARGET', 'INCLUDE', 'JAVAOBJECTS', 'LINKED_LIBS', 'LINKED_STATIC_LIBS', 'LINKTARGET', 'OBJCFLAGS', 'OBJCFLAGSAPPEND', 'OBJCOBJECTS', 'OBJCXXFLAGS', 'OBJCXXFLAGSAPPEND', 'OBJCXXOBJECTS', 'PYTHONOBJECTS', 'YACCOBJECTS'])) + if lib['LINKTARGET'].find('gbuildselftestdep') != -1: + foundlibs.add('gbuildselftestdep') + elif lib['LINKTARGET'].find('gbuildselftest') != -1: + foundlibs.add('gbuildselftest') + self.assertIn('-Igbuildtojsontestinclude', lib['INCLUDE'].split()) + self.assertIn('gbuildselftestdep', lib['LINKED_LIBS'].split()) + self.assertIn('solenv/qa/python/selftest/selftestobject', lib['CXXOBJECTS'].split()) + self.assertIn('-DGBUILDSELFTESTDEF', lib['DEFS'].split()) + self.assertIn('-DGBUILDSELFTESTCXXFLAG', lib['CXXFLAGSAPPEND'].split()) + self.assertIn('-DGBUILDSELFTESTCFLAG', lib['CFLAGSAPPEND'].split()) + else: + self.assertTrue(False) + self.assertEqual(foundlibs, set(['gbuildselftest', 'gbuildselftestdep'])) + self.assertEqual(len(foundlibs), 2) + jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToJson', 'Executable')) + gbuildexes = [] + for jsonfilename in jsonfiles: + with open(os.path.join(self.tempwork, 'GbuildToJson', 'Executable', jsonfilename), 'r') as f: + gbuildexes.append(json.load(f)) + foundexes = set() + for exe in gbuildexes: + if exe['LINKTARGET'].find('gbuildselftestexe') != -1: + foundexes.add('gbuildselftestexe') + else: + self.assertTrue(False) + self.assertEqual(foundexes, set(['gbuildselftestexe'])) + self.assertEqual(len(foundexes), 1) + +class CheckGbuildToJsonModules(unittest.TestCase): + def setUp(self): + getgbuildtesttools(self) + clearmakevars() + self.tempwork = tempfile.mkdtemp(prefix='gbuild') + self.tempsrc = tempfile.mkdtemp(prefix='gbuild') + self.srcdir = os.environ['SRCDIR'] + self.builddir = os.environ['BUILDDIR'] + if os.environ['OS'] == 'WNT': + self.tempworkmixed = self.tempwork.replace('\\','/') + self.tempsrcmixed = self.tempsrc.replace('\\','/') + self.srcdirnative = self.srcdir.replace('/','\\') + self.builddirnative = self.builddir.replace('/','\\') + else: + self.tempworkmixed = self.tempwork + self.tempsrcmixed = self.tempsrc + self.srcdirnative = self.srcdir + self.builddirnative = self.builddir + shutil.copyfile(os.path.join(self.builddirnative, 'config_host.mk'), os.path.join(self.tempsrc, 'config_host.mk')) + shutil.copyfile(os.path.join(self.builddirnative, 'config_host_lang.mk'), os.path.join(self.tempsrc, 'config_host_lang.mk')) + shutil.copytree(os.path.join(self.builddirnative, 'config_host'), os.path.join(self.tempsrc, 'config_host')) + shutil.copyfile(os.path.join(self.srcdirnative, 'Repository.mk'), os.path.join(self.tempsrc, 'Repository.mk')) + shutil.copyfile(os.path.join(self.srcdirnative, 'RepositoryExternal.mk'), os.path.join(self.tempsrc, 'RepositoryExternal.mk')) + shutil.copyfile(os.path.join(self.srcdirnative, 'RepositoryFixes.mk'), os.path.join(self.tempsrc, 'RepositoryFixes.mk')) + #print('copytree from _%s_ to _%s_' % (os.path.join(self.srcdirnative, 'solenv').replace('\\', '#').replace('/', '!'), os.path.join(self.tempsrc, 'solenv').replace('\\', '#').replace('/', '!'))) + shutil.copytree(os.path.join(self.srcdirnative, 'solenv'), os.path.join(self.tempsrc, 'solenv')) + shutil.copytree(os.path.join(self.srcdirnative, 'pch'), os.path.join(self.tempsrc, 'pch')) + + def tearDown(self): + shutil.rmtree(self.tempsrc) + shutil.rmtree(self.tempwork) + + def test_gbuildtojson(self): + modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'emfio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity'] + if os.environ['OS'] == 'WNT': + # for now, use a limited subset for testing on windows as it is so annoyingly slow on this + modules = ['chart2', 'cui', 'dbaccess', 'framework', 'oox', 'sfx2', 'svl', 'svtools', 'svx', 'toolkit', 'vcl', 'xmloff'] + for module in modules: + shutil.rmtree(self.tempwork) + os.makedirs(os.path.join(self.tempwork, 'LinkTarget', 'Executable')) + shutil.copy(self.gbuildtojson, os.path.join(self.tempwork, 'LinkTarget', 'Executable')) + if module != 'solenv': + shutil.copytree(os.path.join(os.environ['SRCDIR'], module), os.path.join(self.tempsrc, module), + ignore=shutil.ignore_patterns('.#*', '#*', '*~')) + # ignore Emacs lock (.#*), auto-save (#*), and backup (*~) files + (bashscripthandle, bashscriptname) = tempfile.mkstemp(prefix='gbuild') + bashscript = os.fdopen(bashscripthandle, 'w', newline='\n') + bashscript.write("set -e\n") + bashscript.write("cd %s/%s\n" % (self.tempsrc.replace('\\','/'), module)) + bashscript.write("%s gbuildtojson WORKDIR=%s SRCDIR=%s\n" % (self.make, self.tempwork.replace('\\', '/'), self.tempsrc.replace('\\','/'))) + bashscript.close() + subprocess.check_call([self.bash, bashscriptname.replace('\\', '/')]) + os.remove(bashscriptname) + jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToJson', 'Library')) + gbuildlibs = [] + for jsonfilename in jsonfiles: + with open(os.path.join(self.tempwork, 'GbuildToJson', 'Library', jsonfilename), 'r') as f: + gbuildlibs.append(json.load(f)) + + +if __name__ == "__main__": + unittest.main() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/solenv/qa/python/selftest/Executable_gbuildselftestexe.mk b/solenv/qa/python/selftest/Executable_gbuildselftestexe.mk new file mode 100644 index 000000000..c43a77190 --- /dev/null +++ b/solenv/qa/python/selftest/Executable_gbuildselftestexe.mk @@ -0,0 +1,16 @@ +# -*- 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/. +# + +$(eval $(call gb_Executable_Executable,gbuildselftestexe)) + +$(eval $(call gb_Executable_add_exception_objects,gbuildselftestexe,\ + solenv/qa/python/selftest/selftestexeobject \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/solenv/qa/python/selftest/Library_gbuildselftest.mk b/solenv/qa/python/selftest/Library_gbuildselftest.mk new file mode 100644 index 000000000..bed015c09 --- /dev/null +++ b/solenv/qa/python/selftest/Library_gbuildselftest.mk @@ -0,0 +1,37 @@ +# -*- 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/. +# + +$(eval $(call gb_Library_Library,gbuildselftest)) + +$(eval $(call gb_Library_set_include,gbuildselftest,\ + -Igbuildtojsontestinclude\ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_add_defs,gbuildselftest,\ + -DGBUILDSELFTESTDEF \ +)) + +$(eval $(call gb_Library_add_cxxflags,gbuildselftest,\ + -DGBUILDSELFTESTCXXFLAG \ +)) + +$(eval $(call gb_Library_add_cflags,gbuildselftest,\ + -DGBUILDSELFTESTCFLAG \ +)) + +$(eval $(call gb_Library_use_libraries,gbuildselftest,\ + gbuildselftestdep \ +)) + +$(eval $(call gb_Library_add_exception_objects,gbuildselftest,\ + solenv/qa/python/selftest/selftestobject \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/solenv/qa/python/selftest/Library_gbuildselftestdep.mk b/solenv/qa/python/selftest/Library_gbuildselftestdep.mk new file mode 100644 index 000000000..b28450c48 --- /dev/null +++ b/solenv/qa/python/selftest/Library_gbuildselftestdep.mk @@ -0,0 +1,15 @@ +# -*- 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/. +# + +$(eval $(call gb_Library_Library,gbuildselftestdep)) + +$(eval $(call gb_Library_add_exception_objects,gbuildselftestdep,\ + solenv/qa/python/selftest/selftestdepobject \ +)) +# vim: set noet sw=4 ts=4: diff --git a/solenv/qa/python/selftest/Makefile b/solenv/qa/python/selftest/Makefile new file mode 100644 index 000000000..3566a727b --- /dev/null +++ b/solenv/qa/python/selftest/Makefile @@ -0,0 +1,21 @@ +# -*- 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/. +# + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +ifeq (,$(BUILDDIR)) +gb_partial_build__makefile_dir=$(dir $(abspath $(firstword $(MAKEFILE_LIST)))) +BUILDDIR := $(gb_partial_build__makefile_dir)../../../.. +endif + +gb_GBUILDSELFTEST=t + +include $(module_directory)/../../../gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/solenv/qa/python/selftest/Module_selftest.mk b/solenv/qa/python/selftest/Module_selftest.mk new file mode 100644 index 000000000..37c53fdbf --- /dev/null +++ b/solenv/qa/python/selftest/Module_selftest.mk @@ -0,0 +1,18 @@ +# -*- 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/. +# + +$(eval $(call gb_Module_Module,gbuildtojsontest)) + +$(eval $(call gb_Module_add_targets,gbuildtojsontest,\ + Library_gbuildselftestdep \ + Library_gbuildselftest \ + Executable_gbuildselftestexe \ +)) + +# vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/solenv/qa/python/selftest/selftestdepobject.cxx b/solenv/qa/python/selftest/selftestdepobject.cxx new file mode 100644 index 000000000..e69de29bb diff --git a/solenv/qa/python/selftest/selftestexeobject.cxx b/solenv/qa/python/selftest/selftestexeobject.cxx new file mode 100644 index 000000000..78f2de106 --- /dev/null +++ b/solenv/qa/python/selftest/selftestexeobject.cxx @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/solenv/qa/python/selftest/selftestobject.cxx b/solenv/qa/python/selftest/selftestobject.cxx new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3