[gobject-introspection] sourcescannermain.py: Add --filelist option



commit 5c70ef2eb32949f8889e9ae654d50bfbf838951f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Aug 10 12:40:10 2012 +0800

    sourcescannermain.py: Add --filelist option
    
    Add a function to put the files to pass to g-ir-scanner in a filelist
    file, with one source/header file on a single line.  This is done to
    work around the limitation of Windows cmd.exe (and MSYS) where the command
    line cannot exceed 8192 characters.
    
    When this option is used, g-ir-scanner will only look for the header/source
    files that are specified in the filelist file, which is not too hard to
    generate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681820

 giscanner/scannermain.py |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 794cede..6efd291 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -158,6 +158,9 @@ match the namespace prefix.""")
     parser.add_option("", "--c-include",
                       action="append", dest="c_includes", default=[],
                       help="headers which should be included in C programs")
+    parser.add_option("", "--filelist",
+                      action="store", dest="filelist", default=[],
+                      help="file containing headers and sources to be scanned")
 
     group = get_preprocessor_option_group(parser)
     parser.add_option_group(group)
@@ -250,6 +253,27 @@ def extract_filenames(args):
             filenames.append(os.path.abspath(arg))
     return filenames
 
+def extract_filelist(options):
+    filenames = []
+    if not os.path.exists(options.filelist):
+        _error('%s: no such filelist file' % (options.filelist, ))
+    filelist_file = open(options.filelist, "r")
+    lines = filelist_file.readlines()
+    for line in lines:
+        # We don't support real C++ parsing yet, but we should be able
+        # to understand C API implemented in C++ files.
+        filename = line.strip()
+        if (filename.endswith('.c') or filename.endswith('.cpp') or
+            filename.endswith('.cc') or filename.endswith('.cxx') or
+            filename.endswith('.h') or filename.endswith('.hpp') or
+            filename.endswith('.hxx')):
+            if not os.path.exists(filename):
+                _error('%s: Invalid filelist entry-no such file or directory' % (line, ))
+            # Make absolute, because we do comparisons inside scannerparser.c
+            # against the absolute path that cpp will give us
+            filenames.append(os.path.abspath(filename))
+    return filenames
+
 def create_namespace(options):
     if options.strip_prefix:
         print """g-ir-scanner: warning: Option --strip-prefix has been deprecated;
@@ -324,7 +348,10 @@ def create_binary(transformer, options, args):
     return shlibs
 
 def create_source_scanner(options, args):
-    filenames = extract_filenames(args)
+    if options.filelist:
+        filenames = extract_filelist(options)
+    else:
+        filenames = extract_filenames(args)
 
     # Run the preprocessor, tokenize and construct simple
     # objects representing the raw C symbols
@@ -381,8 +408,9 @@ def scanner_main(args):
     if options.test_codegen:
         return test_codegen(options.test_codegen)
 
-    if len(args) <= 1:
-        _error('Need at least one filename')
+    if not options.filelist:
+        if len(args) <= 1:
+            _error('Need at least one filename')
 
     if not options.namespace_name:
         _error('Namespace name missing')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]