def MakeSourceDist(package, baseEnv = None): """ Sets up the distribution build of a source tar.gz for the given package. This will put all the required source and extra distribution files into a compressed tarball. If an environment is specified, it is copied and the copy is used. """ # Clone the base environment if we have one if baseEnv: env = baseEnv.Clone() else: env = Environment() # Create the distribution filename dist_filename = '%s-%d.%d.%d.tar.gz' % (package.getName(), package.getVersionMajor(), package.getVersionMinor(), package.getVersionPatch()) # Add the tar.gz builder to the environment _CreateSourceTarGzBuilder(env) # Get a list of the sources that will be included in the distribution dist_files = [] for a in package.getAssemblies(): dist_files.extend(map(lambda n: n.getFileNode(), a.getHeaders())) dist_files.extend(a.getSources()) dist_files.extend(package.getExtraDist()) # Setup the build of the distribution env.SourceTarGz(dist_filename, dist_files) # Mark implicit dependencies on all the files that will be distributed env.Depends(dist_filename, dist_files)
class mayaPythonPlugin: def __init__ ( self, args, version='1.0.0', mayaVersion=pipe.apps.version.get("maya"), env=None, prefix=None, src=[], sed=[] ): self.args = args self.version = version self.src = src self.installPath = os.path.join(central('tools', args), 'maya', mayaVersion,'plugins') self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) def finalize(self): # build intermediate source registerSedBuilder(self.env, self.sed) src=[] for each in self.src: semSuffix = each.strip(os.path.sep).split(os.path.sep) new = os.path.join( buildFolder(self.args), os.path.sep.join( semSuffix[1:]) ) self.env.sedBuilder( new, each) src.append(new) # install install = [] for each in src: name = os.path.splitext(os.path.basename(each))[0] semSuffix = each.strip(os.path.sep).split(os.path.sep) self.env.Alias( 'install', self.env.InstallAs( os.path.join(self.installPath, os.path.sep.join( semSuffix[1:])), each) )
class msl: def __init__ ( self, args, version='1.0.0', versionControled=False, env=None, prefix=None, src=[], sed=[] ): self.args = args self.version = version self.src = src self.installPath = os.path.join( central('tools',args,prefix=prefix), 'shaders','3delight' ) if versionControled: self.installPath = os.path.join(self.installPath, name, self.version) self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) def finalize(self): # build intermediate source registerSedBuilder(self.env, self.sed) src=[] for each in self.src: new = os.path.join(buildFolder(self.args), os.path.basename(each)) self.env.sedBuilder( new, each) src.append(new) # install install = [] for each in src: name = os.path.splitext(os.path.basename(each))[0] install.append( self.env.Install( self.installPath, each) ) self.env.Alias( 'install', install )
def __init__(self, name, version, prefix='/usr/local', baseEnv = None, description= None): """ Creates a new package with the given name and version, where version is in the form of <major>.<minor>.<patch> (e.g 1.12.0) """ self.name = name self.prefix = prefix self.assemblies = [] self.fileBundles = [FileBundle(),] # File bundle for all files self.extra_dist = [] self.description = description self.packagers = [] self.distDir = "dist" # Path to the dist directory to use if not self.description: self.description = self.name + " Package" if baseEnv: self.env = baseEnv.Clone() else: self.env = Environment() if type(version) is types.TupleType: (self.version_major, self.version_minor, self.version_patch) = version; else: re_matches = re.match(r'^(\d+)\.(\d+)\.(\d+)$', version) self.version_major = int(re_matches.group(1)) self.version_minor = int(re_matches.group(2)) self.version_patch = int(re_matches.group(3))
def __init__(self, name, modern=True, paranoid=True, colorful=True, succinct=True, **kwargs): super(Environment, self).__init__(**self._append_custom_tools(kwargs)) self.SetDefault(NAME=name) self.SetDefault(LOGGER=logging.getLogger(name)) self.SetDefault(BUILD_ROOT=self.Dir('#build')) self.SetDefault(LIB_ROOT=self.Dir('#lib')) self.SetDefault(SRC_ROOT=self.Dir('#src')) self.SetDefault(TEST_ROOT=self.Dir('#test')) self.SetDefault(INCLUDE_ROOT=self.Dir('#include')) # Allow same directory includes. self.AppendUnique(CPPPATH=['.']) self['CC'] = self.Detect(['clang', 'gcc']) self['CXX'] = self.Detect(['clang++', 'g++']) self['LINK'] = self.Detect(['clang++', 'clang', 'ld']) # Modern C/C++ if modern: self.AppendUnique(CFLAGS=['-std=c99']) self.AppendUnique(CXXFLAGS=['-std=c++11']) # Paranoid C/C++ if paranoid: self.AppendUnique(CCFLAGS=['-Wall', '-Wextra', '-pedantic']) # Colorful C/C++ if colorful and sys.stdout.isatty(): if 'clang' in self['CC'] or 'clang' in self['CXX']: self.AppendUnique(CCFLAGS=['-fcolor-diagnostics']) elif 'gcc' in self['CC'] or 'g++' in self['CXX']: # TODO: Also set a GCC_COLORS variable in the system environment? self.AppendUnique(CCFLAGS=['-fdiagnostics-color=always']) # Pretty printing self.SetDefault(ARCOMSTR=Environment._comstr('Archiving', succinct)) self.SetDefault(ASCOMSTR=Environment._comstr('Assembling', succinct)) self.SetDefault(ASPPCOMSTR=Environment._comstr('Assembling', succinct)) self.SetDefault(CCCOMSTR=Environment._comstr('Building (C)', succinct)) self.SetDefault( CXXCOMSTR=Environment._comstr('Building (C++)', succinct)) self.SetDefault(LINKCOMSTR=Environment._comstr('Linking', succinct)) self.SetDefault(RANLIBCOMSTR=Environment._comstr('Indexing', succinct)) self.SetDefault( SHCCCOMSTR=Environment._comstr('Building (C, Shared)', succinct)) self.SetDefault(SHCXXCOMSTR=Environment._comstr( 'Building (C++, Shared)', succinct)) self.SetDefault( SHLINKCOMSTR=Environment._comstr('Linking (Shared)', succinct))
class pythonModule: def __init__ ( self, args, name, version='1.0.0', env=None, pythonVersion='2.5', src=[{'path':'','installPath':''}], installPrefix=None, sed=[] ): self.name = name self.args = args self.version = version self.pythonVersion = pythonVersion self.src = src if not installPrefix: self.installPath = installRoot(self.args) else: self.installPath = installPrefix self.env=env if self.env==None: self.env = Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) @staticmethod def pythonModuleBuilder( target, source, env): target=str(target[0]) source=str(source[0]) sed = filter(lambda x:x[0]=='pythonModuleSED', env.items())[0][1] installDir = os.path.dirname(target) if not os.path.exists(installDir): env.Execute( Mkdir(installDir) ) os.makedirs(installDir) cmd = 'sed "%s" %s > %s' % ( ';'.join(sed), source, target ) #print '\t', cmd os.system( cmd ) def finalize(self): bld = Builder(action = pythonModule.pythonModuleBuilder) self.env.Append(pythonModuleSED=self.sed) self.env.Append(BUILDERS = {'pythonModuleBuilder' : bld}) installPath = os.path.join( self.installPath, 'python', self.pythonVersion, self.name ) install=[] for each in self.src: if type(each) == dict: each = each['path'] p = each.split(os.path.sep) if len(p)>1: del p[0] target = os.path.join( buildFolder(self.args) , os.path.sep.join(p) ) self.env.pythonModuleBuilder( target, each ) install.append( self.env.Install( os.path.join(installPath, os.path.sep.join(os.path.dirname(target).split(os.path.sep)[1:]) ) , target ) ) self.env.Alias( 'install', install)
def __init__(self, name, modern=True, paranoid=True, colorful=True, succinct=True, **kwargs): super(Environment, self).__init__(**self._append_custom_tools(kwargs)) self.SetDefault(NAME=name) self.SetDefault(LOGGER=logging.getLogger(name)) self.SetDefault(BUILD_ROOT=self.Dir('#build')) self.SetDefault(LIB_ROOT=self.Dir('#lib')) self.SetDefault(SRC_ROOT=self.Dir('#src')) self.SetDefault(TEST_ROOT=self.Dir('#test')) self.SetDefault(INCLUDE_ROOT=self.Dir('#include')) # Allow same directory includes. self.AppendUnique(CPPPATH=['.']) self['CC'] = self.Detect(['clang', 'gcc']) self['CXX'] = self.Detect(['clang++', 'g++']) self['LINK'] = self.Detect(['clang++', 'clang', 'ld']) # Modern C/C++ if modern: self.AppendUnique(CFLAGS=['-std=c99']) self.AppendUnique(CXXFLAGS=['-std=c++11']) # Paranoid C/C++ if paranoid: self.AppendUnique(CCFLAGS=['-Wall', '-Wextra', '-pedantic']) # Colorful C/C++ if colorful and sys.stdout.isatty(): if 'clang' in self['CC'] or 'clang' in self['CXX']: self.AppendUnique(CCFLAGS=['-fcolor-diagnostics']) elif 'gcc' in self['CC'] or 'g++' in self['CXX']: # TODO: Also set a GCC_COLORS variable in the system environment? self.AppendUnique(CCFLAGS=['-fdiagnostics-color=always']) # Pretty printing self.SetDefault(ARCOMSTR=Environment._comstr('Archiving', succinct)) self.SetDefault(ASCOMSTR=Environment._comstr('Assembling', succinct)) self.SetDefault(ASPPCOMSTR=Environment._comstr('Assembling', succinct)) self.SetDefault(CCCOMSTR=Environment._comstr('Building (C)', succinct)) self.SetDefault(CXXCOMSTR=Environment._comstr('Building (C++)', succinct)) self.SetDefault(LINKCOMSTR=Environment._comstr('Linking', succinct)) self.SetDefault(RANLIBCOMSTR=Environment._comstr('Indexing', succinct)) self.SetDefault(SHCCCOMSTR=Environment._comstr('Building (C, Shared)', succinct)) self.SetDefault(SHCXXCOMSTR=Environment._comstr('Building (C++, Shared)', succinct)) self.SetDefault(SHLINKCOMSTR=Environment._comstr('Linking (Shared)', succinct))
def init(src_dir): global env, opts env = Environment(tools=['default', 'textfile', 'pymod']) _initOptions() _initLog() log.info("Adding general build information to scons environment") opts = SCons.Script.Variables("custom.py") opts.AddVariables( PathVariable('build_dir', 'Qserv build dir', os.path.join( src_dir, 'build'), PathVariable.PathIsDirCreate), ('PYTHONPATH', 'pythonpath', os.getenv("PYTHONPATH")), # Default to in-place install PathVariable('prefix', 'qserv install dir', src_dir, PathVariable.PathIsDirCreate), ('CXX', 'Choose the C++ compiler to use', env['CXX']) ) opts.Update(env) if not log.verbose: env['CCCOMSTR'] = env['CXXCOMSTR'] = "Compiling static object $TARGET" env['LINKCOMSTR'] = "Linking static object $TARGET" env['SHCCCOMSTR'] = env['SHCXXCOMSTR'] = "Compiling shared object $TARGET" env['SHLINKCOMSTR'] = "Linking shared object $TARGET" env['PROTOC_COMSTR'] = "Running protoc on $SOURCE" env['ANTLR_COMSTR'] = "Running antlr on $SOURCE"
def __init__ ( self, args, version='1.0.0', dlpath=DELIGHT, include=DL_SHADER_PATH, options='', #versionControled=os.environ.has_key('PIPE_DEP'), versionControled=False, env=None, prefix=None, src=[], sed=[] ): self.args = args self.version = version self.dlpath = os.popen('eval echo "%s"' % dlpath).readlines()[0].strip() if not dlpath: raise Exception("cant find 3delight. Set DELIGHT to the 3delight install path") self.include = os.popen('eval echo "%s"' % include).readlines()[0].strip() self.options = options self.src = src self.installPath = os.path.join( central('tools',args,prefix=prefix), 'shaders', '3delight' ) if versionControled: self.installPath = os.path.join(self.installPath, name, self.version) self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) self.env.Append(include=self.include) self.env.Append(dlpath=self.dlpath) self.env.Append(options=self.options)
def __init__(self, ctx): import SCons.Node import SCons.Defaults import SCons.Script ctx.buildSystem = self self.defaultEnv = SCons.Defaults._default_env = Environment(ctx) self.processInvocationOptions(ctx)
def __init__ ( self, args, src=[], target=None,sed=[] ): self.args = args self.version = version self.src = src # if source is a tuple, [0] is source and [1] target name in the ftp self.target = target self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) )
def initVars(self, obj=None): if obj: self.env = obj.env else: try: self.env.vars = {} except: self.env = Environment.Environment() self.env.vars = {}
def createQtEnvironment(qtdir=None, env=None): if not env: env = Environment.Environment(tools=['default']) if not qtdir: qtdir = detectLatestQtVersion() env['QT4DIR'] = qtdir if sys.platform.startswith("linux"): env['ENV']['PKG_CONFIG_PATH'] = detectPkgconfigPath(qtdir) env.Tool('qt4') return env
def __init__ ( self, args, version='1.0.0', mayaVersion=pipe.apps.version.get("maya"), env=None, prefix=None, src=[], sed=[] ): self.args = args self.version = version self.src = src self.installPath = os.path.join(central('tools', args), 'maya', mayaVersion,'plugins') self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) )
class ftp: def __init__ ( self, args, src=[], target=None,sed=[] ): self.args = args self.version = version self.src = src # if source is a tuple, [0] is source and [1] target name in the ftp self.target = target self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) @staticmethod def ftpInstaller( target, source, env): import ftpRsync target=str(target[0]) source=str(source[0]) ftpRsync.rsync(source, target.replace('ftp:/','ftp://')) os.system('rm -rf "ftp:"') def finalize(self): # build intermediate source bld = Builder(action = ftp.ftpInstaller) self.env.Append(BUILDERS = {'ftpInstaller' : bld}) registerSedBuilder(self.env, self.sed) src=[] for each in self.src: if type(each)==type(()): target = each[1] each = each[0] else: target = each new = os.path.join(buildFolder(self.args), os.path.basename(target)) self.env.sedBuilder( new, each) src.append(new) # install for each in src: inst = "%s/%s" % (self.target,os.path.basename(each)) self.env.Alias( 'install', self.env.ftpInstaller( inst, each ) )
def buildInstall(self, env=None, installPrefix="", ignoreBuilt=False): """ Calls install builder to setup the installation of the packaged files. Installs all files using the env environment under prefix. NOTE: file is installed into: installPrefix/bundle.prefix/passed_prefix/file.prefix/file.name NOTE: Whatever the current directly is when this is called is the directory used for the builder command associated with this assembly. Returns list of the Install() targets. ifgnoreBuilt - If true, just rebuild for the given environment and don't test/set the built flag. """ if not ignoreBuilt: assert not self.built self.built = True # Clone the base environment if we have one if env: env = env.Clone() else: env = Environment() ret_targets = [] # Install the files from the bundle common_prefix = pj(installPrefix, self.bundlePrefix) name = common_prefix if hasattr(self,"name"): name = self.name #print "FileBundle-[%s]: buildInstall: "%name for f in self.files: fnode = f.getFileNode() target_dir = path.join(installPrefix, self.bundlePrefix, f.getPrefix()) #print " file:[%s] --> target dir: [%s]"%(str(fnode),target_dir) inst_tgt = env.Install(target_dir, fnode) ret_targets.append(inst_tgt) return ret_targets
def __init__ ( self, args, version='1.0.0', versionControled=False, env=None, prefix=None, src=[], sed=[] ): self.args = args self.version = version self.src = src self.installPath = os.path.join( central('tools',args,prefix=prefix), 'shaders','3delight' ) if versionControled: self.installPath = os.path.join(self.installPath, name, self.version) self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) )
def __init__(self, mainEnv, configuration_name='default'): """ Applies the definitions in configuration_name to generate a correct environment (specificall the set of compilation flags() for the TinySTM library. That environment is returned """ SCons.Environment.Environment.__init__(self) # Generate build directives mnemosyneDirectives = helper.Directives( configuration_name, 'mnemosyne', ARGUMENTS, self._mnemosyne_boolean_directive_vars, self._mnemosyne_enumerable_directive_vars, self._mnemosyne_numerical_directive_vars) configuration_variables = Environment._GetConfigurationVariables(self) configuration_variables.Update(self) self.Append( CPPDEFINES=mnemosyneDirectives.getPreprocessorDefinitions()) # Disable some remark messages when using Intel CC # We don't use ICC anymore but GCC only. if mainEnv is not None and mainEnv['CC'] == 'icc': DISABLE_WARNINGS = [ '-wd869', #remark #869 : parameter "XYZ" was never referenced ] self.Append(CCFLAGS=string.join(DISABLE_WARNINGS, ' ')) # Inherit some command line options from the main environment if mainEnv is not None: self['BUILD_LINKAGE'] = mainEnv['BUILD_LINKAGE'] self['BUILD_DEBUG'] = mainEnv['BUILD_DEBUG'] self['BUILD_STATS'] = mainEnv['BUILD_STATS'] self['MY_ROOT_DIR'] = mainEnv['MY_ROOT_DIR'] self['MY_LINKER_DIR'] = mainEnv['MY_LINKER_DIR'] self['CC'] = mainEnv['CC'] self['CXX'] = mainEnv['CXX'] if mainEnv is not None and mainEnv['VERBOSE'] == False: self.Replace(CCCOMSTR='(COMPILE) $SOURCES', CXXCOMSTR='(COMPILE) $SOURCES', SHCXXCOMSTR='(COMPILE) $SOURCES', SHCCCOMSTR='(COMPILE) $SOURCES', ASPPCOMSTR='(ASSEMBLE) $SOURCES', ARCOMSTR='(BUILD) $TARGET', RANLIBCOMSTR='(INDEX) $TARGET', LINKCOMSTR='(LINK) $TARGET', SHLINKCOMSTR='(LINK) $TARGET')
def __init__(self, pkg, baseEnv, prefix=""): """ Constructs a new Assembly object with the given name within the given environment. """ self.package = pkg # The package object we belong to self.built = False; # Flag set once we have been built self.installPrefix = prefix; # Default install prefix # Clone the base environment if we have one if baseEnv: self.env = baseEnv.Clone() else: self.env = Environment()
def __init__ ( self, args, name, version='1.0.0', env=None, pythonVersion='2.5', src=[{'path':'','installPath':''}], installPrefix=None, sed=[] ): self.name = name self.args = args self.version = version self.pythonVersion = pythonVersion self.src = src if not installPrefix: self.installPath = installRoot(self.args) else: self.installPath = installPrefix self.env=env if self.env==None: self.env = Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) )
def __init__(self, le=None, path=[], fileDirInput="input", fileDirOutput=".", fileDirTmp=".", fileDirSrc="src"): self.lenv = le if le else e.Environment() for p in path: self.lenv.PrependENVPath('PATH', p) self.fileDirInput = fileDirInput self.fileDirOutput = fileDirOutput self.fileDirTmp = fileDirTmp self.fileDirSrc = fileDirSrc import subprocess as sb
def __init__ ( self, args, name, version='1.0.0', mayaVersion = pipe.apps.version.get("maya"), env=None, src=[], sed=[], libs=[], includes=[], libPath=[], includePath=[] ): self.name = name self.args = args self.version = version self.src = src self.installPath = os.path.join( central('tools',args), 'maya', mayaVersion ) self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) self.libs=libs self.includes=includes self.libPath = libPath self.includePath = includePath
def __init__(self, prodname=os.getenv("RIM_PRODUCT"), branchname=os.getenv("RIM_BRANCH")): env = Environment.Environment() env.vars = {} self.rim = Rim.Rim(env, Rim.Rim.Shared) appFile = "%s/App.xml" % os.path.dirname(__file__) appNode = xml.dom.minidom.parse(appFile).getElementsByTagName( 'application')[0] self.conf = RimApp.RimApp(appNode, self.rim, quiet=1) self.conf.branches = self.conf.rim.branches self.product = self.conf.products[prodname] self.branch = self.conf.branches[branchname] self.branchName = branchname # verify that product and branch are compatible self.allComps(self.compScsIsInBranch)
def __init__(self, name, baseEnv): """ Constructs a new Assembly object with the given name within the given environment. """ self.data = {} self.data['name'] = File(name) self.data['sources'] = [] self.data['includes'] = [] self.data['libs'] = [] self.data['libpaths'] = [] self.data['headers'] = [] self.data['installed'] = [] # Clone the base environment if we have one if baseEnv: self.data['env'] = baseEnv.Clone() else: self.data['env'] = Environment()
def CreateEnvironment(vars): # add a variable to handle RELEASE/DEBUG mode vars.Add( EnumVariable('mode', 'Release versus debug mode', 'debug', allowed_values=('release', 'debug'))) # add a variable to handle warnings vars.Add(BoolVariable('Wall', 'Enable all compilation warnings', 1)) # shared or static libraries libraryDefault = 'shared' vars.Add( EnumVariable('library', 'Build shared or static library', libraryDefault, allowed_values=('shared', 'static'))) # add a variable to treat warnings as errors vars.Add(BoolVariable('Werror', 'Treat warnings as errors', 1)) # add a variable to determine the install path default_install_path = '/usr/local' if 'LIBCUXX_INSTALL_PATH' in os.environ: default_install_path = os.environ['LIBCUXX_INSTALL_PATH'] vars.Add( PathVariable('install_path', 'The libcuxx install path', default_install_path, PathVariable.PathIsDirCreate)) vars.Add( BoolVariable( 'install', 'Include libcuxx install path in default ' 'targets that will be built and configure to install in the ' 'install_path (defaults to false unless one of the targets is ' '"install")', 0)) # create an Environment env = Environment(ENV = importEnvironment(), \ tools = getTools(), variables = vars) updateEnvironment(env) # set the version env.Replace(VERSION=getVersion("0.1")) # always link with the c++ compiler if os.name != 'nt': env['LINK'] = env['CXX'] # get C compiler switches env.AppendUnique(CFLAGS = getCFLAGS(env['mode'], env['Wall'], \ env['Werror'], env.subst('$CC'))) # get CXX compiler switches env.AppendUnique(CXXFLAGS = getCXXFLAGS(env['mode'], env['Wall'], \ env['Werror'], env.subst('$CXX'))) # get linker switches env.AppendUnique(LINKFLAGS=getLINKFLAGS(env['mode'], env.subst('$LINK'))) # Install paths if env['install']: env.Replace(INSTALL_PATH=os.path.abspath(env['install_path'])) else: env.Replace(INSTALL_PATH=os.path.abspath('.')) # set the build path env.Replace(BUILD_ROOT=str(env.Dir('.'))) env.Replace(CPPPATH=[env['BUILD_ROOT']]) # get libc++ if env['CXX'] == 'c++': env.AppendUnique(CPPPATH=[getLibCXXPaths()[0]]) # set extra libs env.Replace(EXTRA_LIBS=getExtraLibs()) # set libcuxx include path env.AppendUnique(LIBPATH=os.path.abspath('.')) # we need librt on linux if sys.platform == 'linux2': env.AppendUnique(EXTRA_LIBS=['-lrt']) # we need libdl on max and linux if os.name != 'nt': env.AppendUnique(EXTRA_LIBS=['-ldl']) # generate help text Help(vars.GenerateHelpText(env)) return env
class mayaPlugin: def __init__ ( self, args, name, version='1.0.0', mayaVersion = pipe.apps.version.get("maya"), env=None, src=[], sed=[], libs=[], includes=[], libPath=[], includePath=[] ): self.name = name self.args = args self.version = version self.src = src self.installPath = os.path.join( central('tools',args), 'maya', mayaVersion ) self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) self.libs=libs self.includes=includes self.libPath = libPath self.includePath = includePath def finalize(self): # find maya path maya = pipe.apps.maya().path() # add default include/lib paths self.env.Append(CPPPATH=[ buildFolder(), './include', os.path.join(maya, 'include'), ]) self.env.Append(CPPPATH=self.includePath) self.env.Append(LIBPATH=[os.path.join(maya, 'lib')]) self.env.Append(LIBPATH=self.libPath) self.env.Append(LIBS=[ 'OpenMaya', 'Foundation', ]) self.env.Append(LIBS=self.libs) self.env.Append(CPPFLAGS=[ '-DOSMac_', '-DMAC_PLUGIN', '-D_BOOL', '-DREQUIRE_IOSTREAM', '-DIE_MAJOR_VERSION=%s' % self.version.split('.')[0], '-DIE_MINOR_VERSION=%s' % self.version.split('.')[1], '-DIE_PATCH_VERSION=%s' % self.version.split('.')[2], ]) self.env.Append(LINKFLAGS=[ # '-bundle', ]) if pipe.platform=='darwin': self.env.Append(CPPPATH=[ '/System/Library/Frameworks/AGL.framework/Versions/A/Headers', '/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers', ]) # build intermediate source registerSedBuilder(self.env, self.sed) src=[] for each in self.src: new = os.path.join(buildFolder(self.args), os.path.basename(each)) self.env.sedBuilder( new, each) src.append(new) # build it for real! plugin = self.env.SharedLibrary(self.name+'.'+self.version, src) self.env.Clean(plugin , buildFolder(self.args)) # install plugin installPath = os.path.join( self.installPath, 'plugins' ) new_plugin = plugin if pipe.platform=='darwin': new_plugin = self.env.Command( os.path.join(buildFolder(self.args), self.name+'.'+self.version+'.bundle' ), plugin, 'mv $SOURCE $TARGET') install = self.env.Install(installPath, new_plugin) self.env.Alias( 'install', install )
def init_environment(reqlist) : opts = Variables() cmloptions(opts) # first check if there's qt4 in the requirement need_qt4 = 0 list = reqlist.split() for l in list: if l == "qt4": env = Environment(tools=['default', 'qt4'], options = opts) need_qt4 = 1 break # if not, build default if need_qt4 == 0: env = Environment(options = opts) # Now scanning the dependencies for l in list: if l == "qt4": from loadqt import loadqt loadqt(env) if l == "geant4": from loadgeant4 import loadgeant4 loadgeant4(env) if l == "evio": from loadevio import loadevio loadevio(env) if l == "root": from loadroot import loadroot loadroot(env) if l == "clhep": from loadclhep import loadclhep loadclhep(env) if l == "mysql": from loadmysql import loadmysql loadmysql(env) if l == "clas": from loadclas import loadclas loadclas(env) if l == "jana": from loadjana import loadjana loadjana(env) if l == "clas12": from loadclas12 import loadclas12 loadclas12(env) if l == "cmsg": from loadcmsg import loadcmsg loadcmsg(env) if l == "mu": from loadmu import loadmu loadmu(env) if l == "cuda": from loadcuda import loadcuda loadcuda(env) # generating help list Help(opts.GenerateHelpText(env)) # loading options loadoptions(env) return env
def hostEnv(self): env = Environment.Environment() env.vars = {} return Rim(env)
def pushAppLibs(parent, me): for path in parent.env.applibs: me.env.applibs.append(path) def popAppLibs(parent, me): for path in parent.env.applibs: me.env.applibs.pop() # # use this for tagging purposes. # Scons will complain if different environments try to put the same object in the tree. # global tagrim env = Environment.Environment() env.vars = {} tagrim = Rim(env) tagrim.useCxxforCFiles() class AppLib: class agroup: def __init__(self, fullname, tokens): self.subs = [] self.incDirs = [] self.aliases = [] self.depends = [] self.fname = fullname for idx in range(1, len(tokens)): # a sub lib?
def CreateEnvironment(vars): # add a variable to handle RELEASE/DEBUG mode vars.Add(EnumVariable('mode', 'Release versus debug mode', 'debug', allowed_values = ('release', 'debug'))) # add a variable to handle warnings vars.Add(BoolVariable('Wall', 'Enable all compilation warnings', 1)) # shared or static libraries libraryDefault = 'shared' vars.Add(EnumVariable('library', 'Build shared or static library', libraryDefault, allowed_values = ('shared', 'static'))) # add a variable to treat warnings as errors vars.Add(BoolVariable('Werror', 'Treat warnings as errors', 1)) # add a variable to determine the install path default_install_path = '/usr/local' if 'LIBCUXX_INSTALL_PATH' in os.environ: default_install_path = os.environ['LIBCUXX_INSTALL_PATH'] vars.Add(PathVariable('install_path', 'The libcuxx install path', default_install_path, PathVariable.PathIsDirCreate)) vars.Add(BoolVariable('install', 'Include libcuxx install path in default ' 'targets that will be built and configure to install in the ' 'install_path (defaults to false unless one of the targets is ' '"install")', 0)) # create an Environment env = Environment(ENV = importEnvironment(), \ tools = getTools(), variables = vars) updateEnvironment(env) # set the version env.Replace(VERSION = getVersion("0.1")) # always link with the c++ compiler if os.name != 'nt': env['LINK'] = env['CXX'] # get C compiler switches env.AppendUnique(CFLAGS = getCFLAGS(env['mode'], env['Wall'], \ env['Werror'], env.subst('$CC'))) # get CXX compiler switches env.AppendUnique(CXXFLAGS = getCXXFLAGS(env['mode'], env['Wall'], \ env['Werror'], env.subst('$CXX'))) # get linker switches env.AppendUnique(LINKFLAGS = getLINKFLAGS(env['mode'], env.subst('$LINK'))) # Install paths if env['install']: env.Replace(INSTALL_PATH = os.path.abspath(env['install_path'])) else: env.Replace(INSTALL_PATH = os.path.abspath('.')) # set the build path env.Replace(BUILD_ROOT = str(env.Dir('.'))) env.Replace(CPPPATH = [env['BUILD_ROOT']]) # get libc++ if env['CXX'] == 'c++': env.AppendUnique(CPPPATH = [getLibCXXPaths()[0]]) # set extra libs env.Replace(EXTRA_LIBS=getExtraLibs()) # set libcuxx include path env.AppendUnique(LIBPATH = os.path.abspath('.')) # we need librt on linux if sys.platform == 'linux2': env.AppendUnique(EXTRA_LIBS = ['-lrt']) # we need libdl on max and linux if os.name != 'nt': env.AppendUnique(EXTRA_LIBS = ['-ldl']) # generate help text Help(vars.GenerateHelpText(env)) return env
def test_Platform(self): """Test the Platform() function""" p = SCons.Platform.Platform('cygwin') assert str(p) == 'cygwin', p env = Environment() p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('os2') assert str(p) == 'os2', p env = Environment() p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.lib', env p = SCons.Platform.Platform('posix') assert str(p) == 'posix', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('irix') assert str(p) == 'irix', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('aix') assert str(p) == 'aix', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('sunos') assert str(p) == 'sunos', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('hpux') assert str(p) == 'hpux', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('win32') assert str(p) == 'win32', p env = Environment() p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.lib', env exc_caught = None try: p = SCons.Platform.Platform('_does_not_exist_') except SCons.Errors.UserError: exc_caught = 1 assert exc_caught, "did not catch expected UserError" env = Environment() SCons.Platform.Platform()(env) assert env != {}, env
class Package: """ A package defines a collection of distributables including programs and libraries. The Package class provides the ability to build, install, and package up distributions of your project. A package object provides an interface to add libraries, programs, headers, and support files to a single unit that can be installed. It also shares an environment across all these different units to build. The package contains assemblies (objects that encapsulate things to build) and a FileBundle (which holds all the files that could be installed or handled). When assemblies are built, they should add any installable files to the package file bundle. """ def __init__(self, name, version, prefix='/usr/local', baseEnv = None, description= None): """ Creates a new package with the given name and version, where version is in the form of <major>.<minor>.<patch> (e.g 1.12.0) """ self.name = name self.prefix = prefix self.assemblies = [] self.fileBundles = [FileBundle(),] # File bundle for all files self.extra_dist = [] self.description = description self.packagers = [] self.distDir = "dist" # Path to the dist directory to use if not self.description: self.description = self.name + " Package" if baseEnv: self.env = baseEnv.Clone() else: self.env = Environment() if type(version) is types.TupleType: (self.version_major, self.version_minor, self.version_patch) = version; else: re_matches = re.match(r'^(\d+)\.(\d+)\.(\d+)$', version) self.version_major = int(re_matches.group(1)) self.version_minor = int(re_matches.group(2)) self.version_patch = int(re_matches.group(3)) def getName(self): return self.name def getVersionMajor(self): return self.version_major def getVersionMinor(self): return self.version_minor def getVersionPatch(self): return self.version_patch def getFullVersion(self): return ".".join( (str(self.version_major), str(self.version_minor), str(self.version_patch)) ) def getAssemblies(self): return self.assemblies def getExtraDist(self): return self.extra_dist def getFileBundles(self): return self.fileBundles def getEnv(self): " Get the common pakcage environment. " return self.env def setDistDir(self, path): " Set the prefix for distribution/packaged files. " self.distDir = path def getDistDir(self): return self.distDir def addPackager(self, packager): " Add a new packager. Sets the packager to point to this package. " packager.setPackage(self) self.packagers.append(packager) # ###### Assembly factory methods ####### # def createLoadableModule(self, name, baseEnv = None, installPrefix='lib'): """ Creates a new shared library of the given name as a part of this package. The library will be built within the given environment. """ if not baseEnv: baseEnv = self.env lib = LoadableModule(name, self, baseEnv, installPrefix) self.assemblies.append(lib) return lib def createSharedLibrary(self, name, baseEnv = None, installPrefix='lib'): """ Creates a new shared library of the given name as a part of this package. The library will be built within the given environment. """ if not baseEnv: baseEnv = self.env lib = SharedLibrary(name, self, baseEnv, installPrefix) self.assemblies.append(lib) return lib def createStaticLibrary(self, name, baseEnv = None, installPrefix='lib'): """ Creates a new static library of the given name as a part of this package. The library will be built within the given environment. """ if not baseEnv: baseEnv = self.env lib = StaticLibrary(name, self, baseEnv, installPrefix) self.assemblies.append(lib) return lib def createStaticAndSharedLibrary(self, name, baseEnv = None, installPrefix='lib'): """ Creates new static and shared library of the given name as a part of this package. The library will be built within the given environment. """ if not baseEnv: baseEnv = self.env lib = StaticAndSharedLibrary(name, self, baseEnv, installPrefix) self.assemblies.append(lib) return lib def createProgram(self, name, baseEnv = None, installPrefix='bin', isAppBundle=False, resources=[], infoPlist='', pkgInfo=''): """ Creates a new executable program of the given name as a part of this package. The program will be built within the given environment. """ if not baseEnv: baseEnv = self.env prog = Program(name, self, baseEnv, installPrefix, isAppBundle, resources, infoPlist, pkgInfo) self.assemblies.append(prog) return prog def createFileBundleAssembly(self, prefix, baseEnv = None): """ Creates a new FileBundle object as part of this package. """ bundle = FileBundleAssembly(pkg = self, baseEnv = baseEnv, prefix=prefix) self.assemblies.append(bundle) return bundle def createFileBundle(self, bundlePrefix=""): """ Creates a new file bundle to use with this package. """ fb = FileBundle(bundlePrefix) self.fileBundles.append(fb) return fb def createConfigAction(self, target, source, env): """ Called as action of config script builder """ global config_script_contents new_contents = config_script_contents value_dict = source[0].value # Get dictionary from the value node all_lib_names = [os.path.basename(l.getAbsFilePath()) for l in self.assemblies if isinstance(l,Library)] lib_names = [] for l in all_lib_names: if not lib_names.count(l): lib_names.append(l) inc_paths = [pj(self.prefix,'include'),] cflags = " ".join(["-I"+p for p in inc_paths]) if value_dict["extraCflags"] != None: cflags = cflags + " " + value_dict["extraCflags"] lib_paths = [pj(self.prefix,'lib'),] if value_dict["extraIncPaths"] != None: cflags = cflags + " ".join([" -I"+l for l in value_dict["extraIncPaths"]]) # Extend varDict with local settings varDict = {} if value_dict["varDict"] != None: varDict = value_dict["varDict"] varDict["Libs"] = " ".join(["-L"+l for l in lib_paths]) if value_dict["extraLibPath"] != None: varDict["Libs"] += " " + " ".join(["-L"+l for l in value_dict["extraLibPath"]]) if len(lib_names): varDict["Libs"] += " " + " ".join(["-l"+l for l in lib_names]) if value_dict["extraLibs"]!=None: varDict["Libs"] = varDict["Libs"] + " " + " ".join(["-l"+l for l in value_dict["extraLibs"]]) varDict["Cflags"] = cflags varDict["Version"] = self.getFullVersion() varDict["Name"] = self.name varDict["Description"] = self.description varDict["Prefix"] = self.prefix # Create the new content txt = "# config script generated for %s at %s\n" % (self.name, time.asctime()) txt = txt + '# values: %s\n'%(source[0].get_contents(),) for k,v in value_dict["varDict"].items(): if SCons.Util.is_String(v): txt = txt + 'vars["%s"] = "%s"\n' % (k,v) else: txt = txt + 'vars["%s"] = %s\n' % (k,v) # Find and replace the replacable content cut_re = re.compile(r'(?<=# -- BEGIN CUT --\n).*?(?=# -- END CUT --)', re.DOTALL) new_contents = cut_re.sub(txt,config_script_contents) # Create and write out the new file (setting it executable) fname = str(target[0]) f = open(str(target[0]), 'w') f.write(new_contents) f.close() os.chmod(fname, stat.S_IREAD|stat.S_IEXEC|stat.S_IWUSR) # Set the file options return 0 # Successful build def createConfigScript(self, name, installDir='bin', varDict = None, extraIncPaths=None, extraLibs=None, extraLibPaths=None, extraCflags=None): """ Adds a config script to the given package installation. varDict - Dictionary of extra variables to define. """ if not self.env['BUILDERS'].has_key("PackageConfigScript"): cfg_builder = Builder(action = Action(self.createConfigAction, lambda t,s,e: "Create config script for %s package: %s"%(self.name, t[0])) ) self.env.Append(BUILDERS = {"PackageConfigScript" : cfg_builder}) value_dict = {} value_dict["prefix"] = self.prefix value_dict["extraIncPaths"] = extraIncPaths value_dict["extraLibs"] = extraLibs value_dict["extraLibPath"] = extraLibPaths value_dict["extraCflags"] = extraCflags value_dict["varDict"] = varDict self.env.PackageConfigScript(target = pj(installDir, name), source = Value(value_dict)) # May need to delay doing this until a later build stage so that all libs, headers, etc are # setup and ready to go in this package. def addExtraDist(self, files, exclude=[]): """ Adds in the given files to the distribution of this package. If a directory is encountered in the file list, it is recursively added. Files whose names are in the exclude list are not added to the list. """ for file in files: assert isinstance(file, str), "file was not of correct type." # Make sure to skip files in the exclude list if not file in exclude: # If the file is a directory, recurse on it if os.path.isdir(str(file)): self.addExtraDist(os.listdir(str(file)), exclude) # If the file is not a directory, add in the extra dist list else: self.extra_dist.append(file) def build(self, install = True): """ Sets up the build and install for this package. This will build all assemblies contained therein that have not already been built and set up the standard filebundle install. """ for assembly in self.assemblies: if not assembly.isBuilt(): assembly.build() # Build the file bundles for this package if install: for fb in self.fileBundles: fb.buildInstall(self.env, self.prefix) #self.env.Alias('install', self.prefix) # Setup all packagers for p in self.packagers: p.build()
def test_Platform(self): """Test the Platform() function""" p = SCons.Platform.Platform('cygwin') assert str(p) == 'cygwin', p env = Environment() p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('os2') assert str(p) == 'os2', p env = Environment() p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.lib', env p = SCons.Platform.Platform('posix') assert str(p) == 'posix', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('irix') assert str(p) == 'irix', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('aix') assert str(p) == 'aix', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('sunos') assert str(p) == 'sunos', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('hpux') assert str(p) == 'hpux', p env = Environment() p(env) assert env['PROGSUFFIX'] == '', env assert env['LIBSUFFIX'] == '.a', env assert env['SHELL'] == 'sh', env p = SCons.Platform.Platform('win32') assert str(p) == 'win32', p env = Environment() p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.lib', env assert str try: p = SCons.Platform.Platform('_does_not_exist_') except SCons.Errors.UserError: pass else: # TODO pylint E0704: bare raise not inside except raise env = Environment() SCons.Platform.Platform()(env) assert env != {}, env
class sl: def __init__ ( self, args, version='1.0.0', dlpath=DELIGHT, include=DL_SHADER_PATH, options='', #versionControled=os.environ.has_key('PIPE_DEP'), versionControled=False, env=None, prefix=None, src=[], sed=[] ): self.args = args self.version = version self.dlpath = os.popen('eval echo "%s"' % dlpath).readlines()[0].strip() if not dlpath: raise Exception("cant find 3delight. Set DELIGHT to the 3delight install path") self.include = os.popen('eval echo "%s"' % include).readlines()[0].strip() self.options = options self.src = src self.installPath = os.path.join( central('tools',args,prefix=prefix), 'shaders', '3delight' ) if versionControled: self.installPath = os.path.join(self.installPath, name, self.version) self.env=env if not env: self.env=Environment() self.sed = sed self.sed.append('s/!%s!/%s/g' % ('VERSION',self.version) ) self.env.Append(include=self.include) self.env.Append(dlpath=self.dlpath) self.env.Append(options=self.options) @staticmethod def builder( target, source, env): target=str(target[0]) source=str(source[0]) dlpath = filter(lambda x:x[0]=='dlpath', env.items())[0][1] include = filter(lambda x:x[0]=='include', env.items())[0][1].split(':') options = filter(lambda x:x[0]=='options', env.items())[0][1] shaderdl = os.path.join(dlpath,'bin','shaderdl') include = '-I'.join(include) os.system('%s %s -I%s %s -o %s' % (shaderdl, options, include, source, target) ) def finalize(self): bld = Builder(action = sl.builder) self.env.Append(BUILDERS = {'slBuilder' : bld}) # build intermediate source registerSedBuilder(self.env, self.sed) src=[] for each in self.src: new = os.path.join(buildFolder(self.args), os.path.basename(each)) sdl = new.replace('.sl','.sdl') print >>sys.stderr, new,sdl self.env.sedBuilder( new, each) self.env.slBuilder( sdl, new ) src.append(sdl) # install install = [] for each in src: name = os.path.splitext(os.path.basename(each))[0] install.append( self.env.Install( self.installPath , each) ) self.env.Alias( 'install', install )