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 946b44884e5e795212e68f0c609b865b2a49be44 Author: Damjan Jovanovic <dam...@apache.org> AuthorDate: Mon Jun 29 06:46:44 2020 +0200 Add l10n translations. Patch by: me --- main/site_scons/AllLangRes.py | 43 +++++++++++++++++++++++++++++++++++-------- main/site_scons/site_init.py | 2 ++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/main/site_scons/AllLangRes.py b/main/site_scons/AllLangRes.py index 1708876..81a8fc4 100644 --- a/main/site_scons/AllLangRes.py +++ b/main/site_scons/AllLangRes.py @@ -125,6 +125,9 @@ class SrsTarget: def __init__(self, srsPath): 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 @@ -142,20 +145,44 @@ class SrsTarget: class SrsPartTarget: def __init__(self, env, file): srcFile = File(file) - dstFile = File('Res/SrsPartTarget/' + 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) - env2 = env.Clone() - for var in env['CPPPATH']: - env2.Append(RSC_CPPPATH = ' -I' + var) - for var in env['CPPDEFINES']: - env2.Append(RSC_CPPDEFINES = ' -D' + var) + # We need private env changes + env = env.Clone() + + # If we're translating, there is an extra step + withLang = 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] + translatedFile = File('Res/SrsPartMergeTarget/' + file + '.partmerge') + env.Command(translatedFile, srcFile.srcnode(), ' '.join([ + '${OUTDIR}/bin/transex3', + '-p ${AOO_PRJ}', + '-i ${SOURCE}', + '-o ${TARGET}', + '-m ${AOO_SDF}', + '-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([ + '${OUTDIR}/bin/rsc', + '-s', + '${RSC_CPPPATH}', + '${RSC_CPPDEFINES}', + '-fp=$TARGET', + '$SOURCE'])) - self.target = env2.Command(dstFile, srcFile.srcnode(), - '${OUTDIR}/bin/rsc -s ${RSC_CPPPATH} ${RSC_CPPDEFINES} -fp=$TARGET $SOURCE') class SrsPartMergeTarget: def __init__(self): diff --git a/main/site_scons/site_init.py b/main/site_scons/site_init.py index c38fc50..01a0360 100644 --- a/main/site_scons/site_init.py +++ b/main/site_scons/site_init.py @@ -45,6 +45,8 @@ env['SOLARSRC'] = soenv['SOLARSRC'] env['OUTDIR'] = soenv['OUTDIR'] env['WORKDIR'] = soenv['WORKDIR'] env['SOLARENV'] = soenv['SOLARENV'] +env['LOCDIR'] = Dir(soenv['SOLARSRC']).Dir('..').abspath + '/extras' +env['INPATH'] = soenv['INPATH'] ## Useful constants