From 05a7af886ce300b08728eff4387f71be3dfa79b6 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 4 Mar 2019 14:20:13 +0100 Subject: [PATCH] Enabling the user to choose the devtoolset it needs. * Change: In boostrap/ccb.py, change the devtoolset argument from a fixed behavior "--devtoolset-2" to a selecting one "--devtoolset=X" where X is the requested version of the devtoolset. Modify coriolisEnv.py to dynamically detect with which devtoolset we have been compiled. Idem for Makefile.package and FindBootstrap.cmake. --- Makefile | 13 +++-- bootstrap/Makefile.package | 13 +++-- bootstrap/builder/Builder.py | 24 ++++---- bootstrap/builder/CompileWidget.py | 16 +++--- bootstrap/builder/OptionsWidget.py | 32 +++++------ bootstrap/ccb.py | 4 +- bootstrap/cmake_modules/FindBootstrap.cmake | 6 +- bootstrap/coriolisEnv.py | 63 +++++++++++---------- bootstrap/socInstaller.py | 8 +-- 9 files changed, 93 insertions(+), 86 deletions(-) diff --git a/Makefile b/Makefile index 8ccdbbb5..c03bfee1 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,16 @@ - UNAME_S = $(shell uname -s) - UNAME_R = $(shell uname -r) + UNAME_S = $(shell uname -s) + UNAME_R = $(shell uname -r) + DEVTOOLSET_VERSION = 7 -# We must use devtoolset-2 only under RHEL6 & clones. +# We must use devtoolset only under RHEL6 & clones. DEVTOOLSET_OPTION = ifeq ($(UNAME_S),Linux) - ifneq ($(findstring .el6.,$(UNAME_R)),) - DEVTOOLSET_OPTION = --devtoolset-2 + ifneq ($(findstring .el7.,$(UNAME_R)),) + DEVTOOLSET_OPTION = --devtoolset=$(DEVTOOLSET_VERSION) endif ifneq ($(findstring .slsoc6.,$(UNAME_R)),) - DEVTOOLSET_OPTION = --devtoolset-2 + DEVTOOLSET_OPTION = --devtoolset=$(DEVTOOLSET_VERSION) endif endif diff --git a/bootstrap/Makefile.package b/bootstrap/Makefile.package index 403a900e..c5dca5a5 100644 --- a/bootstrap/Makefile.package +++ b/bootstrap/Makefile.package @@ -38,12 +38,13 @@ build: FORCE esac; \ case "$${X_SCLS}" in \ *"devtoolset"*) \ - cmakeArgs="$${cmakeArgs} -D Boost_NO_SYSTEM_PATHS:STRING=TRUE"; \ - BOOST_INCLUDEDIR="/opt/rh/devtoolset-2/root/usr/include"; \ - BOOST_LIBRARYDIR="/opt/rh/devtoolset-2/root/usr/lib"; \ - export BOOST_INCLUDEDIR BOOST_LIBRARYDIR; \ - echo "** Using $${X_SCLS}."; \ - ;; \ + version="`echo $${X_SCLS} | sed 's,devtoolset-,,'`"; \ + cmakeArgs="$${cmakeArgs} -D Boost_NO_SYSTEM_PATHS:STRING=TRUE"; \ + BOOST_INCLUDEDIR="/opt/rh/devtoolset-$${version}/root/usr/include"; \ + BOOST_LIBRARYDIR="/opt/rh/devtoolset-$${version}/root/usr/lib"; \ + export BOOST_INCLUDEDIR BOOST_LIBRARYDIR; \ + echo "** Using $${X_SCLS}."; \ + ;; \ esac; \ for tool in $(tools); do \ echo "** Building tool $${tool}"; \ diff --git a/bootstrap/builder/Builder.py b/bootstrap/builder/Builder.py index 0d78e2b5..00f110b8 100644 --- a/bootstrap/builder/Builder.py +++ b/bootstrap/builder/Builder.py @@ -37,7 +37,7 @@ class Builder: self._clang = False self._noSystemBoost = False self._macports = False - self._devtoolset2 = False + self._devtoolset = 0 self._qt5 = False self._openmp = False self._enableShared = "ON" @@ -66,9 +66,9 @@ class Builder: elif attribute == "macports": self._macports = value if value: self._noSystemBoost = True - elif attribute == "devtoolset2": - self._devtoolset2 = value - if value: self._noSystemBoost = True + elif attribute == "devtoolset": + self._devtoolset = value + #if value: self._noSystemBoost = True elif attribute == "qt5": self._qt5 = value elif attribute == "openmp": self._openmp = value elif attribute == "enableDoc": self._enableDoc = value @@ -132,14 +132,14 @@ class Builder: def _execute ( self, command, error ): - if self._devtoolset2 == True: - print 'Using devtoolset-2 (scl enable devtoolset-2 ...)' + if self._devtoolset: + print 'Using devtoolset-%(v)d (scl enable devtoolset-%(v)d ...)' % {'v':self._devtoolset} commandAsString = '' for i in range(len(command)): if i: commandAsString += ' ' if ' ' in command[i]: commandAsString += '"'+command[i]+'"' else: commandAsString += command[i] - command = [ 'scl', 'enable', 'devtoolset-2', commandAsString ] + command = [ 'scl', 'enable', 'devtoolset-%d' % self._devtoolset, commandAsString ] #print command sys.stdout.flush () @@ -295,9 +295,9 @@ class Builder: if self._clang: self._environment[ 'CC' ] = '/usr/bin/clang' self._environment[ 'CXX' ] = '/usr/bin/clang++' - if self._devtoolset2: - self._environment[ 'BOOST_INCLUDEDIR' ] = '/opt/rh/devtoolset-2/root/usr/include' - self._environment[ 'BOOST_LIBRARYDIR' ] = '/opt/rh/devtoolset-2/root/usr/lib' + if self._devtoolset: + self._environment[ 'BOOST_INCLUDEDIR' ] = '/opt/rh/devtoolset-%d/root/usr/include' % self._devtoolset + self._environment[ 'BOOST_LIBRARYDIR' ] = '/opt/rh/devtoolset-%d/root/usr/lib' % self._devtoolset if self._macports: self._environment[ 'BOOST_INCLUDEDIR' ] = '/opt/local/include' self._environment[ 'BOOST_LIBRARYDIR' ] = '/opt/local/lib' @@ -430,8 +430,8 @@ class Builder: , "--define", "_tmppath %s" % self.tmppathDir #, "--define", "_enable_debug_packages 0" , "--with", "binarytar" ] - if self._devtoolset2 == True: - command += [ "--define", "scl devtoolset-2" ] + if self._devtoolset: + command += [ "--define", "scl devtoolset-%d"%self._devtoolset ] command += [ "-ba", "--clean", rpmSpecFile ] self._execute ( command, "Rebuild rpm packages" ) diff --git a/bootstrap/builder/CompileWidget.py b/bootstrap/builder/CompileWidget.py index b5a7e81d..a589e3de 100644 --- a/bootstrap/builder/CompileWidget.py +++ b/bootstrap/builder/CompileWidget.py @@ -139,14 +139,14 @@ class CompileWidget ( QWidget ): if self.conf.rootDir: command += [ '--root=%s'%self.conf.rootDir ] - #if self.options.svnUpdate: command += [ '--svn-update' ] - #if self.options.svnStatus: command += [ '--svn-update' ] - if self.options.enableDoc: command += [ '--doc' ] - if self.options.devtoolset2: command += [ '--devtoolset-2' ] - if self.options.qt5: command += [ '--qt5' ] - if self.options.noCache: command += [ '--no-cache' ] - if self.options.rmBuild: command += [ '--rm-build' ] - if self.options.verbose: command += [ '--verbose' ] + #if self.options.svnUpdate: command += [ '--svn-update' ] + #if self.options.svnStatus: command += [ '--svn-update' ] + if self.options.enableDoc: command += [ '--doc' ] + if self.options.devtoolset: command += [ '--devtoolset-8' ] + if self.options.qt5: command += [ '--qt5' ] + if self.options.noCache: command += [ '--no-cache' ] + if self.options.rmBuild: command += [ '--rm-build' ] + if self.options.verbose: command += [ '--verbose' ] if self.options.make: makeArguments='install '+self.options.threads command += [ '--make=%s'%makeArguments ] diff --git a/bootstrap/builder/OptionsWidget.py b/bootstrap/builder/OptionsWidget.py index eea9759b..7ce71d83 100644 --- a/bootstrap/builder/OptionsWidget.py +++ b/bootstrap/builder/OptionsWidget.py @@ -65,7 +65,7 @@ class OptionsWidget ( QWidget ): #self._svnStatus = QCheckBox( 'SVN Status' ) self._make = QCheckBox( 'Build' ) self._enableDoc = QCheckBox( 'Build Documentation' ) - self._devtoolset2 = QCheckBox( 'Build with devtoolset 2' ) + self._devtoolset = QCheckBox( 'Build with devtoolset 8' ) self._qt5 = QCheckBox( 'Build with Qt 5 (Qt 4 default)' ) self._noCache = QCheckBox( 'Remove previous CMake cache' ) self._rmBuild = QCheckBox( 'Cleanup Build Directory' ) @@ -91,7 +91,7 @@ class OptionsWidget ( QWidget ): vLayout = QVBoxLayout() vLayout.addWidget( self._buildMode ) vLayout.addWidget( self._enableDoc ) - vLayout.addWidget( self._devtoolset2 ) + vLayout.addWidget( self._devtoolset ) vLayout.addWidget( self._qt5 ) vLayout.addWidget( self._noCache ) vLayout.addWidget( self._rmBuild ) @@ -130,7 +130,7 @@ class OptionsWidget ( QWidget ): #def _getSvnStatus ( self ): return self._svnStatus.isChecked() def _getMake ( self ): return self._make.isChecked() def _getEnableDoc ( self ): return self._enableDoc.isChecked() - def _getDevtoolset2 ( self ): return self._devtoolset2.isChecked() + def _getDevtoolset ( self ): return self._devtoolset.isChecked() def _getQt5 ( self ): return self._qt5.isChecked() def _getNoCache ( self ): return self._noCache.isChecked() def _getRmBuild ( self ): return self._rmBuild.isChecked() @@ -143,7 +143,7 @@ class OptionsWidget ( QWidget ): #svnStatus = property( _getSvnStatus ) make = property( _getMake ) enableDoc = property( _getEnableDoc ) - devtoolset2 = property( _getDevtoolset2 ) + devtoolset = property( _getDevtoolset ) qt5 = property( _getQt5 ) noCache = property( _getNoCache ) rmBuild = property( _getRmBuild ) @@ -156,7 +156,7 @@ class OptionsWidget ( QWidget ): #self._svnStatus .setChecked( settings.value('builder/svnStatus').toBool() ) self._make .setChecked( settings.value('builder/make' ).toBool() ) self._enableDoc .setChecked( settings.value('builder/enableDoc').toBool() ) - self._devtoolset2.setChecked( settings.value('builder/devtoolset2').toBool() ) + self._devtoolset .setChecked( settings.value('builder/devtoolset').toBool() ) self._qt5 .setChecked( settings.value('builder/qt5').toBool() ) self._noCache .setChecked( settings.value('builder/noCache' ).toBool() ) self._rmBuild .setChecked( settings.value('builder/rmBuild' ).toBool() ) @@ -176,17 +176,17 @@ class OptionsWidget ( QWidget ): def saveSettings ( self ): settings = QSettings() - #settings.setValue('builder/svnUpdate' , self._svnUpdate .isChecked() ) - #settings.setValue('builder/svnStatus' , self._svnStatus .isChecked() ) - settings.setValue('builder/make' , self._make .isChecked() ) - settings.setValue('builder/enableDoc' , self._enableDoc .isChecked() ) - settings.setValue('builder/devtoolset2', self._devtoolset2.isChecked() ) - settings.setValue('builder/qt5' , self._qt5 .isChecked() ) - settings.setValue('builder/buildMode' , self._buildMode .currentText() ) - settings.setValue('builder/noCache' , self._noCache .isChecked() ) - settings.setValue('builder/rmBuild' , self._rmBuild .isChecked() ) - settings.setValue('builder/verbose' , self._verbose .isChecked() ) - settings.setValue('builder/threads' , self._threads .currentText() ) + #settings.setValue('builder/svnUpdate' , self._svnUpdate .isChecked() ) + #settings.setValue('builder/svnStatus' , self._svnStatus .isChecked() ) + settings.setValue('builder/make' , self._make .isChecked() ) + settings.setValue('builder/enableDoc' , self._enableDoc .isChecked() ) + settings.setValue('builder/devtoolset', self._devtoolset.isChecked() ) + settings.setValue('builder/qt5' , self._qt5 .isChecked() ) + settings.setValue('builder/buildMode' , self._buildMode .currentText() ) + settings.setValue('builder/noCache' , self._noCache .isChecked() ) + settings.setValue('builder/rmBuild' , self._rmBuild .isChecked() ) + settings.setValue('builder/verbose' , self._verbose .isChecked() ) + settings.setValue('builder/threads' , self._threads .currentText() ) for project in self._projects: project.saveToSettings() return diff --git a/bootstrap/ccb.py b/bootstrap/ccb.py index 45faceb8..db7f2223 100755 --- a/bootstrap/ccb.py +++ b/bootstrap/ccb.py @@ -208,7 +208,7 @@ parser.add_option ( "--no-build" , action="store_true" , parser.add_option ( "--no-cache" , action="store_true" , dest="noCache" , help="Remove previous CMake cache before building." ) parser.add_option ( "--rm-build" , action="store_true" , dest="rmBuild" , help="Remove previous build directoty before building." ) parser.add_option ( "--macports" , action="store_true" , dest="macports" , help="Build against MacPorts." ) -parser.add_option ( "--devtoolset-2" , action="store_true" , dest="devtoolset2" , help="Build against TUV Dev Toolset 2." ) +parser.add_option ( "--devtoolset" , action="store" , type="int" , dest="devtoolset" , help="Build against TUV Dev Toolset 8." ) parser.add_option ( "--qt5" , action="store_true" , dest="qt5" , help="Build against Qt 5 (default: Qt 4)." ) parser.add_option ( "--openmp" , action="store_true" , dest="openmp" , help="Enable the use of OpenMP in Gcc." ) parser.add_option ( "--ninja" , action="store_true" , dest="ninja" , help="Use Ninja instead of UNIX Makefile." ) @@ -286,7 +286,7 @@ else: if options.ninja: builder.ninja = True if options.clang: builder.clang = True if options.macports: builder.macports = True - if options.devtoolset2: builder.devtoolset2 = True + if options.devtoolset: builder.devtoolset = options.devtoolset if options.qt5: builder.qt5 = True if options.openmp: builder.openmp = True if options.makeArguments: builder.makeArguments = options.makeArguments diff --git a/bootstrap/cmake_modules/FindBootstrap.cmake b/bootstrap/cmake_modules/FindBootstrap.cmake index a716172c..5720a67d 100644 --- a/bootstrap/cmake_modules/FindBootstrap.cmake +++ b/bootstrap/cmake_modules/FindBootstrap.cmake @@ -294,10 +294,10 @@ # macro(setup_sysconfdir INSTALLDIR) message("-- Checking installation directory <${INSTALLDIR}>") - string(REGEX MATCH "^/opt/rh/devtoolset-2/root/usr$" IS_OPT_RH ${INSTALLDIR}) + string(REGEX MATCH "^/opt/rh/devtoolset-[0-9]+/root" IS_OPT_RH ${INSTALLDIR}) if(IS_OPT_RH) - message("-- Using devtoolset-2 install tree /opt/rh/devtoolset-2/root/etc.") - set(SYS_CONF_DIR "/opt/rh/devtoolset-2/root/etc" CACHE STRING "System configuration directory (/etc)" FORCE) + message("-- Using devtoolset-X install tree ${IS_OPT_RH}/etc.") + set(SYS_CONF_DIR ${IS_OPT_RH} CACHE STRING "System configuration directory (/etc)" FORCE) else() string(REGEX MATCH "^/usr$" IS_USR ${INSTALLDIR}) string(REGEX MATCH "^/opt$" IS_OPT ${INSTALLDIR}) diff --git a/bootstrap/coriolisEnv.py b/bootstrap/coriolisEnv.py index 037e09f0..f0ab9b89 100755 --- a/bootstrap/coriolisEnv.py +++ b/bootstrap/coriolisEnv.py @@ -41,7 +41,7 @@ def scrubPath ( pathName ): def guessOs (): - useDevtoolset2 = False + useDevtoolset = False osSlsoc7x_64 = re.compile (".*Linux.*el7.*x86_64.*") osSlsoc6x_64 = re.compile (".*Linux.*el6.*x86_64.*") osSlsoc6x = re.compile (".*Linux.*(el|slsoc)6.*") @@ -74,10 +74,10 @@ def guessOs (): elif osSlsoc6x_64.match(lines[0]): osType = "Linux.slsoc6x_64" libDir = "lib64" - useDevtoolset2 = True + useDevtoolset = True elif osSlsoc6x.match(lines[0]): osType = "Linux.slsoc6x" - useDevtoolset2 = True + useDevtoolset = True elif osSLSoC5x_64.match(lines[0]): osType = "Linux.SLSoC5x_64" libDir = "lib64" @@ -132,12 +132,12 @@ def guessOs (): print " (using: \"%s\")" % osType ldLibraryPath = os.getenv('LD_LIBRARY_PATH') - if ldLibraryPath and 'devtoolset' in ldLibraryPath: useDevtoolset2 = False + if ldLibraryPath and 'devtoolset' in ldLibraryPath: useDevtoolset = False if libDir == 'lib64' and not os.path.exists('/usr/lib64'): libDir = 'lib' - return (osType,libDir,useDevtoolset2) + return (osType,libDir,useDevtoolset) def guessShell (): @@ -170,7 +170,7 @@ def guessShell (): if __name__ == "__main__": - osType,libDir,useDevtoolset2 = guessOs() + osType,libDir,useDevtoolset = guessOs() buildType = "Release" linkType = "Shared" rootDir = None @@ -226,6 +226,8 @@ if __name__ == "__main__": # 'setenv STRATUS_MAPPING_NAME "%(SYSCONF_DIR)s/stratus2sxlib.xml";' \ + reDevtoolset = re.compile( r'/opt/rh/devtoolset-(?P\d+)/root/etc/coriolis2.*' ) + buildDir = buildType + "." + linkType scriptDir = os.path.dirname ( os.path.abspath(__file__) ) #print "echo \"Script Location: %s\";" % scriptDir, @@ -233,26 +235,29 @@ if __name__ == "__main__": coriolisTop = "/usr" sysconfDir = scriptDir shellMessage = "Using system-wide Coriolis 2 (/usr)" - elif scriptDir.startswith("/opt/rh/devtoolset-2/root/etc/coriolis2"): - coriolisTop = "/opt/rh/devtoolset-2/root/usr" - sysconfDir = scriptDir - shellMessage = "Using system-wide devtoolset-2 Coriolis 2 (/opt/rh/devtoolset-2/root/usr)" - elif scriptDir.startswith(os.getenv("HOME")+"/nightly/coriolis-2.x/"): - rootDir = os.getenv("HOME") + "/nightly/coriolis-2.x" - coriolisTop = "%s/%s/%s/install" % ( rootDir, osType, buildDir ) - sysconfDir = scriptDir - shellMessage = "Using Nightly build Coriolis 2 (%s)" % coriolisTop - elif scriptDir.startswith("/users/outil/coriolis/coriolis-2.x/") \ - or scriptDir.startswith("/soc/coriolis2/"): - coriolisTop = "/soc/coriolis2" - sysconfDir = coriolisTop + "/etc/coriolis2" - shellMessage = "Using SoC network-wide Coriolis 2 (/soc/coriolis2)" - else: - if not rootDir: - rootDir = os.getenv("HOME") + "/coriolis-2.x" - coriolisTop = "%s/%s/%s/install" % ( rootDir, osType, buildDir ) - sysconfDir = coriolisTop + "/etc/coriolis2" - shellMessage = "Using user-selected Coriolis 2 (%s)" % rootDir + else + m = reDevtoolset.match( scriptDir ) + if m: + coriolisTop = "/opt/rh/devtoolset-%d/root/usr" % m.group('version') + sysconfDir = scriptDir + shellMessage = "Using system-wide devtoolset-%(v)d Coriolis 2 (/opt/rh/devtoolset-%(v)d/root/usr)" \ + { 'v':m.group('version') } + elif scriptDir.startswith(os.getenv("HOME")+"/nightly/coriolis-2.x/"): + rootDir = os.getenv("HOME") + "/nightly/coriolis-2.x" + coriolisTop = "%s/%s/%s/install" % ( rootDir, osType, buildDir ) + sysconfDir = scriptDir + shellMessage = "Using Nightly build Coriolis 2 (%s)" % coriolisTop + elif scriptDir.startswith("/users/outil/coriolis/coriolis-2.x/") \ + or scriptDir.startswith("/soc/coriolis2/"): + coriolisTop = "/soc/coriolis2" + sysconfDir = coriolisTop + "/etc/coriolis2" + shellMessage = "Using SoC network-wide Coriolis 2 (/soc/coriolis2)" + else: + if not rootDir: + rootDir = os.getenv("HOME") + "/coriolis-2.x" + coriolisTop = "%s/%s/%s/install" % ( rootDir, osType, buildDir ) + sysconfDir = coriolisTop + "/etc/coriolis2" + shellMessage = "Using user-selected Coriolis 2 (%s)" % rootDir if osType.startswith("Cygwin"): strippedPath = "%s/%s:%s" % ( coriolisTop, libDir, strippedPath ) @@ -304,10 +309,10 @@ if __name__ == "__main__": if isBourneShell: shellScript = shellScriptSh else: shellScript = shellScriptCsh - if useDevtoolset2: + if useDevtoolset: shellScript += \ - ' echo "Launching a devtoolset-2 subshell though scl (CTRL+D to exit).";' \ - ' scl enable devtoolset-2 %(SHELL)s' + ' echo "Launching a devtoolset-8 subshell though scl (CTRL+D to exit).";' \ + ' scl enable devtoolset-8 %(SHELL)s' evalScript = shellScript % { "PATH" : strippedPath , "LD_LIBRARY_PATH" : strippedLibraryPath diff --git a/bootstrap/socInstaller.py b/bootstrap/socInstaller.py index 9ef2bbd3..11ba8ae0 100755 --- a/bootstrap/socInstaller.py +++ b/bootstrap/socInstaller.py @@ -499,11 +499,11 @@ try: [ ( conf.targets['SL7_64'], buildCommand % (3,conf.debugArg) , conf.fds['build' ] ) , ( conf.targets['SL7_64'], buildCommand % (1,conf.debugArg+' --doc') , conf.fds['build' ] ) , ( conf.targets['SL7_64'], benchsCommand , conf.fds['benchs'] ) - , ( conf.targets['SL6_64'], buildCommand % (6,conf.debugArg+' --devtoolset-2') , conf.fds['build' ] ) - , ( conf.targets['SL6_64'], buildCommand % (1,conf.debugArg+' --devtoolset-2 --doc'), conf.fds['build' ] ) + , ( conf.targets['SL6_64'], buildCommand % (6,conf.debugArg+' --devtoolset-8') , conf.fds['build' ] ) + , ( conf.targets['SL6_64'], buildCommand % (1,conf.debugArg+' --devtoolset-8 --doc'), conf.fds['build' ] ) , ( conf.targets['SL6_64'], benchsCommand , conf.fds['benchs'] ) - , ( conf.targets['SL6'] , buildCommand % (2,conf.debugArg+' --devtoolset-2') , conf.fds['build' ] ) - , ( conf.targets['SL6'] , buildCommand % (1,conf.debugArg+' --devtoolset-2 --doc'), conf.fds['build' ] ) + , ( conf.targets['SL6'] , buildCommand % (2,conf.debugArg+' --devtoolset-8') , conf.fds['build' ] ) + , ( conf.targets['SL6'] , buildCommand % (1,conf.debugArg+' --devtoolset-8 --doc'), conf.fds['build' ] ) , ( conf.targets['SL6'] , benchsCommand , conf.fds['benchs'] ) ]