Changeset 32:4a3a1770955e

Show
Ignore:
Timestamp:
08/23/06 18:58:05 (2 years ago)
Author:
vadim@mbdsys.com
Message:

Added Library and SharedLibrary? methods to BuildJobInfo? to further simplify Sconscripts

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Env/BuildJob.py

    r30 r32  
    8181              self.buildpath += "/release" 
    8282           
    83            
    84  
    85  
    86     def Component(self, name, includes = [], libpath = [], libs = [] , uses = [], node = None):  
     83 
     84          self.sharedtarget = False 
     85 
     86 
     87    def Component(self, name, includes = [], libpath = [], libs = [], uses = [], node = None):  
    8788          if self.components.has_key(name): 
    8889              return self.components[name] 
     
    9798              return self.components[x] 
    9899 
    99           newuses = [ compinfo(x) for x in uses ] 
    100  
     100          if uses and len(uses): 
     101              newuses = [ compinfo(x) for x in uses ] 
     102          else: 
     103              newuses = [] 
     104 
     105          if node: 
     106              self.env.Alias(name, node) 
     107 
     108          if node: 
     109              if len(libpath) == 0: 
     110                  libpath = [node[0].dir] 
     111              if len(libs) == 0: 
     112                  libs = [name] 
     113                   
    101114          m = CompInfo(name, includes, libpath, libs, newuses, node) 
    102115          self.components[name] = m 
     
    154167    def Autoconf(self, env, moduleName, outputFiles, 
    155168                       configureCommand = './configure', makeCommand = 'make', 
    156                        configureFiles = 'configure', makeFiles = 'Makefile'): 
     169                       configureFiles = 'configure', makeFiles = 'Makefile', 
     170                       uses = None, includes = None, libpath = None, libs = None): 
    157171        """ 
    158172        Build a library using autotools: configure and make. 
    159173         
    160174        Algorithm: 
    161         - Copy the library source directory to the build path directory 
    162175        - Launch the configure command 
    163176        - Launch the make command 
     
    187200 
    188201        env.Depends(make, makefile) 
     202        #self.Component(moduleName, includes, libpath, libs, uses) 
    189203        env.Alias(moduleName, [make]) 
     204         
    190205 
    191206 
     
    210225     
    211226       
    212        
    213            
     227    def Library(self, env, target, source = None, uses = [], includes = [], libpath = [], libs = [],  sharedtarget = None, **kw): 
     228 
     229        if sharedtarget == None: 
     230            sharedtarget = self.sharedtarget 
     231 
     232 
     233        self.Use(env, uses) 
     234        env.AppendUnique( **kw ) 
     235        if sharedtarget: 
     236            obj = env.SharedObject( source = source) 
     237        else: 
     238            obj = env.StaticObject( source = source) 
     239             
     240 
     241        lib = env.StaticLibrary( target, obj ) 
     242        self.Component(target, includes = includes, libpath = libpath, libs = libs, uses = uses, node = lib) 
     243 
     244        return lib 
     245 
     246 
     247    def SharedLibrary(self, env, target, source,  uses = [], includes = [], libpath = [], libs = [],  **kw): 
     248 
     249        self.Use(env, uses) 
     250        env.AppendUnique( **kw ) 
     251        lib = env.SharedLibrary( target, source = source ) 
     252        self.Component(target, includes = includes, libpath = libpath, libs = libs, uses = uses, node = lib) 
     253 
     254        return lib 
     255     
  • SConstruct

    r22 r32  
    3636 
    3737env = BJ.NewEnv() 
     38if env["shared_phapi"]: 
     39   BJ.sharedtarget = True 
    3840 
    3941#Duplicate = 0 is very important: it tells SCons 
  • libs/pixertool/SConscript

    r31 r32  
    3535        sources += ['src/null-pixertool.cpp'] 
    3636 
    37 env.Append(CPPPATH = include_path, CPPDEFINES = defines) 
    38 BJ.Use(env, libs) 
    39 print "pixertool includes", env["CPPPATH"] 
    40 if env['shared_phapi']: 
    41    pxo = env.SharedObject( source = sources ) 
     37 
     38if True: 
     39   pxl = BJ.Library(env, target = 'pixertool',  
     40            source = sources,  
     41            uses = ["owutil", "owcutil", "avcodec", "avutil"], 
     42            includes = ["#/libs/pixertool/include"], 
     43            CPPPATH = include_path, CPPDEFINES = defines 
     44            )  
     45             
     46 
    4247else: 
    43    pxo = env.StaticObject( source = sources ) 
     48   env.Append(CPPPATH = include_path, CPPDEFINES = defines) 
     49   BJ.Use(env, libs) 
     50   if env['shared_phapi']: 
     51      pxo = env.SharedObject( source = sources ) 
     52   else: 
     53      pxo = env.StaticObject( source = sources ) 
    4454 
    45 pxl = env.StaticLibrary('pixertool', source = pxo) 
     55   pxl = env.StaticLibrary('pixertool', source = pxo) 
    4656 
    47 BJ.Component('pixertool', includes = ["#/libs/pixertool/include"], libpath = [pxl[0].dir], libs = ["pixertool"], 
    48              uses = ["owutil", "owcutil", "avcodec", "avutil"], node = pxl) 
     57   BJ.Component('pixertool', uses = ["owutil", "owcutil", "avcodec", "avutil"], 
     58            includes = ["#/libs/pixertool/include"]) 
     59 
     60 
     61 
    4962 
    5063