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 c128808560ee319f52c4787ff923cb04bc1b5896 Author: Damjan Jovanovic <dam...@apache.org> AuthorDate: Sat Feb 1 19:40:26 2020 +0200 Initial import of a preliminary SCons-based build system. Initial port of main/fileaccess to SCons. Patch by: me --- main/SConstruct | 1 + main/fileaccess/{prj/makefile.mk => SConscript} | 53 ++-- main/fileaccess/prj/makefile.mk | 2 +- .../prj/makefile.mk => site_scons/config.py} | 36 ++- .../prj/makefile.mk => site_scons/executable.py} | 40 +-- main/site_scons/globals.py | 164 ++++++++++++ main/site_scons/platform/aooplatform.py | 104 ++++++++ main/site_scons/platform/freebsd.py | 251 ++++++++++++++++++ main/site_scons/platform/windows.py | 293 +++++++++++++++++++++ main/site_scons/sharedLibrary.py | 70 +++++ main/site_scons/sharedObjects.py | 63 +++++ main/site_scons/site_init.py | 149 +++++++++++ 12 files changed, 1166 insertions(+), 60 deletions(-) diff --git a/main/SConstruct b/main/SConstruct new file mode 100644 index 0000000..05d09bd --- /dev/null +++ b/main/SConstruct @@ -0,0 +1 @@ +SConscript('fileaccess/SConscript', variant_dir=WORKDIR+'/scons/fileaccess', duplicate=0) diff --git a/main/fileaccess/prj/makefile.mk b/main/fileaccess/SConscript similarity index 61% copy from main/fileaccess/prj/makefile.mk copy to main/fileaccess/SConscript index 353f9e0..cd47d9c 100644 --- a/main/fileaccess/prj/makefile.mk +++ b/main/fileaccess/SConscript @@ -19,26 +19,37 @@ # #************************************************************** +objs = AOOSharedObjects() +objs.AddAPI([ + 'offapi', + 'udkapi' +]) +objs.AddInclude([ + 'inc' +]) +objs.AddDefs([ + 'FILEACCESS_DLLIMPLEMENTATION' +]) +objs.AddCxxExceptionSources([ + 'source/FileAccess.cxx' +]) +fileacc = AOOSharedLibrary( + 'fileacc', + 'OOOLIBS', + objs.objects +) +fileacc.AddLinkedLibs( + [ + CPPULIB, + CPPUHELPERLIB, + SALLIB, + TOOLSLIB, + UCBHELPERLIB, + UNOTOOLSLIB + ] + STDLIBS +) +fileacc.SetComponentFile('util/fileacc') +fileacc.InstallTo('${OUTDIR}/lib') +Install('${OUTDIR}/xml', 'source/fileacc.xml') -PRJ=.. -TARGET=prj - -.INCLUDE : settings.mk - -.IF "$(VERBOSE)"!="" -VERBOSEFLAG := -.ELSE -VERBOSEFLAG := -s -.ENDIF - -.IF "$(DEBUG)"!="" -DEBUG_ARGUMENT=DEBUG=$(DEBUG) -.ELIF "$(debug)"!="" -DEBUG_ARGUMENT=debug=$(debug) -.ELSE -DEBUG_ARGUMENT= -.ENDIF - -all: - cd $(PRJ) && $(GNUMAKE) $(VERBOSEFLAG) -r -j$(MAXPROCESS) $(gb_MAKETARGET) $(DEBUG_ARGUMENT) && $(GNUMAKE) $(VERBOSEFLAG) -r deliverlog diff --git a/main/fileaccess/prj/makefile.mk b/main/fileaccess/prj/makefile.mk index 353f9e0..9476456 100644 --- a/main/fileaccess/prj/makefile.mk +++ b/main/fileaccess/prj/makefile.mk @@ -41,4 +41,4 @@ DEBUG_ARGUMENT= .ENDIF all: - cd $(PRJ) && $(GNUMAKE) $(VERBOSEFLAG) -r -j$(MAXPROCESS) $(gb_MAKETARGET) $(DEBUG_ARGUMENT) && $(GNUMAKE) $(VERBOSEFLAG) -r deliverlog + cd $(PRJ) && scons -u $(VERBOSEFLAG) -j$(MAXPROCESS) install diff --git a/main/fileaccess/prj/makefile.mk b/main/site_scons/config.py similarity index 60% copy from main/fileaccess/prj/makefile.mk copy to main/site_scons/config.py index 353f9e0..d7f5455 100644 --- a/main/fileaccess/prj/makefile.mk +++ b/main/site_scons/config.py @@ -19,26 +19,24 @@ # #************************************************************** +import os +_siteDir, _myFilename = os.path.split(os.path.abspath(__file__)) +_mainDir, _siteDir2 = os.path.split(_siteDir) -PRJ=.. -TARGET=prj +# Or should we patch set_soenv to generate us a .py file? +def _loadJavaProperties(filepath): + props = {} + with open(filepath, "rt") as f: + for line in f: + l = line.strip() + if l and not l.startswith('#'): + eq = l.find('=') + if eq >= 0: + key = l[:eq].strip() + value = l[(eq+1):].strip() + props[key] = value + return props -.INCLUDE : settings.mk +soenv = _loadJavaProperties(_mainDir + '/ant.properties') -.IF "$(VERBOSE)"!="" -VERBOSEFLAG := -.ELSE -VERBOSEFLAG := -s -.ENDIF - -.IF "$(DEBUG)"!="" -DEBUG_ARGUMENT=DEBUG=$(DEBUG) -.ELIF "$(debug)"!="" -DEBUG_ARGUMENT=debug=$(debug) -.ELSE -DEBUG_ARGUMENT= -.ENDIF - -all: - cd $(PRJ) && $(GNUMAKE) $(VERBOSEFLAG) -r -j$(MAXPROCESS) $(gb_MAKETARGET) $(DEBUG_ARGUMENT) && $(GNUMAKE) $(VERBOSEFLAG) -r deliverlog diff --git a/main/fileaccess/prj/makefile.mk b/main/site_scons/executable.py similarity index 52% copy from main/fileaccess/prj/makefile.mk copy to main/site_scons/executable.py index 353f9e0..fb602ae 100644 --- a/main/fileaccess/prj/makefile.mk +++ b/main/site_scons/executable.py @@ -19,26 +19,28 @@ # #************************************************************** +from SCons.Script import * +from config import soenv +from globals import * +class AOOExecutable: + def __init__(self, target, group, objects): + self.env = DefaultEnvironment().Clone() + self.exe = self.env.Program( + target, + source = objects + ) + self.env['AOO_THIS'] = self.exe[0] + self.env.Append(LINKFLAGS=platform.getExecutableLDFlags(soenv, group, OUTDIRLOCATION, DEBUGGING, DEBUGLEVEL)) + self.env.Append(LIBPATH=platform.getLDPATH(soenv)) + self.env['AOO_GROUP'] = group + self.env['AOO_LAYER'] = platform.getLibraryGroupLayer(group) -PRJ=.. -TARGET=prj + def AddLinkedLibs(self, libs): + self.env.Append(LIBS=libs) -.INCLUDE : settings.mk + def SetTargetTypeGUI(self, isGUI): + self.env.Append(LINKFLAGS=platform.getTargetTypeGUIFlags(isGUI)) -.IF "$(VERBOSE)"!="" -VERBOSEFLAG := -.ELSE -VERBOSEFLAG := -s -.ENDIF - -.IF "$(DEBUG)"!="" -DEBUG_ARGUMENT=DEBUG=$(DEBUG) -.ELIF "$(debug)"!="" -DEBUG_ARGUMENT=debug=$(debug) -.ELSE -DEBUG_ARGUMENT= -.ENDIF - -all: - cd $(PRJ) && $(GNUMAKE) $(VERBOSEFLAG) -r -j$(MAXPROCESS) $(gb_MAKETARGET) $(DEBUG_ARGUMENT) && $(GNUMAKE) $(VERBOSEFLAG) -r deliverlog + def InstallTo(self, path): + self.env.Install(path, self.exe) diff --git a/main/site_scons/globals.py b/main/site_scons/globals.py new file mode 100644 index 0000000..8a65f17 --- /dev/null +++ b/main/site_scons/globals.py @@ -0,0 +1,164 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +from config import soenv +import os +_siteDir, _myFilename = os.path.split(os.path.abspath(__file__)) +import sys +sys.path.insert(0, _siteDir + '/platform') + +############################ +# Platforms +############################ + +if soenv['OS'] == 'FREEBSD': + from freebsd import * + platform = FreeBSD() +elif soenv['OS'] == 'WNT': + from windows import * + platform = Windows() +else: + raise Exception ('Unsupported OS: ' + soenv['OS']) + +GUI = platform.getGUI() +COMID = platform.getCOMID() + +############################ +# Product and debug settings +############################ + +PRODUCT = (soenv.get('PRODUCT') == 'TRUE') + +if 'DEBUG' in soenv: + DEBUGLEVEL = 2 +elif PRODUCT: + DEBUGLEVEL = 1 +else: + DEBUGLEVEL = 0 + +DEBUGGING = False +if DEBUGLEVEL == 2: + DEBUGGING = True + +if soenv.get('ENABLE_SYMBOLS') == 'SMALL': + DEBUGGING = True +elif soenv.get('ENABLE_SYMBOLS') == 'TRUE': + DEBUGGING = True + +if soenv.get('ENABLE_CRASHDUMP') == 'TRUE': + DEBUGGING = True + + +############################ +# Precompiled headers +############################ + +ENABLE_PCH = (soenv.get('ENABLE_PCH') == 'TRUE') + +############################ +# Defs +############################ + +GLOBALDEFS = [ + '_REENTRANT', + 'CUI', + 'ENABLE_LAYOUT_EXPERIMENTAL=0', + 'ENABLE_LAYOUT=0', + 'OSL_DEBUG_LEVEL=' + str(DEBUGLEVEL), + 'SOLAR_JAVA', + 'SUPD=' + soenv['UPD'], + 'VCL' +] + +GLOBALDEFS += platform.getOSDefs(soenv) +GLOBALDEFS += platform.getCompilerDefs(soenv) +GLOBALDEFS += platform.getCPUDefs(soenv) + +if PRODUCT: + GLOBALDEFS += ['PRODUCT', 'PRODUCT_FULL'] +else: + GLOBALDEFS += ['DBG_UTIL', 'STLP_DEBUG'] + +if DEBUGLEVEL == 2: + GLOBALDEFS += ['DEBUG']; +else: + GLOBALDEFS += ['OPTIMIZE', 'NDEBUG'] + +if 'ENABLE_GTK' in soenv: + GLOBALDEFS += ['ENABLE_GTK'] +if 'ENABLE_KDE' in soenv: + GLOBALDEFS += ['ENABLE_KDE'] +if 'ENABLE_KDE4' in soenv: + GLOBALDEFS += ['ENABLE_KDE4'] +if 'ENABLE_GRAPHITE' in soenv: + GLOBALDEFS += ['ENABLE_GRAPHITE'] + +############################ +# Paths +############################ + +OUTDIR = soenv['SOLARVERSION'] + "/" + soenv['INPATH'] +WORKDIR = OUTDIR + "/workdir" +OUTDIRLOCATION = OUTDIR + os.sep + 'lib' + +############################ +# Libraries +############################ + +# FIXME: this probably belongs elsewhere +UCBHELPER_MAJOR=4 +UDK_MAJOR=3 + +if GUI == 'UNX' or soenv['COM'] == 'GCC': + if GUI+soenv['COM'] == 'WNTGCC': + CPPULIB = 'cppu' + UDK_MAJOR + CPPUHELPERLIB = 'cppuhelper' + UDK_MAJOR + COMID + elif GUI == 'OS2': + CPPULIB = 'cppu' + UDK_MAJOR + CPPUHELPERLIB = 'cppuh' + UDK_MAJOR + else: + CPPULIB = 'uno_cppu' + CPPUHELPERLIB = 'uno_cppuhelper' + COMID + + if GUI+soenv['COM'] == 'WNTGCC' or GUI == 'OS2': + SALLIB = 'sal' + UDK_MAJOR + else: + SALLIB = 'uno_sal' + + TOOLSLIB = 'tl' + + if GUI == 'OS2': + UCBHELPERLIB = 'ucbh' + UCBHELPER_MAJOR + else: + UCBHELPERLIB= 'ucbhelper' + COMID + + UNOTOOLSLIB = 'utl' + +else: + CPPULIB = 'icppu' + CPPUHELPERLIB = 'icppuhelper' + SALLIB = 'isal' + TOOLSLIB = 'itools' + UCBHELPERLIB = 'iucbhelper' + UNOTOOLSLIB = 'iutl' + +STDLIBS = platform.getStandardLibs() + diff --git a/main/site_scons/platform/aooplatform.py b/main/site_scons/platform/aooplatform.py new file mode 100644 index 0000000..11dfbb0 --- /dev/null +++ b/main/site_scons/platform/aooplatform.py @@ -0,0 +1,104 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +from abc import ABC, abstractmethod + +class Platform(ABC): + @abstractmethod + def getGUI(self): + pass + + @abstractmethod + def getCOMID(self): + pass + + @abstractmethod + def getCompilerDefs(self, soenv): + pass + + @abstractmethod + def getCPUDefs(self, soenv): + pass + + @abstractmethod + def getOSDefs(self, soenv): + pass + + @abstractmethod + def getLibraryDefs(self, soenv): + pass + + @abstractmethod + def getCFlags(self, soenv): + pass + + @abstractmethod + def getCXXFlags(self, soenv): + pass + + @abstractmethod + def getInclude(self, soenv): + pass + + @abstractmethod + def getIncludeStl(self, soenv): + pass + + @abstractmethod + def getExceptionFlags(self, soenv, enabled): + pass + + @abstractmethod + def getCompilerOptFlags(self, enabled, debugLevel): + pass + + @abstractmethod + def getDebugCFlags(self, compiler, enableSymbols): + pass + + @abstractmethod + def getExecutableLDFlags(self, soenv, group, outDirLocation, debugging, debugLevel): + pass + + @abstractmethod + def getLibraryLDFlags(self, soenv, group, outDirLocation, debugging, debugLevel): + pass + + @abstractmethod + def getStandardLibs(self): + pass + + @abstractmethod + def getLibraryGroupLayer(self, group): + pass + + @abstractmethod + def getLibraryLayerComponentPrefix(self, layer): + pass + + @abstractmethod + def getExecutableEnvironment(self, soenv): + pass + + @abstractmethod + def getTargetTypeGUIFlags(self, isGUI): + pass + diff --git a/main/site_scons/platform/freebsd.py b/main/site_scons/platform/freebsd.py new file mode 100644 index 0000000..c1e845f --- /dev/null +++ b/main/site_scons/platform/freebsd.py @@ -0,0 +1,251 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +import subprocess +import aooplatform + +class FreeBSD(aooplatform.Platform): + def __init__(self): + self.GXX_INCLUDE_PATH = None + self.executableGroupLayers = {} + self.executableGroupLayers['UREBIN'] = 'UREBIN' + self.executableGroupLayers['SDK'] = 'SDKBIN' + self.executableGroupLayers['OOO'] = 'OOO' + self.executableGroupLayers['BRAND'] = 'BRAND' + self.executableGroupLayers['NONE'] = 'NONEBIN' + self.libraryGroupLayers = {} + self.libraryGroupLayers['OOOLIBS'] = 'OOO' + self.libraryGroupLayers['PLAINLIBS_URE'] = 'URELIB' + self.libraryGroupLayers['PLAINLIBS_OOO'] = 'OOO' + self.libraryGroupLayers['RTLIBS'] = 'OOO' + self.libraryGroupLayers['RTVERLIBS'] = 'URELIB' + self.libraryGroupLayers['STLLIBS'] = 'URELIB' + self.libraryGroupLayers['UNOLIBS_URE'] = 'URELIB' + self.libraryGroupLayers['UNOLIBS_OOO'] = 'OOO' + self.libraryGroupLayers['UNOVERLIBS'] = 'URELIB' + self.layerRPaths = {} + self.layerRPaths['URELIB'] = '$ORIGIN' + self.layerRPaths['UREBIN'] = '$ORIGIN/../lib:$ORIGIN' + self.layerRPaths['OOO'] = '$ORIGIN:$ORIGIN/../ure-link/lib' + self.layerRPaths['BRAND'] = '$ORIGIN:$ORIGIN/../basis-link/program:$ORIGIN/../basis-link/ure-link/lib' + self.layerRPaths['SDKBIN'] = '$ORIGIN/../../ure-link/lib' + self.layerRPaths['NONEBIN'] = '$ORIGIN/../lib:$ORIGIN' + self.layerComponentPrefixes = {} + self.layerComponentPrefixes['OOO'] = 'vnd.sun.star.expand:\\$$OOO_BASE_DIR/program/' + self.layerComponentPrefixes['URELIB'] = 'vnd.sun.star.expand:\\$$URE_INTERNAL_LIB_DIR/' + self.layerComponentPrefixes['NONE'] = 'vnd.sun.star.expand:\\$$OOO_INBUILD_SHAREDLIB_DIR/' + + def getGUI(self): + return 'UNX' + + def getCOMID(self): + return 'gcc3' + + def getCompilerDefs(self, soenv): + if self.GXX_INCLUDE_PATH is None: + gccVersion = subprocess.Popen("gcc -dumpversion", shell=True, stdout=subprocess.PIPE).stdout.readline().rstrip() + self.GXX_INCLUDE_PATH = soenv['COMPATH'] + "/include/c++/" + gccVersion.decode('utf-8') + return [ + soenv['COM'], + 'HAVE_GCC_VISIBILITY_FEATURE', + 'CPPU_ENV=gcc3', + 'GXX_INCLUDE_PATH=' + self.GXX_INCLUDE_PATH + ] + + def getCPUDefs(self, soenv): + return [soenv['CPUNAME']] + + def getOSDefs(self, soenv): + defs = [ + soenv['OS'], + '_PTHREADS', + 'UNIX', + 'UNX' + ] + if 'PTHREAD_CFLAGS' in soenv: + defs += [soenv['PTHREAD_CFLAGS']] + return defs + + def getCFlags(self, soenv): + flags = [ + '-Wall', + '-Wendif-labels', + '-Wextra', + '-Wshadow', + '-fPIC', + '-fmessage-length=0', + '-fno-common', + '-fno-strict-aliasing', + '-fvisibility=hidden', + '-pipe' + ] + if soenv.get('EXTERNAL_WARNINGS_NOT_ERRORS') != 'TRUE': + flags += ['-Werror'] + if 'SYSBASE' in soenv: + flags += ['--sysroot=' + soenv['SYSBASE']] + return flags + + def getCXXFlags(self, soenv): + flags = [ + '-Wall', + '-Wendif-labels', + '-Wextra', + '-Wno-ctor-dtor-privacy', + '-Wno-non-virtual-dtor', + '-Wshadow', + '-fPIC', + '-fmessage-length=0', + '-fno-common', + '-fno-strict-aliasing', + '-fno-use-cxa-atexit', + '-fvisibility-inlines-hidden', + '-fvisibility=hidden', + '-pipe' + ] + if soenv['EXTERNAL_WARNINGS_NOT_ERRORS'] != 'TRUE': + flags += ['-Werror'] + if 'SYSBASE' in soenv: + flags += ['--sysroot=' + soenv['SYSBASE']] + if soenv['COM'] == 'CLANG': + flags += ['-DHAVE_STL_INCLUDE_PATH'] + else: + flags += ['-DBOOST_TR1_DISABLE_INCLUDE_NEXT', '-DBOOST_TR1_GCC_INCLUDE_PATH=c++'] + return flags + + def getInclude(self, soenv): + includes = [] + for i in soenv['SOLARINC'].split(' '): + if i.endswith('/stl'): + continue; + if i.startswith('-I'): + includes.append(i[2:]) + return includes + + def getIncludeStl(self, soenv): + includes = [] + for i in soenv['SOLARINC'].split(' '): + if i.startswith('-I') and i.endswith('/stl'): + includes.append(i[2:]) + return includes + + def getExceptionFlags(self, soenv, enabled): + flags = [] + if enabled: + flags += ['-DEXCEPTIONS_ON', '-fexceptions'] + if soenv['COM'] == 'GCC': + flags += ['-fno-enforce-eh-specs']; + else: + flags += ['-DEXCEPTIONS_OFF', '-fno-exceptions'] + return flags + + def getCompilerOptFlags(self, enabled, debugLevel): + if enabled: + if debugLevel == 2: + return ['-O0'] + else: + return ['-Os'] + else: + return ['-O0'] + + def getDebugCFlags(self, compiler, enableSymbols): + if compiler == 'CLANG': + if enableSymbols == 'SMALL': + return ['-ggdb1', '-fno-inline'] + else: + return ['-ggdb3', '-fno-inline'] + else: + if enableSymbols == 'SMALL': + return ['-ggdb1', '-finline-limit=0', '-fno-inline', '-fno-default-inline'] + else: + return ['-ggdb3', '-finline-limit=0', '-fno-inline', '-fno-default-inline'] + + def getRPATH(self, layer): + return self.layerRPaths[layer] + + def getLibraryDefs(self, soenv): + return [] + + def getLDFlags(self, soenv, debugging, debugLevel): + sysbase = soenv.get('SYSBASE') + if sysbase is None: + sysbase = '' + flags = [ + '-Wl,-rpath-link,' + sysbase + '/lib:' + sysbase + '/usr/lib', + '-Wl,-z,combreloc', + '-Wl,-z,defs' + ] + if soenv.get('FBSD_GCC_RPATH') is not None: + flags += [soenv['FBSD_GCC_RPATH']] + if sysbase != '': + flags += ['-Wl,--sysroot=' + sysbase] + if soenv.get('HAVE_LD_HASH_STYLE') == 'TRUE': + flags += ['-Wl,--hash-style=both'] + if soenv.get('HAVE_LD_BSYMBOLIC_FUNCTIONS') == 'TRUE': + flags += [ + '-Wl,--dynamic-list-cpp-new', + '-Wl,--dynamic-list-cpp-typeinfo', + '-Wl,-Bsymbolic-functions' + ] + if debugLevel == 0: + flags += ['-Wl,-O1'] + return flags; + + def getLDPATH(self, soenv): + path = soenv['SOLARLIB'] + path = path.replace('-L../lib ', '') + path = path.replace('-L', '') + return path.split() + + def getExecutableLDFlags(self, soenv, group, outDirLocation, debugging, debugLevel): + flags = self.getLDFlags(soenv, debugging, debugLevel) + flags += [ + '-Wl,-rpath,' + self.getRPATH(self.executableGroupLayers(group)), + '-Wl,-rpath-link,' + outDirLocation + ] + return flags + + def getLibraryLDFlags(self, soenv, group, outDirLocation, debugging, debugLevel): + flags = self.getLDFlags(soenv, debugging, debugLevel) + flags += [ '-Wl,-z,noexecstack' ] + flags += [ + '-Wl,-z,origin', + '-Wl,-rpath,' + self.getRPATH(self.getLibraryGroupLayer(group)), + '-Wl,-rpath-link,' + outDirLocation + ] + return flags + + def getStandardLibs(self): + return [] + + def getLibraryGroupLayer(self, group): + return self.libraryGroupLayers[group] + + def getLibraryLayerComponentPrefix(self, layer): + return self.layerComponentPrefixes[layer] + + def getExecutableEnvironment(self, soenv): + return { + 'LD_LIBRARY_PATH' : soenv['OUTDIR'] + '/lib' + } + + def getTargetTypeGUIFlags(self, isGUI): + return [] + diff --git a/main/site_scons/platform/windows.py b/main/site_scons/platform/windows.py new file mode 100644 index 0000000..eeec1ad --- /dev/null +++ b/main/site_scons/platform/windows.py @@ -0,0 +1,293 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +import aooplatform + +class Windows(aooplatform.Platform): + def __init__(self): + self.libraryGroupLayers = {} + self.libraryGroupLayers['OOOLIBS'] = 'OOO' + self.libraryGroupLayers['PLAINLIBS_URE'] = 'OOO' + self.libraryGroupLayers['PLAINLIBS_OOO'] = 'OOO' + self.libraryGroupLayers['RTLIBS'] = 'OOO' + self.libraryGroupLayers['RTVERLIBS'] = 'OOO' + self.libraryGroupLayers['STLLIBS'] = 'OOO' + self.libraryGroupLayers['UNOLIBS_URE'] = 'OOO' + self.libraryGroupLayers['UNOLIBS_OOO'] = 'OOO' + self.libraryGroupLayers['UNOVERLIBS'] = 'OOO' + self.layerComponentPrefixes = {} + self.layerComponentPrefixes['OOO'] = 'vnd.sun.star.expand:$$OOO_BASE_DIR/program/' + self.layerComponentPrefixes['URELIB'] = 'vnd.sun.star.expand:$$URE_INTERNAL_LIB_DIR/' + self.layerComponentPrefixes['NONE'] = 'vnd.sun.star.expand:$$OOO_INBUILD_SHAREDLIB_DIR/' + + def getGUI(self): + return 'WNT' + + def getCOMID(self): + return 'MSC' + + def getCompilerDefs(self, soenv): + defs = [ + 'MSC', + '_CRT_NON_CONFORMING_SWPRINTFS', + '_CRT_NONSTDC_NO_DEPRECATE', + '_CRT_SECURE_NO_DEPRECATE', + '_MT', + '_DLL', + 'CPPU_ENV=' + soenv['COMNAME'], + 'FULL_DESK', + 'M1500' + ] + if soenv['CPUNAME'] == 'INTEL': + defs += ['BOOST_MEM_FN_ENABLE_CDECL'] + return defs; + + def getCPUDefs(self, soenv): + defs = [ + 'ALIGN=' + soenv['ALIGN'], + 'CPUNAME=' + soenv['CPUNAME'] + ] + if soenv['CPUNAME'] == 'INTEL': + defs += ['_X86_=1'] + elif soenv['CPUNAME'] == 'X86_64': + defs += ['_AMD64_=1'] + return defs + + def getOSDefs(self, soenv): + return [ + 'WINVER=0x0500', + '_WIN32_IE=0x0500', + 'NT351', + 'WIN32', + 'WNT' + ] + + def getCFlags(self, soenv): + flags = [ + '-Gd', + '-GR', + '-Gs', + '-GS', + '-nologo', + '-Wall', + '-wd4005', + '-wd4061', + '-wd4127', + '-wd4180', + '-wd4189', + '-wd4191', + '-wd4217', + '-wd4250', + '-wd4251', + '-wd4255', + '-wd4275', + '-wd4290', + '-wd4294', + '-wd4350', + '-wd4355', + '-wd4365', + '-wd4503', + '-wd4505', + '-wd4511', + '-wd4512', + '-wd4514', + '-wd4611', + '-wd4619', + '-wd4625', + '-wd4626', + '-wd4640', + '-wd4668', + '-wd4675', + '-wd4692', + '-wd4710', + '-wd4711', + '-wd4738', + '-wd4786', + '-wd4800', + '-wd4820', + '-wd4826', + '-Zc:wchar_t-', + '-Zm500' + ] + if soenv['EXTERNAL_WARNINGS_NOT_ERRORS'] != 'TRUE': + flags += ['-WX'] + return flags + + def getCXXFlags(self, soenv): + flags = [ + '-Gd', + '-GR', + '-Gs', + '-GS', + '-Gy', + '-nologo', + '-Wall', + '-wd4005', + '-wd4061', + '-wd4127', + '-wd4180', + '-wd4189', + '-wd4191', + '-wd4217', + '-wd4250', + '-wd4251', + '-wd4275', + '-wd4290', + '-wd4294', + '-wd4350', + '-wd4355', + '-wd4365', + '-wd4503', + '-wd4505', + '-wd4511', + '-wd4512', + '-wd4514', + '-wd4611', + '-wd4619', + '-wd4625', + '-wd4626', + '-wd4640', + '-wd4668', + '-wd4675', + '-wd4692', + '-wd4710', + '-wd4711', + '-wd4738', + '-wd4786', + '-wd4800', + '-wd4820', + '-wd4826', + '-Zc:wchar_t-', + '-Zm500' + ] + if soenv['EXTERNAL_WARNINGS_NOT_ERRORS'] != 'TRUE': + flags += ['-WX'] + return flags + + def getInclude(self, soenv): + includes = [] + for i in soenv['SOLARINC'].split(' '): + if i.endswith('/stl'): + continue; + if i.startswith('-I'): + includes.append(i[2:]) + return includes + + def getIncludeStl(self, soenv): + includes = [] + for i in soenv['SOLARINC'].split(' '): + if i.startswith('-I') and i.endswith('/stl'): + includes.append(i[2:]) + return includes + + def getExceptionFlags(self, soenv, enabled): + flags = [] + if enabled: + flags += ['-DEXCEPTIONS_ON', '-EHa'] + else: + flags += ['-DEXCEPTIONS_OFF'] + return flags + + def getCompilerOptFlags(self, enabled, debugLevel): + if enabled: + if debugLevel == 2: + return [] + else: + return ['-Ob1', '-Oxs', '-Oy-'] + else: + return ['-Od'] + + def getDebugCFlags(self, compiler, debugging, enableSymbols): + return ['-Zi'] + + def getLibraryDefs(self, soenv): + return ['_DLL_'] + + def getLDFlags(self, soenv, debugging, debugLevel): + flags = [ + '-NODEFAULTLIB' + ] + if soenv['CPUNAME'] == 'INTEL': + flags += ['-MACHINE:IX86'] + elif soenv['CPUNAME'] == 'X86_64': + flags += ['-MACHINE:X64'] + if debugging: + flags += ['-DEBUG'] + return flags; + + def getLDPATH(self, soenv): + path = [] + ilib = soenv['ILIB'] + ilib = ilib.replace(';', ' ') + for i in ilib.split(' '): + if i != '.': + path += [i] + return path + + def getExecutableLDFlags(self, soenv, group, outDirLocation, debugging, debugLevel): + flags = self.getLDFlags(soenv, debugging, debugLevel) + flags += [ + '-RELEASE', + '-BASE:0x1b000000', + '-OPT:NOREF', + '-INCREMENTAL:NO', + '-DEBUG', + '-NXCOMPAT', + '-DYNAMICBASE' + ] + if env['CPUNAME'] == 'INTEL': + flags += ['-SAFESEH'] + return flags + + def getLibraryLDFlags(self, soenv, group, outDirLocation, debugging, debugLevel): + flags = self.getLDFlags(soenv, debugging, debugLevel) + flags += [ + '-DLL', + '-OPT:NOREF', + '-NXCOMPAT', + '-DYNAMICBASE', + ] + if env['CPUNAME'] == 'INTEL': + flags += ['-SAFESEH'] + return flags + + def getStandardLibs(self): + return [ + 'kernel32', + 'msvcrt', + 'oldnames', + 'uwinapi' + ] + + def getLibraryGroupLayer(self, group): + return self.libraryGroupLayers[group] + + def getLibraryLayerComponentPrefix(self, layer): + return self.layerComponentPrefixes[layer] + + def getExecutableEnvironment(self, soenv): + return {} + + def getTargetTypeGUIFlags(self, isGUI): + if isGUI: + return '-SUBSYSTEM:WINDOWS' + else: + return '-SUBSYSTEM:CONSOLE' diff --git a/main/site_scons/sharedLibrary.py b/main/site_scons/sharedLibrary.py new file mode 100644 index 0000000..afe7644 --- /dev/null +++ b/main/site_scons/sharedLibrary.py @@ -0,0 +1,70 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +from SCons.Script import * +from config import soenv +from globals import * + +class AOOSharedLibrary: + def __init__(self, target, group, sharedObjects): + self.env = DefaultEnvironment().Clone() + self.sharedLib = self.env.SharedLibrary( + target, + source = sharedObjects + ) + self.env['AOO_THIS'] = self.sharedLib[0] + self.env.Append(LINKFLAGS=platform.getLibraryLDFlags(soenv, group, OUTDIRLOCATION, DEBUGGING, DEBUGLEVEL)) + self.env.Append(LIBPATH=platform.getLDPATH(soenv)) + self.env['AOO_GROUP'] = group + self.env['AOO_LAYER'] = platform.getLibraryGroupLayer(group) + + def AddLinkedLibs(self, libs): + self.env.Append(LIBS=libs) + + def SetComponentFile(self, path): + componentFile = File(path + '.component') + inbuildComponentFile = File(path + '.inbuild.component') + + outdirComponentDir = Dir(OUTDIR + '/xml/component/' + componentFile.srcnode().dir.path) + + xsltenv = self.env.Clone() + xsltenv.Append(ENV = platform.getExecutableEnvironment(soenv)) + if soenv['SYSTEM_LIBXSLT'] == 'YES': + xsltenv['AOO_XSLTPROC'] = 'xsltproc' + else: + xsltenv['AOO_XSLTPROC'] = '${OUTDIR}/bin/xsltproc' + xsltenv['AOO_COMPONENTPREFIX'] = platform.getLibraryLayerComponentPrefix(self.env['AOO_LAYER']) + xsltenv['AOO_INBUILDCOMPONENTPREFIX'] = platform.getLibraryLayerComponentPrefix('NONE') + + finalComponent = xsltenv.Command(componentFile, componentFile.srcnode(), + '${AOO_XSLTPROC} --nonet --stringparam uri "${AOO_COMPONENTPREFIX}${AOO_THIS.name}"' \ + ' -o $TARGET ${SOLARENV}/bin/createcomponent.xslt $SOURCE' + ) + inbuildComponent = xsltenv.Command(inbuildComponentFile, componentFile.srcnode(), + '${AOO_XSLTPROC} --nonet --stringparam uri "${AOO_INBUILDCOMPONENTPREFIX}${AOO_THIS.name}"' \ + ' -o $TARGET ${SOLARENV}/bin/createcomponent.xslt $SOURCE' + ) + + self.env.Install(outdirComponentDir, finalComponent) + self.env.Install(outdirComponentDir, inbuildComponent) + + def InstallTo(self, path): + self.env.Install(path, self.sharedLib) diff --git a/main/site_scons/sharedObjects.py b/main/site_scons/sharedObjects.py new file mode 100644 index 0000000..0d068b5 --- /dev/null +++ b/main/site_scons/sharedObjects.py @@ -0,0 +1,63 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +from SCons.Script import * +from config import soenv +from globals import * + +class AOOSharedObjects: + def __init__(self): + self.env = DefaultEnvironment().Clone() + self.env.Append(CPPDEFINES=platform.getLibraryDefs(soenv)) + if DEBUGGING: + self.env.Append(CFLAGS=platform.getDebugCFlags(soenv['COM'], soenv['ENABLE_SYMBOLS'])) + self.env.Append(CXXFLAGS=platform.getDebugCFlags(soenv['COM'], soenv['ENABLE_SYMBOLS'])) + self.objects = [] + + def AddDefs(self, defs): + self.env.Append(CPPDEFINES=defs) + + def AddInclude(self, includes): + self.env.Append(CPPPATH=includes) + + def AddAPI(self, names): + for name in names: + self.env.Append(CPPPATH='${OUTDIR}/inc/' + name) + + def AddCxxExceptionSources(self, names): + self.AddCxxSources(names, + platform.getExceptionFlags(soenv, True) + + platform.getCompilerOptFlags(DEBUGLEVEL < 2, DEBUGLEVEL)) + + def AddCxxNoExceptionSources(self, names): + self.AddCxxSources(names, + platform.getExceptionFlags(soenv, False) + + platform.getCompilerOptFlags(DEBUGLEVEL < 2, DEBUGLEVEL)) + + def AddCxxSources(self, names, flags): + for name in names: + self.objects.append( + self.env.SharedObject( + name, + CXXFLAGS = self.env['CXXFLAGS'] + flags + ) + ) + diff --git a/main/site_scons/site_init.py b/main/site_scons/site_init.py new file mode 100644 index 0000000..f41a204 --- /dev/null +++ b/main/site_scons/site_init.py @@ -0,0 +1,149 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +from SCons.Script import * +import sys +import os +from config import soenv +import component +from globals import * + + +########################### +# Envirionment +########################### + +env = DefaultEnvironment( + CC = soenv['CC'], + CXX = soenv['CXX'], + CPPPATH = platform.getInclude(soenv) +) +env.Append(CPPDEFINES = GLOBALDEFS) +env.Append(CFLAGS = platform.getCFlags(soenv)) +env.Append(CXXFLAGS = platform.getCFlags(soenv)) + +## Add some common paths to the SCons environment + +env['OUTDIR'] = soenv['OUTDIR'] +env['WORKDIR'] = soenv['WORKDIR'] +env['SOLARENV'] = soenv['SOLARENV'] + +########################### +# API +########################### + +from sharedLibrary import AOOSharedLibrary +from sharedObjects import AOOSharedObjects + +def CreateSharedLibraryEnvironment(name, group): + env = Environment() + env.Replace(CC=soenv['CC']) + env.Replace(CXX=soenv['CXX']) + + env.Append(CPPPATH=platform.getInclude(soenv)) + + defines = GLOBALDEFS + defines += platform.getLibraryDefs(soenv) + env.Append(CPPDEFINES=defines) + + cflags = platform.getCFlags(soenv) + cxxflags = platform.getCXXFlags(soenv) + if DEBUGGING: + cflags += platform.getDebugCFlags(soenv['COM'], soenv['ENABLE_SYMBOLS']) + cxxflags += platform.getDebugCFlags(soenv['COM'], soenv['ENABLE_SYMBOLS']) + env.Append(CFLAGS=cflags) + print("APPENDING " + str(cxxflags)) + env.Replace(CXXFLAGS=cxxflags) + print("CXXFLAGS is " + str(env['CXXFLAGS'])) + + env.Append(LINKFLAGS=platform.getLibraryLDFlags(soenv, group, OUTDIRLOCATION, DEBUGGING, DEBUGLEVEL)) + env.Append(LIBPATH=platform.getLDPATH(soenv)) + + env['SOLARENV'] = soenv['SOLARENV'] + env['AOO_GROUP'] = group + env['AOO_LAYER'] = platform.getLibraryGroupLayer(group) + env['AOO_COMPONENTPREFIX'] = platform.getLibraryLayerComponentPrefix(env['AOO_LAYER']) + + env.AddMethod(AddAPI) + env.AddMethod(AddExceptionSharedObjects) + env.AddMethod(AddNoExceptionSharedObjects) + env.AddMethod(AddCxxSharedObjects) + env.AddMethod(SetComponentFile) + + return env + +def AddAPI(env, names): + for name in names: + env.Append(CPPPATH=OUTDIR + '/inc/' + name) + +def AddExceptionSharedObjects(env, names): + return AddCxxSharedObjects(env, names, + platform.getExceptionFlags(soenv, True) + + platform.getCompilerOptFlags(DEBUGLEVEL < 2, DEBUGLEVEL)) + +def AddNoExceptionSharedObjects(env, names): + return AddCxxSharedObjects(env, names, + platform.getExceptionFlags(soenv, False) + + platform.getCompilerOptFlags(DEBUGLEVEL < 2, DEBUGLEVEL)) + +def AddCxxSharedObjects(env, names, flags): + objects = [] + for name in names: + objects.append( + env.SharedObject( + name, + CXXFLAGS = env['CXXFLAGS'] + flags + ) + ) + return objects + +if soenv['SYSTEM_LIBXSLT'] == 'YES': + _XSLTPROC = 'xsltproc' +else: + _XSLTPROC = OUTDIR + '/bin/xsltproc' + +def SetComponentFile(self, library, componentFileBaseName): + env = self + + componentFile = File(componentFileBaseName + '.component') + inbuildComponentFile = File(componentFileBaseName + '.inbuild.component') + + outdirComponentDir = Dir(OUTDIR + '/xml/component/' + componentFile.srcnode().dir.path) + + xsltenv = env.Clone() + xsltenv.Append(ENV = platform.getExecutableEnvironment(soenv)) + finalComponent = xsltenv.Command(componentFile, componentFile.srcnode(), + action = [ + _XSLTPROC + ' --nonet --stringparam uri "' + env['AOO_COMPONENTPREFIX'] + str(library[0]) + '"' + + ' -o $TARGET ' + env['SOLARENV'] + '/bin/createcomponent.xslt $SOURCE' + ] + ) + inbuildComponent = xsltenv.Command(inbuildComponentFile, componentFile.srcnode(), + action = [ + _XSLTPROC + ' --nonet --stringparam uri "' + platform.getLibraryLayerComponentPrefix('NONE') + str(library[0]) + '"' + + ' -o $TARGET ' + env['SOLARENV'] + '/bin/createcomponent.xslt $SOURCE' + ] + ) + + installs = [] + installs += env.Install(outdirComponentDir, finalComponent) + installs += env.Install(outdirComponentDir, inbuildComponent) + return installs