[STRIP_SUFFIX] ability to flag suffixes to be stripped.
[gnome.gobject-introspection] / giscanner / scannermain.py
index 4b74253..6ef80ee 100644 (file)
@@ -58,7 +58,7 @@ def _get_option_parser():
                       help="full path to libtool")
     parser.add_option("", "--no-libtool",
                       action="store_true", dest="nolibtool", default=False,
-                      help="use libtool")
+                      help="do not use libtool")
     parser.add_option("-l", "--library",
                       action="append", dest="libraries", default=[],
                       help="libraries of this unit")
@@ -75,12 +75,22 @@ def _get_option_parser():
     parser.add_option("", "--strip-prefix",
                       action="store", dest="strip_prefix", default=None,
                       help="remove this prefix from objects and functions")
+    parser.add_option("", "--strip-suffix",
+                      action="store", dest="strip_suffix", default=None,
+                      help="remove this suffix from objects and functions, "
+                           "only done when also removing prefix")
+    parser.add_option("", "--add-init-section",
+                      action="append", dest="init_sections", default=[],
+            help="add extra initialization code in the introspection program")
     parser.add_option("-o", "--output",
                       action="store", dest="output",
                       help="output to writeout, defaults to stdout")
     parser.add_option("", "--pkg",
                       action="append", dest="packages", default=[],
                       help="pkg-config packages to get cflags from")
+    parser.add_option("", "--pkg-export",
+                      action="append", dest="packages_export", default=[],
+                      help="Associated pkg-config packages for this library")
     parser.add_option("-v", "--verbose",
                       action="store_true", dest="verbose",
                       help="be verbose")
@@ -247,20 +257,6 @@ def scanner_main(args):
         _error("Must specify --program or --library")
     libraries = options.libraries
 
-    # FIXME: using LPATH is definitely not portable enough. Using Python's
-    # find_library for finding our shared libraries is not a portable enough
-    # anyway as it behaves differently depending on the OS
-    lpath = os.environ.get('LPATH')
-    library_path = ':'.join(options.library_paths)
-
-    ld_library_path = os.environ.get('LD_LIBRARY_PATH')
-    if ld_library_path:
-        library_path = ':'.join([ld_library_path, library_path])
-
-    if lpath:
-        os.environ['LPATH'] = ':'.join([lpath, library_path])
-    else:
-        os.environ['LPATH'] = library_path
     filenames = []
     for arg in args:
         if (arg.endswith('.c') or
@@ -279,12 +275,17 @@ def scanner_main(args):
         transformer.set_strip_prefix(options.strip_prefix)
     else:
         transformer.set_strip_prefix(options.namespace_name)
+    transformer.set_strip_suffix(options.strip_suffix)        
     transformer.set_include_paths(options.include_paths)
     shown_include_warning = False
     for include in options.includes:
         if os.sep in include:
             raise ValueError("Invalid include path %r" % (include, ))
-        include_obj = Include.from_string(include)
+        try:
+            include_obj = Include.from_string(include)
+        except:
+            sys.stderr.write("Malformed include %r\n" % (include, ))
+            sys.exit(1)
         transformer.register_include(include_obj)
 
     packages = set(options.packages)
@@ -333,8 +334,12 @@ def scanner_main(args):
         raise SystemExit("ERROR in annotation: %s" % (str(e), ))
 
     # Write out AST
+    if options.packages_export:
+        exported_packages = options.packages_export
+    else:
+        exported_packages = options.packages
     writer = Writer(namespace, shlibs, transformer.get_includes(),
-                    options.packages, options.c_includes,
+                    exported_packages, options.c_includes,
                     transformer.get_strip_prefix())
     data = writer.get_xml()
     if options.output: