[gobject-introspection] giscanner: Use shlex.split() for environment variables
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Use shlex.split() for environment variables
- Date: Tue, 21 Mar 2017 09:10:18 +0000 (UTC)
commit e714202055483286d77467ec7f393ad23c8683c8
Author: Nirbheek Chauhan <nirbheek centricular com>
Date: Mon Feb 20 23:10:34 2017 +0530
giscanner: Use shlex.split() for environment variables
str.split() does not handle quoting, so if you have spaces in your
CFLAGS, it will be split incorrectly. For instance:
CFLAGS="'-I/opt/some dir' -DFOO=bar"
>>> os.environ['CFLAGS'].split()
["'-I/opt/some", "dir'", '-DFOO=bar']
>>> shlex.split(os.environ['CFLAGS'])
['-I/opt/some dir', '-DFOO=bar']
https://bugzilla.gnome.org/show_bug.cgi?id=778971
giscanner/ccompiler.py | 3 ++-
giscanner/dumper.py | 10 ++++------
2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 11bc9fc..7c1895d 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -19,6 +19,7 @@
#
import os
+import shlex
import subprocess
import tempfile
@@ -213,7 +214,7 @@ class CCompiler(object):
# This is to handle the case where macros are defined in CFLAGS
cflags = os.environ.get('CFLAGS')
if cflags:
- for i, cflag in enumerate(cflags.split()):
+ for i, cflag in enumerate(shlex.split(cflags)):
if cflag.startswith('-D'):
stridx = cflag.find('=')
if stridx > -1:
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 9077d20..f48fcc1 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -26,6 +26,7 @@ from __future__ import unicode_literals
import os
import sys
+import shlex
import subprocess
import shutil
import tempfile
@@ -232,14 +233,11 @@ class DumpCompiler(object):
# MSVC Builds use the INCLUDE, LIB envvars,
# which are automatically picked up during
# compilation and linking
- cppflags = os.environ.get('CPPFLAGS', '')
- for cppflag in cppflags.split():
+ for cppflag in shlex.split(os.environ.get('CPPFLAGS', '')):
args.append(cppflag)
- cflags = os.environ.get('CFLAGS', '')
- for cflag in cflags.split():
+ for cflag in shlex.split(os.environ.get('CFLAGS', '')):
args.append(cflag)
- ldflags = os.environ.get('LDFLAGS', '')
- for ldflag in ldflags.split():
+ for ldflag in shlex.split(os.environ.get('LDFLAGS', '')):
args.append(ldflag)
# Make sure to list the library to be introspected first since it's
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]