From d1fd7fbea2949f3e90d75342c26459578bab50d8 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Fri, 22 Aug 2008 21:24:47 +0000 Subject: [PATCH] Send in undefs/defines via writing it directly to stdin of cpp instead of 2008-08-22 Johan Dahlin * gir/Makefile.am: * giscanner/sourcescanner.py: Send in undefs/defines via writing it directly to stdin of cpp instead of via arguments. svn path=/trunk/; revision=463 --- ChangeLog | 7 +++++++ gir/Makefile.am | 2 +- giscanner/sourcescanner.py | 27 +++++++++++++++------------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66305e5..1d4447c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-08-22 Johan Dahlin + + * gir/Makefile.am: + * giscanner/sourcescanner.py: + Send in undefs/defines via writing it directly to stdin + of cpp instead of via arguments. + 2008-08-22 Colin Walters * tools/generate.c, tools/compiler.c: Default diff --git a/gir/Makefile.am b/gir/Makefile.am index 14be052..e5e9239 100644 --- a/gir/Makefile.am +++ b/gir/Makefile.am @@ -66,7 +66,7 @@ girdir=$(datadir)/gir dist_gir_DATA = $(BUILT_SOURCES) %.typelib: %.gir - $(top_builddir)/tools/g-ir-compiler $< --raw -o $@ + $(top_builddir)/tools/g-ir-compiler $< -o $@ typelibsdir = $(datadir)/gitypelibs typelibs_DATA = GLib.typelib GObject.typelib Gio.typelib diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py index 092fda3..4315cdc 100644 --- a/giscanner/sourcescanner.py +++ b/giscanner/sourcescanner.py @@ -223,20 +223,18 @@ class SourceScanner(object): if not filenames: return - cpp_args = [ - 'cpp', - '-C', - '-U__GNUC__', - '-D__GI_SCANNER__', - # libintl.h has no types we care about and breaks - # cpp on some systems - '-D_LIBINTL_H', - '-I.', - ] + defines = ['__GI_SCANNER__'] + undefs = ['__GNUC__'] + cpp_args = ['cpp', '-C', '-I.'] + + # libintl.h has no types we care about and breaks + # cpp on some systems + defines.append('_LIBINTL_H') # Do not parse the normal glibconfig.h, use the # one we provide instead - cpp_args.append('-D__G_LIBCONFIG_H__') + defines.append('__G_LIBCONFIG_H__') + dirname = os.path.dirname(os.path.abspath(__file__)) includedir = os.path.join(dirname, '..', 'giscanner') if not os.path.exists(includedir): @@ -247,7 +245,12 @@ class SourceScanner(object): proc = subprocess.Popen(cpp_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) - + for define in defines: + proc.stdin.write('#ifndef %s\n' % (define, )) + proc.stdin.write('# define %s\n' % (define, )) + proc.stdin.write('#endif\n') + for undef in undefs: + proc.stdin.write('#undef %s\n' % (undef, )) for filename in filenames: filename = os.path.abspath(filename) proc.stdin.write('#include <%s>\n' % (filename, )) -- 2.7.4