root/branches/Dirk_RenderTraversalWork/osg-config.in

Revision 80, 5.2 kB (checked in by allenb, 2 years ago)

Backout change that added 'include/OpenSG' to include flags.

  • 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, os.path, sys
20 pj = os.path.join
21 from optparse import OptionParser
22
23 # List of dictionaries in string format that will
24 # be used to build library information
25 lib_map_str = """@LIB_MAP_STR@"""
26
27 # various other variables needed
28 inst_prefix = "@PREFIX@"
29 inst_lib_path = "@LIBPATH@"
30 inst_inc_path = "@INCPATH@"
31 version = "@VERSION@"
32
33 lib_map_list = eval(lib_map_str)
34 parser = None
35 lib_map = {}
36
37 def main():
38    global parser, lib_map
39    
40    # Create library map from the dumped set of dictionaries
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    # Determine defaults
48    if "win32" == sys.platform:
49       def_incprefix = "/I"
50       def_libprefix = ""
51       def_libpathprefix = "/LIBPATH:"
52    else:
53       def_incprefix = "-I"
54       def_libprefix = "-l"
55       def_libpathprefix = "-L"
56      
57    # Create parser
58    parser = OptionParser(usage="%prog [LIBRARY] [OPTIONS]", description="OpenSG config options.")
59
60    parser.add_option("--prefix",action="store_true",help="Print the installation prefix.")
61    parser.add_option("--version",action="store_true",help="Print the installed CppDom's version number.")
62    parser.add_option("--cflags",action="store_true",help="Print OpenSG specific cflags.")
63    parser.add_option("--lflags",action="store_true",help="Print library flags.")
64    parser.add_option("--llibs",action="store_true",help="Print library list.")
65    parser.add_option("--libs",action="store_true",help="Print libraries and flags.")
66    parser.add_option("--no-prefix-flags",action="store_true",
67                      help="When printing list of libraries and paths, don't include compiler prefix flags (-I,-l,-L)")
68    parser.add_option("--inc-prefix",default=def_incprefix,
69                      help="Compiler include path prefix to use. (%s)"%def_incprefix)
70    parser.add_option("--lib-prefix",default=def_libprefix,
71                      help="Linker lib prefix to use. (%s)"%def_libprefix)
72    parser.add_option("--libpath-prefix",default=def_libpathprefix,
73                      help="Linker library path prefix to use. (%s)"%def_libpathprefix)
74    parser.add_option("--opt",action="store_true",help="Ignored for backwards compatibility.")
75    parser.add_option("--dbg",action="store_true",help="Ignored for backwards compatibility.")
76
77    (options, pos_args) = parser.parse_args() 
78    
79    # Process simple single options
80    if options.prefix:
81       print inst_prefix
82       return
83    elif options.version:
84       print version
85       return
86    
87    # Try to find libname
88    # - Try given name and name with OSG or OSGWindow prefix
89    libraries = []
90    if len(pos_args):     
91       for n in pos_args:
92          for name_alt in [n, "OSG"+n, "OSGWindow"+n, None]:
93             if not name_alt:
94                print "Error: Can not find library named: ", n           
95             elif lib_map.has_key(name_alt):
96                libraries.append(lib_map[name_alt])
97                break
98
99      
100    # Make sure we have libraries
101    if len(libraries) == 0:
102       printUsage()
103       sys.exit(1)
104
105    # If set to no prefix flags, then clear all defaults
106    if options.no_prefix_flags:
107       options.inc_prefix = ""
108       options.lib_prefix = ""
109       options.libpath_prefix = ""
110    
111    # Create a configuration adapter for the required library
112    default_lib_settings = LibraryInfo()
113    default_lib_settings.libpath.insert(0, inst_lib_path)
114    default_lib_settings.cpppath.insert(0, inst_inc_path)
115    config_info = ConfigInfoAdapter(libraries, lib_map, default_lib_settings,
116                      options.inc_prefix, options.lib_prefix, options.libpath_prefix)
117            
118    if options.cflags:
119       print config_info.getIncPathStr()
120    elif options.libs or options.llibs or options.lflags:
121       if options.libs:
122          print "%s %s"%(config_info.getLibPathStr(), config_info.getLibsStr())
123       elif options.llibs:
124          print config_info.getLibsStr()
125       elif options.lflags:
126          print config_info.getLibPathStr()
127    else:
128       printUsage()
129       sys.exit(1)
130
131    
132
133 def printUsage():
134    global parser, lib_map
135    parser.print_help()
136    print "\nLibraries: "
137    for lib_name in lib_map.keys():
138       print "   %s"%lib_name
139
140 # --- Copied from Source file --- #
141 # DO NOT MODIFY HERE
142 @LIBRARY_UTIL_SRC@
143 # ----------------------------------- #   
144
145 # Main
146 main()
Note: See TracBrowser for help on using the browser.