| | 5 | |
|---|
| | 6 | lib_map_str = """@LIB_MAP_STR@""" |
|---|
| | 7 | inst_prefix = "@PREFIX@" |
|---|
| | 8 | inst_lib_path = "@LIBPATH@" |
|---|
| | 9 | version = "@VERSION@" |
|---|
| | 10 | |
|---|
| | 11 | lib_map_list = eval(lib_map_str) |
|---|
| | 12 | parser = None |
|---|
| | 13 | lib_map = {} |
|---|
| | 14 | |
|---|
| | 15 | def 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 | |
|---|
| | 70 | def 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 | |
|---|
| | 78 | def 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 | |
|---|
| | 101 | def 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 |
|---|
| 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 | # ----------------------------------- # |
|---|