After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695182 - gi-r-scanner: add support for raw CFLAGS flags option
gi-r-scanner: add support for raw CFLAGS flags option
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
: 693928 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-05 05:48 UTC by darkxst
Modified: 2015-02-07 16:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gi-r-scanner: add support for raw CFLAGS flags option (3.49 KB, patch)
2013-03-05 05:48 UTC, darkxst
reviewed Details | Review
It seems unlikely that there would be a need more than one --cflags argument, so went with the "store" option. (3.48 KB, patch)
2013-03-05 21:04 UTC, darkxst
committed Details | Review
gi-r-scanner: add support for raw CFLAGS flags option (3.63 KB, patch)
2013-03-06 03:11 UTC, darkxst
none Details | Review
0001-tests-Remove-duplicate-specification-of-CPPFLAGS-for.patch (914 bytes, patch)
2013-03-06 17:17 UTC, Colin Walters
accepted-commit_now Details | Review
0002-tests-Pass-a-include-option-for-Regress.patch (1.01 KB, patch)
2013-03-06 17:18 UTC, Colin Walters
accepted-commit_now Details | Review
0003-scanner-Allow-CFLAGS-to-contain-arbitrary-preprocess.patch (3.27 KB, patch)
2013-03-06 17:18 UTC, Colin Walters
none Details | Review
gi-r-scanner: add support for raw CFLAGS flags option (3.61 KB, patch)
2013-03-06 20:40 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review

Description darkxst 2013-03-05 05:48:33 UTC
91c5274 gi-r-scanner: add support for raw CFLAGS flags option
Comment 1 darkxst 2013-03-05 05:48:35 UTC
Created attachment 238086 [details] [review]
gi-r-scanner: add support for raw CFLAGS flags option

gi-r-scanner chokes when gir_CFLAGS have an '-include <header>' since
this is not a recognised option. This commit adds a new --cflags option
that passes cflags directly to the spawned gcc.
Comment 2 Rui Matos 2013-03-05 10:46:17 UTC
*** Bug 693928 has been marked as a duplicate of this bug. ***
Comment 3 Colin Walters 2013-03-05 20:52:09 UTC
Review of attachment 238086 [details] [review]:

The other option is something like:

--begin-cflags $(pkg_FLAGS) --end-cflags

That's probably more difficult to implement though.

::: giscanner/scannermain.py
@@ +47,3 @@
+    group.add_option("--cflags", help="Pre-processor cflags",
+                     action="append", dest="cpp_cflags",
+                     default=[])

So either this should be action="store" default="", or:

::: giscanner/sourcescanner.py
@@ +226,3 @@
+    def set_cpp_options(self, cflags, includes, defines, undefines):
+        if cflags:
+            self._cpp_options = cflags[0].split()

Or this should be:

self._cpp_options = []
for flags in cflags:
  self._cpp_options.extend(flags.split())
Comment 4 darkxst 2013-03-05 21:04:14 UTC
Created attachment 238162 [details] [review]
It seems unlikely that there would be a need more than one --cflags argument, so went with the "store" option.

gi-r-scanner: add support for raw CFLAGS flags option

gi-r-scanner chokes when gir_CFLAGS have an '-include <header>' since
this is not a recognised option. This commit adds a new --cflags option
that passes cflags directly to the spawned gcc.
Comment 5 Colin Walters 2013-03-05 21:05:29 UTC
Review of attachment 238162 [details] [review]:

Looks right.  

(We should probably do the same for the linker flags, but that can be another patch)
Comment 6 Colin Walters 2013-03-05 23:24:52 UTC
Breaks when the CFLAGS have shell-quoted arguments, like gtk2 has:

-DGTK_PRINT_PREVIEW_COMMAND=\""evince --unlink-tempfile --preview --print-settings %s %f"\"
Comment 7 darkxst 2013-03-06 03:11:41 UTC
Created attachment 238179 [details] [review]
gi-r-scanner: add support for raw CFLAGS flags option

gi-r-scanner chokes when gir_CFLAGS have an '-include <header>' since
this is not a recognised option. This commit adds a new --cflags option
that passes cflags directly to the spawned gcc.

This appears to work and passes the newly added enclosed quote test. I don't know if its a bit too much of a hack though?
Comment 8 Colin Walters 2013-03-06 17:17:55 UTC
Created attachment 238214 [details] [review]
0001-tests-Remove-duplicate-specification-of-CPPFLAGS-for.patch
Comment 9 Colin Walters 2013-03-06 17:18:11 UTC
Created attachment 238215 [details] [review]
0002-tests-Pass-a-include-option-for-Regress.patch
Comment 10 Colin Walters 2013-03-06 17:18:52 UTC
Created attachment 238216 [details] [review]
0003-scanner-Allow-CFLAGS-to-contain-arbitrary-preprocess.patch

Ok, this patch series does what I was suggesting with optparse's option callbacks, and I think it's a lot cleaner than attempting to quote and parse shell script syntax.
Comment 11 Jasper St. Pierre (not reading bugmail) 2013-03-06 19:59:18 UTC
Review of attachment 238214 [details] [review]:

OK.
Comment 12 Jasper St. Pierre (not reading bugmail) 2013-03-06 20:15:34 UTC
Review of attachment 238215 [details] [review]:

Should we also use single quotes as well to test all combinations?
Comment 13 Jasper St. Pierre (not reading bugmail) 2013-03-06 20:40:29 UTC
Created attachment 238243 [details] [review]
gi-r-scanner: add support for raw CFLAGS flags option

gi-r-scanner chokes when gir_CFLAGS have an '-include <header>' since
this is not a recognised option. This commit adds a new --cflags option
that passes cflags directly to the spawned gcc.



This one works for me, and I like it better than the --begin-blah stuff.
Comment 14 Colin Walters 2013-03-06 21:43:39 UTC
Review of attachment 238243 [details] [review]:

::: Makefile.introspection
@@ +143,3 @@
 	  $(_gir_libraries) \
 	  $($(_gir_name)_SCANNERFLAGS) \
+	  --cflags='$($(_gir_name)_CFLAGS)' \

This will fail if the CFLAGS contains single quotes.
Comment 15 Colin Walters 2013-03-06 22:53:09 UTC
Pushed after IRC discussion.
Comment 16 André Klapper 2015-02-07 16:56:44 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]