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

Unified Diff: build/gyp_chromium

Issue 203813003: Remove GN integration code from gyp_chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 63e867191e91e9973c946a9c00ccba9f4f36df38..bf21884359b66bd192beee7f66763761259e394f 100755
--- a/build/gyp_chromium
+++ b/build/gyp_chromium
@@ -67,99 +67,6 @@ def GetSupplementalFiles():
return glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
-def FormatKeyForGN(key):
- """Returns the given GYP key reformatted for GN.
-
- GYP dictionary keys can be almost anything, but in GN they are identifiers
- and must follow the same rules. This reformats such keys to be valid GN
- identifiers."""
- return ''.join([c if c in string.ascii_letters else '_' for c in key])
-
-
-def EscapeStringForGN(s):
- """Converts a string to a GN string literal."""
- for old, new in [('\\', '\\\\'), ('$', '\\$'), ('"', '\\"')]:
- s = s.replace(old, new)
- return '"' + s + '"'
-
-
-def ProcessGypDefinesItems(items):
- """Converts a list of strings to a list of key-value pairs."""
- result = []
- for item in items:
- tokens = item.split('=', 1)
- # Some GYP variables have hyphens, which we don't support.
- key = FormatKeyForGN(tokens[0])
- if len(tokens) == 2:
- result += [(key, tokens[1])]
- else:
- # No value supplied, treat it as a boolean and set it. Note that we
- # use the string '1' here so we have a consistent definition whether
- # you do 'foo=1' or 'foo'.
- result += [(key, '1')]
- return result
-
-
-def GetGypVarsForGN(supplemental_files):
- """Returns a dictionary of all GYP vars that we will be passing to GN."""
- # Find the .gyp directory in the user's home directory.
- home_dot_gyp = os.environ.get('GYP_CONFIG_DIR', None)
- if home_dot_gyp:
- home_dot_gyp = os.path.expanduser(home_dot_gyp)
- if not home_dot_gyp:
- home_vars = ['HOME']
- if sys.platform in ('cygwin', 'win32'):
- home_vars.append('USERPROFILE')
- for home_var in home_vars:
- home = os.getenv(home_var)
- if home != None:
- home_dot_gyp = os.path.join(home, '.gyp')
- if not os.path.exists(home_dot_gyp):
- home_dot_gyp = None
- else:
- break
-
- if home_dot_gyp:
- include_gypi = os.path.join(home_dot_gyp, "include.gypi")
- if os.path.exists(include_gypi):
- supplemental_files += [include_gypi]
-
- # GYP defines from the supplemental.gypi files.
- supp_items = []
- for supplement in supplemental_files:
- with open(supplement, 'r') as f:
- try:
- file_data = eval(f.read(), {'__builtins__': None}, None)
- except SyntaxError, e:
- e.filename = os.path.abspath(supplement)
- raise
- variables = file_data.get('variables', [])
- for v in variables:
- supp_items += [(FormatKeyForGN(v), str(variables[v]))]
-
- # GYP defines from the environment.
- 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:]]
- cmdline_items = ProcessGypDefinesItems(cmdline_input_items)
-
- vars_dict = dict(supp_items + env_items + cmdline_items)
- # It's not possible to set a default value for cpu_arch in GN, so do it here
- # for now (http://crbug.com/344767).
- if vars_dict.get('OS') == 'android' and not 'target_arch' in vars_dict:
- vars_dict['target_arch'] = 'arm'
- return vars_dict
-
-
def GetOutputDirectory():
"""Returns the output directory that GYP will use."""
# GYP generator flags from the command line. We can't use optparse since we
@@ -179,103 +86,6 @@ def GetOutputDirectory():
return "out"
-def GetArgsStringForGN(vars_dict):
- """Returns the args to pass to GN.
- Based on a subset of the GYP variables that have been rewritten a bit."""
- gn_args = ''
-
- # Note: These are the additional flags passed to various builds by builders
- # on the main waterfall. We'll probably need to add these at some point:
- # mac_strip_release=1 http://crbug.com/330301
- # linux_dump_symbols=0 http://crbug.com/330300
- # host_os=linux Probably can skip, GN knows the host OS.
- # order_text_section=<path> http://crbug.com/330299
- # chromium_win_pch=0 http://crbug.com/297678
- # chromium_ios_signing=0 http://crbug.com/330302
- # use_allocator=tcmalloc http://crbug.com/330303, 345554
- # release_extra_flags=... http://crbug.com/330305
-
- # These tuples of (key, value, gn_arg_string) use the gn_arg_string for
- # gn when the key is set to the given value in the GYP arguments.
- remap_cases = [
- ('android_webview_build', '1', 'is_android_webview_build=true'),
- ('branding', 'Chrome', 'is_chrome_branded=true'),
- ('build_for_tool', 'drmemory', 'disable_iterator_debugging=true'),
- ('build_for_tool', 'tsan', 'disable_iterator_debugging=true'),
- ('buildtype', 'Official', 'is_official_build=true'),
- ('component', 'shared_library', 'is_component_build=true'),
- ('clang', '1', 'is_clang=true'),
- ('clang_use_chrome_plugins', '0', 'clang_use_chrome_plugins=false'),
- ('disable_glibcxx_debug', '1', 'disable_iterator_debugging=true'),
- ('enable_mdns', '0', 'enable_mdns=false'),
- ('enable_mdns', '1', 'enable_mdns=true'),
- ('enable_plugins', '0', 'enable_plugins=false'),
- ('enable_plugins', '1', 'enable_plugins=true'),
- ('target_arch', 'ia32', 'cpu_arch="x86"'),
- ('target_arch', 'x64', 'cpu_arch="x64" force_win64=true'),
- ('target_arch', 'arm', 'cpu_arch="arm"'),
- ('target_arch', 'mipsel', 'cpu_arch="mipsel"'),
- ('fastbuild', '0', 'symbol_level=2'),
- ('fastbuild', '1', 'symbol_level=1'),
- ('fastbuild', '2', 'symbol_level=0'),
- ('OS', 'ios', 'os="ios"'),
- ('OS', 'android', 'os="android"'),
- ('chromeos', '1', 'os="chromeos"'),
- ('use_aura', '1', 'use_aura=true'),
- ('use_goma', '1', 'use_goma=true'),
- ('use_openssl', '0', 'use_openssl=false'),
- ('use_openssl', '1', 'use_openssl=true'),
- ('asan', '1', 'is_asan=true'),
- ('lsan', '1', 'is_lsan=true'),
- ('msan', '1', 'is_msan=true'),
- ('tsan', '1', 'is_tsan=true'),
- ]
- for i in remap_cases:
- if i[0] in vars_dict and vars_dict[i[0]] == i[1]:
- gn_args += ' ' + i[2]
-
- # These string arguments get passed directly as GN strings.
- for v in ['android_src', 'arm_float_abi', 'ios_deployment_target',
- 'ios_sdk_path', 'windows_sdk_path']:
- if v in vars_dict:
- gn_args += ' ' + v + '=' + EscapeStringForGN(vars_dict[v])
-
- # gomadir is renamed goma_dir in the GN build.
- if 'gomadir' in vars_dict:
- gn_args += ' goma_dir=%s' % EscapeStringForGN(vars_dict['gomadir'])
-
- # Set the "use_ios_simulator" flag if the ios_sdk_path is set.
- if 'ios_sdk_path' in vars_dict:
- if os.path.basename(vars_dict['ios_sdk_path']).lower().startswith(
- 'iphonesimulator'):
- gn_args += ' use_ios_simulator=true'
- else:
- gn_args += ' use_ios_simulator=false'
-
- # These arguments get passed directly as integers (avoiding the quoting and
- # escaping of the string ones above).
- for v in ['arm_version']:
- if v in vars_dict:
- gn_args += ' %s=%s' % (v, vars_dict[v])
-
- # Some other flags come from GYP environment variables.
- gyp_msvs_version = os.environ.get('GYP_MSVS_VERSION', '')
- if gyp_msvs_version:
- gn_args += ' visual_studio_version=' + EscapeStringForGN(gyp_msvs_version)
- gyp_msvs_override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH', '')
- if gyp_msvs_override_path:
- gn_args += ' visual_studio_path=' + \
- EscapeStringForGN(gyp_msvs_override_path)
-
- # Set the GYP flag so BUILD files know they're being invoked in GYP mode.
- gn_args += ' is_gyp=true'
-
- gyp_outdir = GetOutputDirectory()
- gn_args += ' gyp_output_dir=\"%s\"' % gyp_outdir
-
- return gn_args.strip()
-
-
def additional_include_files(supplemental_files, args=[]):
"""
Returns a list of additional (.gypi) files to include, without duplicating
@@ -306,38 +116,6 @@ def additional_include_files(supplemental_files, args=[]):
return result
-def RunGN(vars_dict):
- """Runs GN, returning True if it succeeded, printing an error and returning
- false if not."""
-
- # The binaries in platform-specific subdirectories in src/tools/gn/bin.
- gnpath = SRC_DIR + '/tools/gn/bin/'
- if sys.platform in ('cygwin', 'win32'):
- gnpath += 'win/gn.exe'
- elif sys.platform.startswith('linux'):
- # On Linux we have 32-bit and 64-bit versions.
- if subprocess.check_output(["getconf", "LONG_BIT"]).find("64") >= 0:
- gnpath += 'linux/gn'
- else:
- gnpath += 'linux/gn32'
- elif sys.platform == 'darwin':
- gnpath += 'mac/gn'
- else:
- print 'Unknown platform for GN: ', sys.platform
- return False
-
- print 'Generating gyp files from GN...'
-
- # Need to pass both the source root (the bots don't run this command from
- # within the source tree) as well as set the is_gyp value so the BUILD files
- # to know they're being run under GYP.
- args = [gnpath, 'gyp', '-q',
- '--root=' + chrome_src,
- '--args=' + GetArgsStringForGN(vars_dict),
- '--output=//' + GetOutputDirectory() + '/gn_build/']
- return subprocess.call(args) == 0
-
-
def GetDesiredVsToolchainHashes():
"""Load a list of SHA1s corresponding to the toolchains that we want installed
to build with."""
@@ -540,7 +318,6 @@ if __name__ == '__main__':
args.append('--check')
supplemental_includes = GetSupplementalFiles()
- gn_vars_dict = GetGypVarsForGN(supplemental_includes)
# Automatically turn on crosscompile support for platforms that need it.
# (The Chrome OS build sets CC_host / CC_target which implicitly enables
@@ -550,9 +327,6 @@ if __name__ == '__main__':
'GYP_CROSSCOMPILE' not in os.environ)):
os.environ['GYP_CROSSCOMPILE'] = '1'
- # TODO(brettw) bug 350974 either turn back on GN or delete all of this code.
- #if not RunGN(gn_vars_dict):
- # sys.exit(1)
args.extend(
['-I' + i for i in additional_include_files(supplemental_includes, 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