Changeset 21

Show
Ignore:
Timestamp:
08/16/06 21:39:41 (2 years ago)
Author:
allenb
Message:

Added basic support for recursively figuring out library dependencies. (cpppath, libs, libpath, etc)

This needs to be more modularized and the build.info files need updated but this should now work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/scons_build_creation/SConstruct

    r20 r21  
    5252      self.osg_dep_libs = []         # Names of OpenSG libraries we depend upon 
    5353      self.libs = []                 # Names of other libraries we depend upon 
     54      self.libpath = []             # Paths to dependent libs 
    5455      self.cpppath = []              # List of extra paths we need to compile 
    5556 
     
    233234         print "   Evaluating: ", bi_filename          
    234235         ns = {"option_pass":False,  
     236               "opts":opts, 
    235237               "library":None, 
    236238               "platform":platform, 
     
    239241               "osg_dep_libs":[], 
    240242               "libs":[], 
     243               "libpath":[], 
    241244               "cpppath":[], 
    242245         } 
     
    257260         cur_lib.libs.extend(ns["libs"]) 
    258261         cur_lib.cpppath.extend(ns["cpppath"]) 
     262         cur_lib.libpath.extend(ns["libpath"]) 
    259263       
    260264      test_files =   [f for f in files if os.path.basename(f).startswith("test") and f.endswith(".cpp")] 
     
    349353   print "archs: ",    variant_helper.variants["arch"]     
    350354    
    351    for combo in variant_helper.iterate(locals(), base_bldr, common_env):             
     355   if 0: 
     356   #for combo in variant_helper.iterate(locals(), base_bldr, common_env):             
    352357      #baseEnv = env_bldr.applyToEnvironment(common_env.Copy(), variant=combo,options=opts)       
    353358      print "   Processing combo: ", ", ".join(['%s:%s'%(i[0],i[1]) for i in combo.iteritems()]) 
     
    369374         SConscript(pj(d,'SConscript'), build_dir=pj(full_build_dir, d), duplicate=0) 
    370375    
    371    common_env.Alias('install', inst_paths['base']) 
     376   common_env.Alias('install', paths['base']) 
    372377    
    373378   # Build -config file 
     
    380385   submap = {'@LIB_MAP_STR@':lib_map_str, 
    381386             '@PREFIX@':common_env["prefix"], 
     387             '@LIBPATH@':paths["lib"], 
    382388             '@VERSION@':opensg_version_string} 
    383    osg_config = common_env.SubstBuilder(pj(inst_paths['bin'],'osg-config'), 
     389   osg_config = common_env.SubstBuilder(pj(paths['bin'],'osg-config'), 
    384390                              'osg-config.in', submap=submap) 
    385391   common_env.AddPostAction(osg_config, Chmod('$TARGET', 0755)) 
  • branches/scons_build_creation/Source/Base/build.info

    r19 r21  
    77   osg_dep_libs = [] 
    88   if "win32" == platform: 
    9       libs = ["pthread","dl","m"
     9      libs = [
    1010      cpppath = [] 
    1111   else: 
  • branches/scons_build_creation/Source/System/FileIO/build.info

    r5 r21  
    55else: 
    66   library = "OSGFileIO" 
    7    lib_deps = ['OSGBase',"OSGSystem"
     7   osg_dep_libs = ['OSGBase', 'OSGSystem'
  • branches/scons_build_creation/Source/System/NodeCores/Drawables/build.info

    r5 r21  
    55else: 
    66   library = "OSGDrawable" 
    7    lib_deps = ['OSGBase',"OSGSystem"]    
     7   osg_dep_libs = ['OSGBase', 'OSGSystem', 'OSGState'] 
  • branches/scons_build_creation/Source/System/NodeCores/Groups/build.info

    r5 r21  
    55else: 
    66   library = "OSGGroup" 
    7    lib_deps = ['OSGBase',"OSGSystem"
     7   osg_dep_libs = ['OSGBase', 'OSGSystem'
  • branches/scons_build_creation/Source/System/State/build.info

    r5 r21  
    55else: 
    66   library = "OSGState" 
    7    osg_lib_deps = ['OSGBase',"OSGSystem"]    
     7   osg_dep_libs = ['OSGBase', 'OSGSystem'] 
  • branches/scons_build_creation/Source/System/build.info

    r5 r21  
    44   print "Processing option pass" 
    55else: 
     6   jpeg_option = opts.GetOption("jpeg") 
     7   tiff_option = opts.GetOption("tiff") 
     8   png_option = opts.GetOption("png") 
     9    
    610   library = "OSGSystem" 
    7    lib_deps = ["OSGBase",] 
     11   osg_dep_libs = ['OSGBase'] 
     12    
     13   for option in [jpeg_option, tiff_option, png_option]: 
     14      if option.isAvailable(): 
     15         libs.append(option.library) 
     16         if option.incDir: 
     17            cpppath.append(option.incDir) 
     18         if option.libDir: 
     19            libpath.append(option.libDir) 
     20    
     21    
  • branches/scons_build_creation/osg-config.in

    r20 r21  
    33import os, sys 
    44from optparse import OptionParser 
     5    
     6lib_map_str = """@LIB_MAP_STR@""" 
     7inst_prefix = "@PREFIX@" 
     8inst_lib_path = "@LIBPATH@" 
     9version = "@VERSION@" 
     10 
     11lib_map_list = eval(lib_map_str) 
     12parser = None 
     13lib_map = {} 
     14 
     15def main(): 
     16   global parser, lib_map 
     17    
     18   # Create library map 
     19   for i in lib_map_list: 
     20      if i.has_key("name"): 
     21         name = i["name"] 
     22         lib_map[name] = LibraryInfo(name) 
     23         lib_map[name].load(i) 
     24 
     25   # Create parser 
     26   parser = OptionParser(usage="%prog [LIBRARY] [OPTIONS]", description="OpenSG config options.") 
     27 
     28   parser.add_option("--prefix",action="store_true",help="Print the installation prefix.") 
     29   parser.add_option("--version",action="store_true",help="Print the installed CppDom's version number.") 
     30   parser.add_option("--cflags",action="store_true",help="Print OpenSG specific cflags.") 
     31   parser.add_option("--lflags",action="store_true",help="Print library flags.") 
     32   parser.add_option("--llibs",action="store_true",help="Print library list.") 
     33   parser.add_option("--libs",action="store_true",help="Print libraries and flags.") 
     34 
     35   (options, pos_args) = parser.parse_args() 
     36    
     37   print "Pos args: ", pos_args 
     38    
     39   if len(pos_args) == 0 or pos_args[0] not in lib_map.keys():       
     40      printUsage() 
     41      sys.exit(1) 
     42 
     43   libname = pos_args[0] 
     44   merged_lib = createMergedLibraryObject(libname) 
     45 
     46   if options.prefix: 
     47      print inst_prefix 
     48   elif options.version: 
     49      print version 
     50   elif options.cflags: 
     51      all_inc_paths = merged_lib.cpppath 
     52      paths_str = " ".join(["-I%s"%p for p in all_inc_paths]) 
     53      print paths_str 
     54   elif options.libs or options.llibs or options.lflags: 
     55      all_libs = merged_lib.libs 
     56      lib_paths = merged_lib.libpaths 
     57      libs_str = " ".join(["-l%s"%l for l in all_libs]) 
     58      lib_paths_str = " ".join(["-L%s"%p for p in lib_paths]) 
     59      if options.libs: 
     60         print "%s %s"%(lib_paths_str, libs_str) 
     61      elif options.llibs: 
     62         print libs_str 
     63      elif options.lflags: 
     64         print lib_paths_str       
     65   else: 
     66      printUsage() 
     67      sys.exit(1) 
     68 
     69 
     70def getLibDepList(libName, knownList): 
     71   dep_list = [] 
     72   if lib_map.has_key(libName): 
     73      dep_list.extend([l for l in lib_map[libName].osg_dep_libs if not l in knownList]) 
     74   for l in dep_list[:]: 
     75      dep_list.extend(getLibDepList(l,dep_list)) 
     76   return dep_list 
     77 
     78def createMergedLibraryObject(libName): 
     79   """ Return a new library object with all of the options 
     80       merged for the dependencies of the given libName library. 
     81       This is used to combine all the options for a library and 
     82       it's dependencies into a single object 
     83   """ 
     84   global lib_map, inst_lib_path 
     85   dep_list = [libName] + getLibDepList(libName,[]) 
     86   print "Deps for lib: %s  are: %s"%(libName, dep_list)    
     87    
     88   dep_lib_list = [lib_map[l] for l in dep_list]    
     89   merged_lib = LibraryInfo() 
     90   merged_lib.libs = dep_list[:] 
     91   merged_lib.libpaths = [inst_lib_path] 
     92    
     93   for lib in dep_lib_list: 
     94      merged_lib.libs.extend([i for i in lib.libs if not i in merged_lib.libs]) 
     95      merged_lib.libpath.extend([i for i in lib.libpath if not i in merged_lib.libpath]) 
     96      merged_lib.cpppath.extend([i for i in lib.cpppath if not i in merged_lib.cpppath]) 
     97       
     98   return merged_lib 
     99    
     100 
     101def printUsage(): 
     102   global parser, lib_map 
     103   parser.print_help() 
     104   print "\nLibraries: " 
     105   for lib_name in lib_map.keys(): 
     106      print "   %s"%lib_name 
    5107 
    6108# --- Copied from SConstruct file --- # 
     
    15117      self.osg_dep_libs = []         # Names of OpenSG libraries we depend upon 
    16118      self.libs = []                 # Names of other libraries we depend upon 
     119      self.libpath = []             # Paths to dependent libs 
    17120      self.cpppath = []              # List of extra paths we need to compile 
    18121 
     
    30133         if dumpDict.has_key(i): 
    31134            self.__dict__[i] = dumpDict[i] 
    32 # ----------------------------------- #       
    33  
    34 lib_map_str = """@LIB_MAP_STR@""" 
    35 inst_prefix = "@PREFIX@" 
    36 version = "@VERSION@" 
    37  
    38 lib_map_list = eval(lib_map_str) 
    39  
    40 lib_map = {} 
    41 for i in lib_map_list: 
    42    if i.has_key("name"): 
    43       name = i["name"] 
    44       lib_map[name] = LibraryInfo(name) 
    45       lib_map[name].load(i) 
    46  
    47  
    48 parser = OptionParser(usage="%prog [LIBRARY] [OPTIONS]", description="OpenSG config options.") 
    49  
    50 parser.add_option("--prefix",action="store_true",help="Print the installation prefix.") 
    51 parser.add_option("--version",action="store_true",help="Print the installed CppDom's version number.") 
    52 parser.add_option("--cflags",action="store_true",help="Print OpenSG specific cflags.") 
    53 parser.add_option("--lflags",action="store_true",help="Print library flags.") 
    54 parser.add_option("--llibs",action="store_true",help="Print library list.") 
    55 parser.add_option("--libs",action="store_true",help="Print libraries and flags.") 
    56  
    57 def main(): 
    58    global parser, lib_map 
    59    (options, pos_args) = parser.parse_args() 
    60     
    61    print "Pos args: ", pos_args 
    62  
    63    if options.prefix: 
    64       print inst_prefix 
    65    elif options.version: 
    66       print version 
    67    elif options.cxxflags or options.libs: 
    68       if options.cxxflags: 
    69          command_flags += " --cflags" 
    70       if options.libs: 
    71          command_flags += " --libs" 
    72       if not options.all: 
    73          command_flags += " --no-deps" 
    74    else: 
    75       printUsage() 
    76       sys.exit(1) 
    77  
    78     
    79 def printUsage(): 
    80    global parser, lib_map 
    81    parser.print_help() 
    82    print "\nLibraries: " 
    83    for lib_name in lib_map.keys(): 
    84       print "   %s"%lib_name 
    85     
    86  
     135# ----------------------------------- #    
    87136 
    88137# Main