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 )
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 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 ) )
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 )
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 )