[gtk-doc/scangobj-quotes-fix: 2/2] gtkdoc-scangobj: allow to pass --{c, ld}flags multiple times



commit 0ffa6eb14cb8234e8bb7767ec683996e9830c725
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Sep 12 22:32:52 2018 +0200

    gtkdoc-scangobj: allow to pass --{c,ld}flags multiple times
    
    Instead of supporting the cflags argument just once, allow to pass it multiple
    times. This allows build systems like meson to append cflags using
    `scanobjs_args` the parameter.
    
    Updated tests accordingly to check this.

 gtkdoc-scangobj.in                      | 10 ++++++++--
 tests/helpers/gtkdoc_scangobj_runner.py | 19 ++++++++-----------
 2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/gtkdoc-scangobj.in b/gtkdoc-scangobj.in
index 4cbe130..9676956 100755
--- a/gtkdoc-scangobj.in
+++ b/gtkdoc-scangobj.in
@@ -43,8 +43,10 @@ if __name__ == '__main__':
                         help='The directory where the results are stored')
     parser.add_argument('--cc', default='', help='The compiler to use')
     parser.add_argument('--ld', default='', help='The linker to use')
-    parser.add_argument('--cflags', default='', help='Compiler flags')
-    parser.add_argument('--ldflags', default='', help='Linker flags')
+    parser.add_argument('--cflags', type=str, default=[], help='Compiler flags',
+                        action='append')
+    parser.add_argument('--ldflags', type=str, default=[], help='Linker flags',
+                        action='append')
     parser.add_argument('--run', default='',
                         help='Command for running the scanner')
     parser.add_argument('--verbose', action='store_true', default=False,
@@ -54,6 +56,10 @@ if __name__ == '__main__':
 
     if options.types == '':
         options.types = os.path.join(options.output_dir, options.module + '.types')
+    if options.cflags:
+        options.cflags = ' '.join(options.cflags)
+    if options.ldflags:
+        options.ldflags = ' '.join(options.ldflags)
 
     if not options.cc:
         options.cc = os.environ.get('CC', 'gcc')
diff --git a/tests/helpers/gtkdoc_scangobj_runner.py b/tests/helpers/gtkdoc_scangobj_runner.py
index 45067ac..c3546f7 100644
--- a/tests/helpers/gtkdoc_scangobj_runner.py
+++ b/tests/helpers/gtkdoc_scangobj_runner.py
@@ -30,28 +30,25 @@ if __name__ == '__main__':
                     '--cflags'] + options.extra_pkg,
                     stdout=PIPE, stderr=PIPE)
 
-    cflags = []
     output, error = process.communicate()
     if process.returncode == 0:
-        cflags += output.rstrip().decode('utf-8').split(' ')
+        cflags = output.rstrip().decode('utf-8')
+        arguments.append('--cflags={0}'.format(cflags))
 
-    cflags += options.extra_cflags
-    arguments.append('--cflags={0}'.format(' '.join(cflags)))
+    for flag in options.extra_cflags:
+        arguments.append('--cflags={0}'.format(flag))
 
     process = Popen([options.pkg_config,
                     '--libs'] + options.extra_pkg,
                     stdout=PIPE, stderr=PIPE)
 
-    libs = []
     output, error = process.communicate()
     if process.returncode == 0:
-        libs += output.rstrip().decode('utf-8').split(' ')
+        arguments.append('--ldflags={0}'.format(output.rstrip().decode('utf-8')))
 
     for lib in options.extra_lib:
-        libs.append('-l{0}'.format(os.path.basename(lib).split('.')[0].lstrip('lib')))
-        libs.append('-L{0}'.format(os.path.dirname(lib)))
-        libs.append('-Wl,-rpath,{0}'.format(os.path.dirname(lib)))
-
-    arguments.append('--ldflags={0}'.format(' '.join(libs)))
+        arguments.append('--ldflags=-l{0}'.format(os.path.basename(lib).split('.')[0].lstrip('lib')))
+        arguments.append('--ldflags=-L{0}'.format(os.path.dirname(lib)))
+        arguments.append('--ldflags=-Wl,-rpath,{0}'.format(os.path.dirname(lib)))
 
     sys.exit(call(arguments))


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