diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-02-06 11:13:24 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-31 11:52:27 +0200 |
commit | 9647f1aaa87e1a412b941f8e4ea03d5cbb4ea3a7 (patch) | |
tree | 3e7811390ef6869783a736cc54aba3a4413b095b /chromium/build | |
parent | a631a70e2bde4b6257bddf6539c74e11a5b68dcc (diff) | |
download | qtwebengine-chromium-9647f1aaa87e1a412b941f8e4ea03d5cbb4ea3a7.tar.gz |
Reintroduce ninja_use_custom_environment_files
For Qt we want to read the environment variable from the environment not
from Google's downloaded packages.
Change-Id: I52def6474daec97cc63cda415d279cbe29881d08
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/build')
-rw-r--r-- | chromium/build/config/win/BUILD.gn | 30 | ||||
-rw-r--r-- | chromium/build/config/win/visual_studio_version.gni | 12 | ||||
-rw-r--r-- | chromium/build/toolchain/win/BUILD.gn | 62 | ||||
-rw-r--r-- | chromium/build/toolchain/win/setup_toolchain.py | 123 |
4 files changed, 136 insertions, 91 deletions
diff --git a/chromium/build/config/win/BUILD.gn b/chromium/build/config/win/BUILD.gn index 38d95ea0d65..f05e5a28585 100644 --- a/chromium/build/config/win/BUILD.gn +++ b/chromium/build/config/win/BUILD.gn @@ -309,16 +309,26 @@ config("sdk_link") { ldflags = [ "/MACHINE:ARM64" ] } - vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - current_os, - current_cpu, - "none", - ], - "scope") + if (ninja_use_custom_environment_files) { + vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_os, + current_cpu, + "none" + ], + "scope") + } else { + vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + current_os, + current_cpu, + "none", + ], + "scope") + } vc_lib_path = vcvars_toolchain_data.vc_lib_path if (defined(vcvars_toolchain_data.vc_lib_atlmfc_path)) { diff --git a/chromium/build/config/win/visual_studio_version.gni b/chromium/build/config/win/visual_studio_version.gni index 982fbe8d3f0..3bc58fe4d7a 100644 --- a/chromium/build/config/win/visual_studio_version.gni +++ b/chromium/build/config/win/visual_studio_version.gni @@ -20,9 +20,11 @@ declare_args() { # This value is the default location, override if you have a different # installation location. windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10" + + ninja_use_custom_environment_files = true } -if (visual_studio_path == "") { +if (visual_studio_path == "" && ninja_use_custom_environment_files) { toolchain_data = exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope") visual_studio_path = toolchain_data.vs_path @@ -33,7 +35,9 @@ if (visual_studio_path == "") { } else { assert(visual_studio_version != "", "You must set the visual_studio_version if you set the path") - assert(wdk_path != "", - "You must set the wdk_path if you set the visual studio path") - visual_studio_runtime_dirs = [] + if (ninja_use_custom_environment_files) { + assert(wdk_path != "", + "You must set the wdk_path if you set the visual studio path") + } + visual_studio_runtime_dirs = "\"\"" } diff --git a/chromium/build/toolchain/win/BUILD.gn b/chromium/build/toolchain/win/BUILD.gn index 1eba0486d0a..78eef618663 100644 --- a/chromium/build/toolchain/win/BUILD.gn +++ b/chromium/build/toolchain/win/BUILD.gn @@ -34,7 +34,7 @@ if (use_goma) { # Copy the VS runtime DLL for the default toolchain to the root build directory # so things will run. -if (current_toolchain == default_toolchain) { +if (current_toolchain == default_toolchain && ninja_use_custom_environment_files) { if (is_debug) { configuration_name = "Debug" } else { @@ -363,16 +363,26 @@ if (target_cpu == "x86" || target_cpu == "x64") { # do any cross compiles when targeting x64-bit (the build does generate # some 64-bit stuff from x86/arm/arm64 target builds). if (win_build_host_cpu != "x64") { - build_cpu_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - host_os, - win_build_host_cpu, - "environment." + win_build_host_cpu, - ], - "scope") + if (ninja_use_custom_environment_files) { + target_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + host_os, + win_build_host_cpu, + "environment." + win_build_host_cpu + ], + "scope") + } else { + target_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + host_os, + win_build_host_cpu, + "environment." + win_build_host_cpu, + ], + "scope") + } msvc_toolchain(win_build_host_cpu) { environment = "environment." + win_build_host_cpu @@ -407,16 +417,26 @@ if (win_build_host_cpu != "x64") { } # 64-bit toolchains. -x64_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "win", - "x64", - "environment.x64", - ], - "scope") +if (ninja_use_custom_environment_files) { + x64_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "win", + "x64", + "environment.x64" + ], + "scope") +} else { + x64_toolchain_data = exec_script("setup_toolchain.py", + [ + "win", + "x64", + "environment.x64", + ], + "scope") +} template("win_x64_toolchains") { msvc_toolchain(target_name) { diff --git a/chromium/build/toolchain/win/setup_toolchain.py b/chromium/build/toolchain/win/setup_toolchain.py index 1ba5533c3ef..5b912e5fe53 100644 --- a/chromium/build/toolchain/win/setup_toolchain.py +++ b/chromium/build/toolchain/win/setup_toolchain.py @@ -181,17 +181,25 @@ def _LowercaseDict(d): def main(): - if len(sys.argv) != 7: + if len(sys.argv) != 7 and len(sys.argv) != 4: print('Usage setup_toolchain.py ' '<visual studio path> <win sdk path> ' '<runtime dirs> <target_os> <target_cpu> ' '<environment block name|none>') + print('or setup_toolchain.py <target_os> <target_cpu>' + '<environment block name|none>') sys.exit(2) - win_sdk_path = sys.argv[2] - runtime_dirs = sys.argv[3] - target_os = sys.argv[4] - target_cpu = sys.argv[5] - environment_block_name = sys.argv[6] + if len(sys.argv) == 7: + win_sdk_path = sys.argv[2] + runtime_dirs = sys.argv[3] + target_os = sys.argv[4] + target_cpu = sys.argv[5] + environment_block_name = sys.argv[6] + else: + target_os = sys.argv[1] + target_cpu = sys.argv[2] + environment_block_name = sys.argv[3] + if (environment_block_name == 'none'): environment_block_name = '' @@ -209,62 +217,65 @@ def main(): include = '' lib = '' - # TODO(scottmg|goma): Do we need an equivalent of - # ninja_use_custom_environment_files? + ninja_use_custom_environment_files = (len(sys.argv) == 7) for cpu in cpus: - if cpu == target_cpu: + if cpu != target_cpu: + continue + if not ninja_use_custom_environment_files: + env = os.environ + else: # Extract environment variables for subprocesses. env = _LoadToolchainEnv(cpu, win_sdk_path, target_store) env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] - 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 - - for path in env['LIB'].split(';'): - if os.path.exists(os.path.join(path, 'msvcrt.lib')): - vc_lib_path = os.path.realpath(path) - break - - for path in env['LIB'].split(';'): - if os.path.exists(os.path.join(path, 'atls.lib')): - vc_lib_atlmfc_path = os.path.realpath(path) - break - - for path in env['LIB'].split(';'): - if os.path.exists(os.path.join(path, 'User32.Lib')): - vc_lib_um_path = os.path.realpath(path) - break - - # The separator for INCLUDE here must match the one used in - # _LoadToolchainEnv() above. - include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p] - - # Make include path relative to builddir when cwd and sdk in same drive. - try: - include = map(os.path.relpath, include) - except ValueError: - pass - - lib = [p.replace('"', r'\"') for p in env['LIB'].split(';') if p] - # Make lib path relative to builddir when cwd and sdk in same drive. - try: - lib = map(os.path.relpath, lib) - except ValueError: - pass - - def q(s): # Quote s if it contains spaces or other weird characters. - return s if re.match(r'^[a-zA-Z0-9._/\\:-]*$', s) else '"' + s + '"' - include_I = ' '.join([q('/I' + i) for i in include]) - include_imsvc = ' '.join([q('-imsvc' + i) for i in include]) - libpath_flags = ' '.join([q('-libpath:' + i) for i in lib]) - - if (environment_block_name != ''): - env_block = _FormatAsEnvironmentBlock(env) - with open(environment_block_name, 'wb') as f: - f.write(env_block) + 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 + + for path in env['LIB'].split(';'): + if os.path.exists(os.path.join(path, 'msvcrt.lib')): + vc_lib_path = os.path.realpath(path) + break + + for path in env['LIB'].split(';'): + if os.path.exists(os.path.join(path, 'atls.lib')): + vc_lib_atlmfc_path = os.path.realpath(path) + break + + for path in env['LIB'].split(';'): + if os.path.exists(os.path.join(path, 'User32.Lib')): + vc_lib_um_path = os.path.realpath(path) + break + + # The separator for INCLUDE here must match the one used in + # _LoadToolchainEnv() above. + include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p] + + # Make include path relative to builddir when cwd and sdk in same drive. + try: + include = map(os.path.relpath, include) + except ValueError: + pass + + lib = [p.replace('"', r'\"') for p in env['LIB'].split(';') if p] + # Make lib path relative to builddir when cwd and sdk in same drive. + try: + lib = map(os.path.relpath, lib) + except ValueError: + pass + + def q(s): # Quote s if it contains spaces or other weird characters. + return s if re.match(r'^[a-zA-Z0-9._/\\:-]*$', s) else '"' + s + '"' + include_I = ' '.join([q('/I' + i) for i in include]) + include_imsvc = ' '.join([q('-imsvc' + i) for i in include]) + libpath_flags = ' '.join([q('-libpath:' + i) for i in lib]) + + if (environment_block_name != ''): + env_block = _FormatAsEnvironmentBlock(env) + with open(environment_block_name, 'wb') as f: + f.write(env_block) assert vc_bin_dir print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) |