You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2020/07/04 18:44:07 UTC

[openoffice] 04/11: Cleanup.

This is an automated email from the ASF dual-hosted git repository.

damjan pushed a commit to branch scons-build
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit d7acc04481468e996150fc632d86032cf930ad2b
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Mon Jun 29 08:19:01 2020 +0200

    Cleanup.
    
    Patch by: me
---
 main/site_scons/AllLangRes.py | 74 +++++++++++++++++++++----------------------
 main/uui/SConscript           |  6 ++--
 2 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/main/site_scons/AllLangRes.py b/main/site_scons/AllLangRes.py
index 81a8fc4..6ed9b78 100644
--- a/main/site_scons/AllLangRes.py
+++ b/main/site_scons/AllLangRes.py
@@ -111,60 +111,61 @@ class ResTarget:
             imageList.append('-lip=' + abspath)
 
 
-def build_srs(target, source, env):
-    # Concatenates the sources into the target.
-    # shutil.copyfileobj() was benchmarked as being the fastest:
-    # https://stackoverflow.com/questions/13613336/python-concatenate-text-files
-    with open(target[0].abspath, 'wb') as outfd:
-        for f in source:
-            with open(f.abspath, 'rb') as infd:
-                shutil.copyfileobj(infd, outfd)
-    return 0
-
 class SrsTarget:
-    def __init__(self, srsPath):
+    def __init__(self, srsPath, srcFiles):
         self.env = DefaultEnvironment().Clone()
         self.env.Append(ENV=platform.getExecutableEnvironment(soenv))
+
         # This will come apart at the seams if it finds a .src file
         # with UTF-8 BOM but non-UTF-8 contents, like we produce with transex3.
         # So use a different filename extension for those.
         self.env.Append(SCANNERS=ClassicCPP("AOOSRCScanner", '.src', "CPPPATH", '^[ \t]*#[ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'))
         self.srsPath = srsPath
 
-    def SetInclude(self, includes):
-        self.env.Replace(CPPPATH=includes)
+        self.parts = []
+        partTargets = []
+        for srcFile in srcFiles:
+            srsPartTarget = SrsPartTarget(self.env, srcFile)
+            self.parts.append(srsPartTarget)
+            partTargets.append(srsPartTarget.target)
 
-    def AddFiles(self, files):
-        parts = []
-        for file in files:
-            srsPartTarget = SrsPartTarget(self.env, file)
-            parts.append(srsPartTarget.target)
-        self.objects = self.env.Command('Res/SrsTarget/' + self.srsPath + '.srs', parts,
-            Action(build_srs))
+        self.objects = self.env.Command('Res/SrsTarget/' + self.srsPath + '.srs', partTargets,
+            Action(self.build_srs))
+
+    def SetIncludes(self, includes):
+        for srsPart in self.parts:
+            srsPart.SetIncludes(includes)
+
+    @staticmethod
+    def build_srs(target, source, env):
+        # Concatenates the sources into the target.
+        # shutil.copyfileobj() was benchmarked as being the fastest:
+        # https://stackoverflow.com/questions/13613336/python-concatenate-text-files
+        with open(target[0].abspath, 'wb') as outfd:
+            for f in source:
+                with open(f.abspath, 'rb') as infd:
+                    shutil.copyfileobj(infd, outfd)
+        return 0
 
 class SrsPartTarget:
     def __init__(self, env, file):
         srcFile = File(file)
         dstFile = File('Res/SrsPartTarget/' + file + '.part')
-#        print('srcFile.path = ' + srcFile.path)
-#        print('srcFile.abspath = ' + srcFile.abspath)
-#        print('srcFile.srcnode().path = ' + srcFile.srcnode().path)
-#        print('srcFile.srcnode().abspath = ' + srcFile.srcnode().abspath)
 
         # We need private env changes
-        env = env.Clone()
+        self.env = env.Clone()
 
         # If we're translating, there is an extra step
-        withLang = env.get('AOO_WITH_LANG')
+        withLang = self.env.get('AOO_WITH_LANG')
         if withLang == None or withLang == '':
             translatedFile = srcFile
         else:
             sdf = '${LOCDIR}/l10n/${INPATH}/misc/sdf/' + srcFile.Dir('.').srcnode().path + '/localize.sdf'
-            env.Depends(dstFile, sdf)
-            env['AOO_SDF'] = sdf
-            env['AOO_PRJ'] = srcFile.srcnode().path.split('/')[0]
+            self.env.Depends(dstFile, sdf)
+            self.env['AOO_SDF'] = sdf
+            self.env['AOO_PRJ'] = srcFile.srcnode().path.split('/')[0]
             translatedFile = File('Res/SrsPartMergeTarget/' + file + '.partmerge')
-            env.Command(translatedFile, srcFile.srcnode(), ' '.join([
+            self.env.Command(translatedFile, srcFile.srcnode(), ' '.join([
                 '${OUTDIR}/bin/transex3',
                 '-p ${AOO_PRJ}',
                 '-i ${SOURCE}',
@@ -173,9 +174,9 @@ class SrsPartTarget:
                 '-l all']))
 
         # Because we're using a custom builder, we have to build includes and defs manually
-        env['RSC_CPPPATH'] = '-I' + ' -I'.join(env['CPPPATH'])
-        env['RSC_CPPDEFINES'] = '-D' + ' -D'.join(env['CPPDEFINES'])
-        self.target = env.Command(dstFile, translatedFile, ' '.join([
+        self.env['RSC_CPPPATH'] = '-I' + ' -I'.join(self.env['CPPPATH'])
+        self.env['RSC_CPPDEFINES'] = '-D' + ' -D'.join(self.env['CPPDEFINES'])
+        self.target = self.env.Command(dstFile, translatedFile, ' '.join([
             '${OUTDIR}/bin/rsc',
             '-s',
             '${RSC_CPPPATH}',
@@ -183,7 +184,6 @@ class SrsPartTarget:
             '-fp=$TARGET',
             '$SOURCE']))
 
-
-class SrsPartMergeTarget:
-    def __init__(self):
-        pass
+    def SetIncludes(self, includes):
+        self.env.Replace(CPPPATH=includes)
+        self.env['RSC_CPPPATH'] = '-I' + ' -I'.join(self.env['CPPPATH'])
diff --git a/main/uui/SConscript b/main/uui/SConscript
index 238cead..b44e76d 100644
--- a/main/uui/SConscript
+++ b/main/uui/SConscript
@@ -1,9 +1,7 @@
 #print("Dir(.)=" + Dir('.').path)
 #print("Dir(#.)=" + Dir('#.').path)
 
-srsTarget = SrsTarget('uui/res')
-srsTarget.SetInclude(env['CPPPATH'] + ['uui/source/'])
-srsTarget.AddFiles([
+srsTarget = SrsTarget('uui/res', [
         'source/cookiedg.src',
         'source/ids.src',
         'source/logindlg.src',
@@ -22,8 +20,8 @@ srsTarget.AddFiles([
         'source/trylater.src',
         'source/nameclashdlg.src',
         'source/newerverwarn.src'
-
 ])
+srsTarget.SetIncludes(env['CPPPATH'] + ['uui/source'])
 
 #ResTarget('uui', 'en-US', [srsTarget.objects])
 AllLangResTarget('uui', [srsTarget.objects])