Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: build/gyp_chromium

Issue 896663002: gyp_chromium: Better parsing of -G command line flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/gyp_chromium
diff --git a/build/gyp_chromium b/build/gyp_chromium
index 11125751a0e5b0e515741ee8d18cd96c608a40e0..82f4dfe050c33904b3df0a530b33cdf493ddbcc0 100755
--- a/build/gyp_chromium
+++ b/build/gyp_chromium
@@ -7,6 +7,7 @@
# This script is wrapper for Chromium that adds some support for how GYP
# is invoked by Chromium beyond what can be done in the gclient hooks.
+import argparse
import glob
import gyp_environment
import os
@@ -124,15 +125,10 @@ def GetGypVars(supplemental_files):
env_items = ProcessGypDefinesItems(
shlex.split(os.environ.get('GYP_DEFINES', '')))
- # GYP defines from the command line. We can't use optparse since we want
- # to ignore all arguments other than "-D".
- cmdline_input_items = []
- for i in range(len(sys.argv))[1:]:
- if sys.argv[i].startswith('-D'):
- if sys.argv[i] == '-D' and i + 1 < len(sys.argv):
- cmdline_input_items += [sys.argv[i + 1]]
- elif len(sys.argv[i]) > 2:
- cmdline_input_items += [sys.argv[i][2:]]
+ # GYP defines from the command line.
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-D', dest='defines', action='append', default=[])
+ cmdline_input_items = parser.parse_known_args()[0].defines
cmdline_items = ProcessGypDefinesItems(cmdline_input_items)
vars_dict = dict(supp_items + env_items + cmdline_items)
@@ -141,21 +137,21 @@ def GetGypVars(supplemental_files):
def GetOutputDirectory():
"""Returns the output directory that GYP will use."""
- # GYP generator flags from the command line. We can't use optparse since we
- # want to ignore all arguments other than "-G".
- needle = '-Goutput_dir='
- cmdline_input_items = []
- for item in sys.argv[1:]:
- if item.startswith(needle):
- return item[len(needle):]
- env_items = shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', ''))
+ # handle command line generator flags
scottmg 2015/02/03 01:26:45 nit; capital H, end with '.'.
Sam Clegg 2015/02/03 02:04:13 Done.
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-G', dest='genflags', default=[], action='append')
+ genflags = parser.parse_known_args()[0].genflags
+
+ # handle generator flags from the environment
scottmg 2015/02/03 01:26:45 same
Sam Clegg 2015/02/03 02:04:13 Done.
+ genflags += shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', ''))
+
needle = 'output_dir='
- for item in env_items:
+ for item in genflags:
if item.startswith(needle):
return item[len(needle):]
- return "out"
+ return 'out'
def additional_include_files(supplemental_files, args=[]):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698