GNOME Bugzilla – Bug 660160
gir-scanner fails if $CC includes arguments
Last modified: 2015-02-07 17:00:58 UTC
With a diagnostic print added at sourcescanner.py line 280: ['/usr/bin/gcc-4.2 -std=gnu99', '-E', '-C', '-I.', '-', '-I..', '-I../gdk', '-I/usr/local/gtk-unstable-3/inst/include/glib-2.0', '-I/usr/local/gtk-unstable-3/inst/lib/glib-2.0/include', '-I/usr/local/gtk-unstable-3/inst/include/pango-1.0', '-I/usr/local/gtk-unstable-3/inst/include/cairo', '-I/usr/local/gtk-unstable-3/inst/include/pixman-1', '-I/usr/local/gtk-unstable-3/inst/include/freetype2', '-I/usr/local/gtk-unstable-3/inst/include/libpng12', '-I/usr/local/gtk-unstable-3/inst/include/gdk-pixbuf-2.0', '-I/usr/local/gtk-unstable-3/inst/include/gio-unix-2.0/', '-DG_LOG_DOMAIN="Gdk"', '-DGDK_COMPILATION', '-DG_DISABLE_CAST_CHECKS', '-D_REENTRANT'] Traceback (most recent call last):
+ Trace 228582
sys.exit(scanner_main(sys.argv))
ss = create_source_scanner(options, args)
ss.parse_files(filenames)
self._parse(headers)
stdout=subprocess.PIPE)
errread, errwrite)
raise child_exception
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py index 5f0ec2d..f7d4879 100644 --- a/giscanner/sourcescanner.py +++ b/giscanner/sourcescanner.py @@ -274,7 +274,7 @@ class SourceScanner(object): defines = ['__GI_SCANNER__'] undefs = [] - cpp_args = [os.environ.get('CC', 'cc'), '-E', '-C', '-I.', '-'] + cpp_args = os.environ.get('CC', 'cc').split() + '-E', '-C', '-I.', '-'] cpp_args += self._cpp_options proc = subprocess.Popen(cpp_args, Fixes the problem.
*** Bug 660162 has been marked as a duplicate of this bug. ***
With the patch added gobject-introspection doesn't build: Traceback (most recent call last):
+ Trace 228602
from giscanner.scannermain import scanner_main
from giscanner.dumper import compile_introspection_binary
from .gdumpparser import IntrospectionBinary
from .transformer import TransformerException
from .sourcescanner import (
cpp_args = os.environ.get('CC', 'cc').split() + '-E', '-C', '-I.', '-']
Sorry, the line should be + cpp_args = os.environ.get('CC', 'cc').split() + ['-E', '-C', '-I.', '-']
Even with the 2nd patch, it doesn't build: GICOMP gir/cairo-1.0.gir Traceback (most recent call last):
+ Trace 228603
cpp_args += self._cpp_options
make[3]: *** [GLib-2.0.gir] Error 1
What version of Python are you using that you're getting a tuple instead of a list from string.split()?
I'm using python-2.6.6 (slackware). I got g-i to compile by changing the line to: + cpp_args = [os.environ.get('CC', 'cc').split() + '-E', '-C', '-I.', '-'] The result still dies; e.g., in gdk-pixbuf-2.24.0: make[5]: Entering directory `/home/ronis/Project/notar/GNOME/garnome/platform/gdk-pixbuf/work/main.d/gdk-pixbuf-2.24.0/gdk-pixbuf' /opt/garnome-svn-3.2.0/bin/g-ir-scanner --namespace=GdkPixbuf --nsversion=2.0 --libtool="/bin/sh ../libtool" --include=GModule-2.0 --include=Gio-2.0 --pkg-export=gdk-pixbuf-2.0 --library=libgdk_pixbuf-2.0.la --warn-all --strip-prefix=Gdk --c-include="gdk-pixbuf/gdk-pixbuf.h" -DGDK_PIXBUF_COMPILATION -I.. -I.. -I../gdk-pixbuf -I../gdk-pixbuf -pthread -I/opt/garnome-svn-3.2.0/include/glib-2.0 -I/opt/garnome-svn-3.2.0/lib/glib-2.0/include -I/usr/include/libpng14 gdk-pixbuf.h gdk-pixbuf-core.h gdk-pixbuf-transform.h gdk-pixbuf-io.h gdk-pixbuf-animation.h gdk-pixbuf-simple-anim.h gdk-pixbuf-loader.h gdk-pixbuf-enum-types.h gdk-pixbuf-marshal.h gdk-pixbuf-features.h gdk-pixdata.h gdk-pixbuf-i18n.h gdk-pixbuf.c gdk-pixbuf-animation.c gdk-pixbuf-data.c gdk-pixbuf-io.c gdk-pixbuf-loader.c gdk-pixbuf-scale.c gdk-pixbuf-simple-anim.c gdk-pixbuf-scaled-anim.c gdk-pixbuf-util.c gdk-pixdata.c gdk-pixbuf-enum-types.c libgdk_pixbuf-2.0.la Makefile --output GdkPixbuf-2.0.gir g-ir-scanner: warning: Option --strip-prefix has been deprecated; see --identifier-prefix and --symbol-prefix. Traceback (most recent call last):
+ Trace 228604
make[5]: *** [GdkPixbuf-2.0.gir] Error 1
It's still not splitting out correctly, then. Put this in after the assignment of cpp_args: print cpp_args You want a single list that looks something like ['/usr/bin/gcc', '-first_arg', '-E', '-C', '-I.', '-'] but you're probably getting [('/usr/bin/gcc', '-first_arg'), '-E', '-C', '-I.', '-'] because your (defective) python is returning that tuple. I think you can fix it with cpp_args = list(os.environ.get('CC', 'cc')) + ['-E', '-C', '-I.','-'] which is harmless in properly working pythons which return a list from string.split() as documented.
Strange, I purged the directories and rebuilt. The form of the patch I suggested in comment 6 now fails, while yours in comment 3 or 7 cpp_args = list(os.environ.get('CC', 'cc')) + ['-E', '-C', '-I.','-'] now works, and gdk-pixbuf builds without complaint. Thanks.
Created attachment 198714 [details] [review] 0001-scanner-split-CC-environment-variable.patch
Review of attachment 198714 [details] [review]: This isn't going to work if the environment variable contains quoted whitespace, like: export CC="'/home/walters/Source Code/gcc'". On the other hand, make doesn't work either. So...I guess we can just do this.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]