root/branches/scons_build_creation/osg-config.in

Revision 36, 4.8 kB (checked in by allenb, 2 years ago)

- Add support for multiple libraries in osg-config
- Use the Config backend for figuring out the deps for tests
- Build tests into a common test directory for each variant
- Remove some code Dirk was using to solve for the deps manually

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env python
2 #
3 # Commandline tool for querying information about OpenSG libraries and required
4 # flags to compile.
5 #
6 # Much of this file is autogenerated at build time, so make sure to modify
7 # the .in version of this file in the build if you want to make changes
8 #
9 # The main components of this file are:
10 # - A set of classes at the end of the file that are automatically included
11 #   from the OpenSG build system.  These are used to store and analyze
12 #   the library information.  Most of the logic used in this tool is in these classes.
13 # - A string rep list of dictionaries that are automatically created by the build
14 #   and represent the state of the library objects from the build.  This list
15 #   is used to construct a local representation of the library information for OpenSG.
16 # - The option parser.  This section of the code is responsible for reading options and
17 #   calling the appropriate methods of the library info classes.
18 #
19 import os, sys
20 from optparse import OptionParser
21
22 # List of dictionaries in string format that will
23 # be used to build library information
24 lib_map_str = """@LIB_MAP_STR@"""
25
26 # various other variables needed
27 inst_prefix = "@PREFIX@"
28 inst_lib_path = "@LIBPATH@"
29 inst_inc_path = "@INCPATH@"
30 version = "@VERSION@"
31
32 lib_map_list = eval(lib_map_str)
33 parser = None
34 lib_map = {}
35
36 def main():
37    global parser, lib_map
38    
39    # Create library map from the dumped set of dictionaries
40    for i in lib_map_list:
41       if i.has_key("name"):
42          name = i["name"]
43          lib_map[name] = LibraryInfo(name)
44          lib_map[name].load(i)
45
46    # Determine defaults
47    if "win32" == sys.platform:
48       def_incprefix = "/I"
49       def_libprefix = ""
50       def_libpathprefix = "/LIBPATH:"
51    else:
52       def_incprefix = "-I"
53       def_libprefix = "-l"
54       def_libpathprefix = "-L"
55      
56    # Create parser
57    parser = OptionParser(usage="%prog [LIBRARY] [OPTIONS]", description="OpenSG config options.")
58
59    parser.add_option("--prefix",action="store_true",help="Print the installation prefix.")
60    parser.add_option("--version",action="store_true",help="Print the installed CppDom's version number.")
61    parser.add_option("--cflags",action="store_true",help="Print OpenSG specific cflags.")
62    parser.add_option("--lflags",action="store_true",help="Print library flags.")
63    parser.add_option("--llibs",action="store_true",help="Print library list.")
64    parser.add_option("--libs",action="store_true",help="Print libraries and flags.")
65    parser.add_option("--no-prefix-flags",action="store_true",
66                      help="When printing list of libraries and paths, don't include compiler prefix flags (-I,-l,-L)")
67    parser.add_option("--inc-prefix",default=def_incprefix,
68                      help="Compiler include path prefix to use. (%s)"%def_incprefix)
69    parser.add_option("--lib-prefix",default=def_libprefix,
70                      help="Linker lib prefix to use. (%s)"%def_libprefix)
71    parser.add_option("--libpath-prefix",default=def_libpathprefix,
72                      help="Linker library path prefix to use. (%s)"%def_libpathprefix)
73
74    (options, pos_args) = parser.parse_args() 
75    
76    # Try to find libname
77    # - Try given name and name with OSG prefix
78    libraries = []
79    if len(pos_args):     
80       for n in pos_args:
81          if lib_map.has_key(n):
82             libraries.append(lib_map[n])
83          elif lib_map.has_key("OSG%s"%n):
84             libraries.append(lib_map["OSG%s"%n])
85          else:
86             print "Error: Can not find library named: ", n
87    
88    if len(libraries) == 0:
89       printUsage()
90       sys.exit(1)
91    
92    # If set to no prefix flags, then clear all defaults
93    if options.no_prefix_flags:
94       options.inc_prefix = ""
95       options.lib_prefix = ""
96       options.libpath_prefix = ""
97    
98    # Create a configuration adapter for the required library
99    default_lib_settings = LibraryInfo()
100    default_lib_settings.libpath.insert(0, inst_lib_path)
101    default_lib_settings.cpppath.insert(0, inst_inc_path)
102    config_info = ConfigInfoAdapter(libraries, lib_map, default_lib_settings,
103                      options.inc_prefix, options.lib_prefix, options.libpath_prefix)
104      
105    if options.prefix:
106       print inst_prefix
107    elif options.version:
108       print version
109    elif options.cflags:
110       print config_info.getIncPathStr()
111    elif options.libs or options.llibs or options.lflags:
112       if options.libs:
113          print "%s %s"%(config_info.getLibPathStr(), config_info.getLibsStr())
114       elif options.llibs:
115          print config_info.getLibsStr()
116       elif options.lflags:
117          print config_info.getLibPathStr()
118    else:
119       printUsage()
120       sys.exit(1)
121
122    
123
124 def printUsage():
125    global parser, lib_map
126    parser.print_help()
127    print "\nLibraries: "
128    for lib_name in lib_map.keys():
129       print "   %s"%lib_name
130
131 # --- Copied from Source file --- #
132 # DO NOT MODIFY HERE
133 @LIBRARY_UTIL_SRC@
134 # ----------------------------------- #   
135
136 # Main
137 main()
Note: See TracBrowser for help on using the browser.