summaryrefslogtreecommitdiffstats
path: root/build/toolchain
diff options
context:
space:
mode:
authordpranke <dpranke@chromium.org>2014-12-02 14:06:59 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-02 22:07:14 +0000
commitc9960f39142de51b59f38d1ddc1f6fe7aad92cb0 (patch)
tree73aa967c9d1a64b25f741ef7c936f409f313e357 /build/toolchain
parenta3a9b8c0b016c57d777d468a97f6612b1c66b7af (diff)
downloadchromium_src-c9960f39142de51b59f38d1ddc1f6fe7aad92cb0.zip
chromium_src-c9960f39142de51b59f38d1ddc1f6fe7aad92cb0.tar.gz
chromium_src-c9960f39142de51b59f38d1ddc1f6fe7aad92cb0.tar.bz2
Make goma work on win GN builds.
R=scottmg@chromium.org, brettw@chromium.org BUG=354261 Review URL: https://codereview.chromium.org/738333002 Cr-Commit-Position: refs/heads/master@{#306469}
Diffstat (limited to 'build/toolchain')
-rw-r--r--build/toolchain/win/BUILD.gn42
-rw-r--r--build/toolchain/win/setup_toolchain.py19
2 files changed, 50 insertions, 11 deletions
diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn
index 1bd6730..1be1cf4 100644
--- a/build/toolchain/win/BUILD.gn
+++ b/build/toolchain/win/BUILD.gn
@@ -2,6 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+declare_args() {
+ # Path to the directory containing the VC binaries for the right
+ # combination of host and target architectures. Currently only the
+ # 64-bit host toolchain is supported, with either 32-bit or 64-bit targets.
+ # If vc_bin_dir is not specified on the command line (and it normally
+ # isn't), we will dynamically determine the right value to use at runtime.
+ vc_bin_dir = ""
+}
+
import("//build/config/win/visual_studio_version.gni")
import("//build/toolchain/goma.gni")
@@ -15,13 +24,20 @@ assert(is_win)
# list to us.
gyp_win_tool_path =
rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir)
-exec_script("setup_toolchain.py",
- [
- visual_studio_path,
- gyp_win_tool_path,
- windows_sdk_path,
- visual_studio_runtime_dirs,
- ])
+
+toolchain_data = exec_script("setup_toolchain.py",
+ [
+ visual_studio_path,
+ gyp_win_tool_path,
+ windows_sdk_path,
+ visual_studio_runtime_dirs,
+ cpu_arch,
+ ],
+ "scope")
+
+if (vc_bin_dir == "") {
+ vc_bin_dir = toolchain_data.vc_bin_dir
+}
# This value will be inherited in the toolchain below.
concurrent_links = exec_script("../get_concurrent_links.py", [], "value")
@@ -49,6 +65,14 @@ template("msvc_toolchain") {
invoker.cpu_arch,
])
+ if (use_goma) {
+ goma_prefix = "$goma_dir/gomacc.exe "
+ } else {
+ goma_prefix = ""
+ }
+
+ cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\""
+
toolchain(target_name) {
# Make these apply to all tools below.
lib_switch = ""
@@ -58,7 +82,7 @@ template("msvc_toolchain") {
rspfile = "{{output}}.rsp"
pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb"
command =
- "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
+ "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
depsformat = "msvc"
description = "CC {{output}}"
outputs =
@@ -72,7 +96,7 @@ template("msvc_toolchain") {
# The PDB name needs to be different between C and C++ compiled files.
pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb"
command =
- "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
+ "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
depsformat = "msvc"
description = "CXX {{output}}"
outputs =
diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py
index 42c3af1..6b7ea7a 100644
--- a/build/toolchain/win/setup_toolchain.py
+++ b/build/toolchain/win/setup_toolchain.py
@@ -98,20 +98,26 @@ def _CopyTool(source_path):
def main():
- if len(sys.argv) != 5:
+ if len(sys.argv) != 6:
print('Usage setup_toolchain.py '
- '<visual studio path> <win tool path> <win sdk path> <runtime dirs>')
+ '<visual studio path> <win tool path> <win sdk path> '
+ '<runtime dirs> <cpu_arch>')
sys.exit(2)
vs_path = sys.argv[1]
tool_source = sys.argv[2]
win_sdk_path = sys.argv[3]
runtime_dirs = sys.argv[4]
+ cpu_arch = sys.argv[5]
_CopyTool(tool_source)
archs = ('x86', 'x64')
+ assert cpu_arch in archs
+ vc_bin_dir = ''
+
# TODO(scottmg|goma): Do we need an equivalent of
# ninja_use_custom_environment_files?
+
for arch in archs:
# Extract environment variables for subprocesses.
args = _SetupScript(arch, win_sdk_path)
@@ -122,6 +128,12 @@ def main():
env = _ExtractImportantEnvironment(variables)
env['PATH'] = runtime_dirs + ';' + env['PATH']
+ if arch == cpu_arch:
+ for path in env['PATH'].split(os.pathsep):
+ if os.path.exists(os.path.join(path, 'cl.exe')):
+ vc_bin_dir = os.path.realpath(path)
+ break
+
# TODO(scottmg|thakis|dpranke): Is there an equivalent to
# msvs_system_include_dirs that we need to inject into INCLUDE here?
@@ -129,6 +141,9 @@ def main():
with open('environment.' + arch, 'wb') as f:
f.write(env_block)
+ assert vc_bin_dir
+ print 'vc_bin_dir = "%s"' % vc_bin_dir
+
if __name__ == '__main__':
main()