2014-03-20 02:01:39 +04:00
|
|
|
# Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import pipes
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
|
|
|
|
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
sys.path.insert(1, os.path.join(chrome_src, 'tools'))
|
|
|
|
sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
|
2014-04-09 05:56:20 +04:00
|
|
|
json_data_file = os.path.join(script_dir, 'win_toolchain.json')
|
2014-03-20 02:01:39 +04:00
|
|
|
|
|
|
|
|
|
|
|
import gyp
|
|
|
|
|
|
|
|
|
2014-04-09 05:56:20 +04:00
|
|
|
def SetEnvironmentAndGetRuntimeDllDirs():
|
|
|
|
"""Sets up os.environ to use the depot_tools VS toolchain with gyp, and
|
|
|
|
returns the location of the VS runtime DLLs so they can be copied into
|
|
|
|
the output directory after gyp generation.
|
2014-03-20 02:01:39 +04:00
|
|
|
"""
|
|
|
|
vs2013_runtime_dll_dirs = None
|
|
|
|
depot_tools_win_toolchain = \
|
|
|
|
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
|
|
|
|
if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
|
2014-08-14 18:03:30 +04:00
|
|
|
if not os.path.exists(json_data_file):
|
|
|
|
Update()
|
2014-04-09 05:56:20 +04:00
|
|
|
with open(json_data_file, 'r') as tempf:
|
2014-03-20 02:01:39 +04:00
|
|
|
toolchain_data = json.load(tempf)
|
|
|
|
|
|
|
|
toolchain = toolchain_data['path']
|
|
|
|
version = toolchain_data['version']
|
|
|
|
version_is_pro = version[-1] != 'e'
|
|
|
|
win8sdk = toolchain_data['win8sdk']
|
|
|
|
wdk = toolchain_data['wdk']
|
|
|
|
# TODO(scottmg): The order unfortunately matters in these. They should be
|
|
|
|
# split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
|
|
|
|
# below). http://crbug.com/345992
|
|
|
|
vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
|
|
|
|
|
|
|
|
os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
|
|
|
|
os.environ['GYP_MSVS_VERSION'] = version
|
|
|
|
# We need to make sure windows_sdk_path is set to the automated
|
|
|
|
# toolchain values in GYP_DEFINES, but don't want to override any
|
|
|
|
# otheroptions.express
|
|
|
|
# values there.
|
|
|
|
gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
|
|
|
|
gyp_defines_dict['windows_sdk_path'] = win8sdk
|
|
|
|
os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
|
|
|
|
for k, v in gyp_defines_dict.iteritems())
|
|
|
|
os.environ['WINDOWSSDKDIR'] = win8sdk
|
|
|
|
os.environ['WDK_DIR'] = wdk
|
|
|
|
# Include the VS runtime in the PATH in case it's not machine-installed.
|
|
|
|
runtime_path = ';'.join(vs2013_runtime_dll_dirs)
|
|
|
|
os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
|
|
|
|
return vs2013_runtime_dll_dirs
|
|
|
|
|
|
|
|
|
Rework win_toolchains a bit and copy the vs runtime DLLs as needed.
In order to run both the visual studio tools and the binaries built
by them (and ninja), we need to ensure that the VS runtime DLLs
are available in the path.
In the GYP build, we accomplish this by copying them into the
Debug and Debug_x64 dirs as appropriate inside the gyp_chromium
script.
In the pure-GN build, then, things would be broken, so we need to
modify the GN build to do the copy as well, or we need to inject
a step somewhere that happens after GN runs but before Ninja tries
to run (since none of the toolchain binaries will work).
This patch accomplishes this by calling out to vs_toolchain.py to
copy the DLLs as neede when the toolchain is defined. This is somewhat
less than ideal (makes 'gn gen' slower) but seems better than forcing
devs to have to run an additional command.
In addition, the GYP build writes targets into Debug and Debug_x64
concurrently. This doesn't really carry over into GN correctly, and
we probably only ever want to write targets into Debug and Debug/64
(or some such).
However, the way the toolchains are currently implemented, it's not
clear if this really works and the interplay between 32-bit and 64-bit
is weird (we apparently normally "force" 32-bit even if we set cpu_arch
to 64-bit, and require you to specify force_win64). To work around this
and make sure that we copy the right DLLs for the right arch into the
outer Debug/ directory, this patch temporarily disables the cross-arch
part of the build, forcing the host_toolchain to match the target_toolchain.
This likely means that 'cpu_arch="x86"' works (the default), but the 'host'
binaries like image_diff and mksnapshot will be compiled in 32-bit mode,
not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and
produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and
won't until we can clean up the above stuff.
R=scottmg@chromium.org, brettw@chromium.org
BUG=430661
Review URL: https://codereview.chromium.org/722723004
Cr-Original-Commit-Position: refs/heads/master@{#304310}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
|
|
|
def _CopyRuntimeImpl(target, source):
|
|
|
|
"""Copy |source| to |target| if it doesn't already exist or if it
|
|
|
|
needs to be updated.
|
|
|
|
"""
|
|
|
|
if (os.path.isdir(os.path.dirname(target)) and
|
|
|
|
(not os.path.isfile(target) or
|
|
|
|
os.stat(target).st_mtime != os.stat(source).st_mtime)):
|
|
|
|
print 'Copying %s to %s...' % (source, target)
|
|
|
|
if os.path.exists(target):
|
|
|
|
os.unlink(target)
|
|
|
|
shutil.copy2(source, target)
|
|
|
|
|
|
|
|
|
|
|
|
def _CopyRuntime(target_dir, source_dir, dll_pattern):
|
|
|
|
"""Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
|
|
|
|
exist, but the target directory does exist."""
|
|
|
|
for which in ('p', 'r'):
|
|
|
|
dll = dll_pattern % which
|
|
|
|
target = os.path.join(target_dir, dll)
|
|
|
|
source = os.path.join(source_dir, dll)
|
|
|
|
_CopyRuntimeImpl(target, source)
|
|
|
|
|
|
|
|
|
2014-03-20 02:01:39 +04:00
|
|
|
def CopyVsRuntimeDlls(output_dir, runtime_dirs):
|
|
|
|
"""Copies the VS runtime DLLs from the given |runtime_dirs| to the output
|
|
|
|
directory so that even if not system-installed, built binaries are likely to
|
|
|
|
be able to run.
|
|
|
|
|
|
|
|
This needs to be run after gyp has been run so that the expected target
|
|
|
|
output directories are already created.
|
|
|
|
"""
|
|
|
|
assert sys.platform.startswith(('win32', 'cygwin'))
|
|
|
|
|
|
|
|
x86, x64 = runtime_dirs
|
|
|
|
out_debug = os.path.join(output_dir, 'Debug')
|
|
|
|
out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
|
|
|
|
out_release = os.path.join(output_dir, 'Release')
|
|
|
|
out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64')
|
|
|
|
out_debug_x64 = os.path.join(output_dir, 'Debug_x64')
|
|
|
|
out_release_x64 = os.path.join(output_dir, 'Release_x64')
|
|
|
|
|
|
|
|
if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64):
|
|
|
|
os.makedirs(out_debug_nacl64)
|
|
|
|
if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
|
|
|
|
os.makedirs(out_release_nacl64)
|
Rework win_toolchains a bit and copy the vs runtime DLLs as needed.
In order to run both the visual studio tools and the binaries built
by them (and ninja), we need to ensure that the VS runtime DLLs
are available in the path.
In the GYP build, we accomplish this by copying them into the
Debug and Debug_x64 dirs as appropriate inside the gyp_chromium
script.
In the pure-GN build, then, things would be broken, so we need to
modify the GN build to do the copy as well, or we need to inject
a step somewhere that happens after GN runs but before Ninja tries
to run (since none of the toolchain binaries will work).
This patch accomplishes this by calling out to vs_toolchain.py to
copy the DLLs as neede when the toolchain is defined. This is somewhat
less than ideal (makes 'gn gen' slower) but seems better than forcing
devs to have to run an additional command.
In addition, the GYP build writes targets into Debug and Debug_x64
concurrently. This doesn't really carry over into GN correctly, and
we probably only ever want to write targets into Debug and Debug/64
(or some such).
However, the way the toolchains are currently implemented, it's not
clear if this really works and the interplay between 32-bit and 64-bit
is weird (we apparently normally "force" 32-bit even if we set cpu_arch
to 64-bit, and require you to specify force_win64). To work around this
and make sure that we copy the right DLLs for the right arch into the
outer Debug/ directory, this patch temporarily disables the cross-arch
part of the build, forcing the host_toolchain to match the target_toolchain.
This likely means that 'cpu_arch="x86"' works (the default), but the 'host'
binaries like image_diff and mksnapshot will be compiled in 32-bit mode,
not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and
produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and
won't until we can clean up the above stuff.
R=scottmg@chromium.org, brettw@chromium.org
BUG=430661
Review URL: https://codereview.chromium.org/722723004
Cr-Original-Commit-Position: refs/heads/master@{#304310}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
|
|
|
_CopyRuntime(out_debug, x86, 'msvc%s120d.dll')
|
|
|
|
_CopyRuntime(out_release, x86, 'msvc%s120.dll')
|
|
|
|
_CopyRuntime(out_debug_x64, x64, 'msvc%s120d.dll')
|
|
|
|
_CopyRuntime(out_release_x64, x64, 'msvc%s120.dll')
|
|
|
|
_CopyRuntime(out_debug_nacl64, x64, 'msvc%s120d.dll')
|
|
|
|
_CopyRuntime(out_release_nacl64, x64, 'msvc%s120.dll')
|
2014-03-20 02:01:39 +04:00
|
|
|
|
2014-07-22 04:18:32 +04:00
|
|
|
# Copy the PGO runtime library to the release directories.
|
|
|
|
if os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
|
|
|
|
pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
|
|
|
|
'VC', 'bin')
|
|
|
|
pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
|
|
|
|
pgo_runtime_dll = 'pgort120.dll'
|
|
|
|
source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll)
|
|
|
|
if os.path.exists(source_x86):
|
Rework win_toolchains a bit and copy the vs runtime DLLs as needed.
In order to run both the visual studio tools and the binaries built
by them (and ninja), we need to ensure that the VS runtime DLLs
are available in the path.
In the GYP build, we accomplish this by copying them into the
Debug and Debug_x64 dirs as appropriate inside the gyp_chromium
script.
In the pure-GN build, then, things would be broken, so we need to
modify the GN build to do the copy as well, or we need to inject
a step somewhere that happens after GN runs but before Ninja tries
to run (since none of the toolchain binaries will work).
This patch accomplishes this by calling out to vs_toolchain.py to
copy the DLLs as neede when the toolchain is defined. This is somewhat
less than ideal (makes 'gn gen' slower) but seems better than forcing
devs to have to run an additional command.
In addition, the GYP build writes targets into Debug and Debug_x64
concurrently. This doesn't really carry over into GN correctly, and
we probably only ever want to write targets into Debug and Debug/64
(or some such).
However, the way the toolchains are currently implemented, it's not
clear if this really works and the interplay between 32-bit and 64-bit
is weird (we apparently normally "force" 32-bit even if we set cpu_arch
to 64-bit, and require you to specify force_win64). To work around this
and make sure that we copy the right DLLs for the right arch into the
outer Debug/ directory, this patch temporarily disables the cross-arch
part of the build, forcing the host_toolchain to match the target_toolchain.
This likely means that 'cpu_arch="x86"' works (the default), but the 'host'
binaries like image_diff and mksnapshot will be compiled in 32-bit mode,
not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and
produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and
won't until we can clean up the above stuff.
R=scottmg@chromium.org, brettw@chromium.org
BUG=430661
Review URL: https://codereview.chromium.org/722723004
Cr-Original-Commit-Position: refs/heads/master@{#304310}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
|
|
|
_CopyRuntimeImpl(os.path.join(out_release, pgo_runtime_dll), source_x86)
|
2014-07-22 04:18:32 +04:00
|
|
|
source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll)
|
|
|
|
if os.path.exists(source_x64):
|
Rework win_toolchains a bit and copy the vs runtime DLLs as needed.
In order to run both the visual studio tools and the binaries built
by them (and ninja), we need to ensure that the VS runtime DLLs
are available in the path.
In the GYP build, we accomplish this by copying them into the
Debug and Debug_x64 dirs as appropriate inside the gyp_chromium
script.
In the pure-GN build, then, things would be broken, so we need to
modify the GN build to do the copy as well, or we need to inject
a step somewhere that happens after GN runs but before Ninja tries
to run (since none of the toolchain binaries will work).
This patch accomplishes this by calling out to vs_toolchain.py to
copy the DLLs as neede when the toolchain is defined. This is somewhat
less than ideal (makes 'gn gen' slower) but seems better than forcing
devs to have to run an additional command.
In addition, the GYP build writes targets into Debug and Debug_x64
concurrently. This doesn't really carry over into GN correctly, and
we probably only ever want to write targets into Debug and Debug/64
(or some such).
However, the way the toolchains are currently implemented, it's not
clear if this really works and the interplay between 32-bit and 64-bit
is weird (we apparently normally "force" 32-bit even if we set cpu_arch
to 64-bit, and require you to specify force_win64). To work around this
and make sure that we copy the right DLLs for the right arch into the
outer Debug/ directory, this patch temporarily disables the cross-arch
part of the build, forcing the host_toolchain to match the target_toolchain.
This likely means that 'cpu_arch="x86"' works (the default), but the 'host'
binaries like image_diff and mksnapshot will be compiled in 32-bit mode,
not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and
produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and
won't until we can clean up the above stuff.
R=scottmg@chromium.org, brettw@chromium.org
BUG=430661
Review URL: https://codereview.chromium.org/722723004
Cr-Original-Commit-Position: refs/heads/master@{#304310}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
|
|
|
_CopyRuntimeImpl(os.path.join(out_release_x64, pgo_runtime_dll),
|
|
|
|
source_x64)
|
|
|
|
|
|
|
|
|
|
|
|
def CopyDlls(target_dir, configuration, cpu_arch):
|
|
|
|
"""Copy the VS runtime DLLs into the requested directory as needed.
|
|
|
|
|
|
|
|
configuration is one of 'Debug' or 'Release'.
|
|
|
|
cpu_arch is one of 'x86' or 'x64'.
|
|
|
|
|
|
|
|
The debug configuration gets both the debug and release DLLs; the
|
|
|
|
release config only the latter.
|
|
|
|
"""
|
|
|
|
vs2013_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
|
|
|
|
if not vs2013_runtime_dll_dirs:
|
|
|
|
return
|
|
|
|
|
|
|
|
x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
|
|
|
|
runtime_dir = x64_runtime if cpu_arch == 'x64' else x86_runtime
|
|
|
|
_CopyRuntime(target_dir, runtime_dir, 'msvc%s120.dll')
|
|
|
|
if configuration == 'Debug':
|
|
|
|
_CopyRuntime(target_dir, runtime_dir, 'msvc%s120d.dll')
|
2014-07-22 04:18:32 +04:00
|
|
|
|
2014-03-20 02:01:39 +04:00
|
|
|
|
2014-04-09 05:56:20 +04:00
|
|
|
def _GetDesiredVsToolchainHashes():
|
|
|
|
"""Load a list of SHA1s corresponding to the toolchains that we want installed
|
|
|
|
to build with."""
|
2014-11-15 04:37:47 +03:00
|
|
|
sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash')
|
2014-04-09 05:56:20 +04:00
|
|
|
with open(sha1path, 'rb') as f:
|
|
|
|
return f.read().strip().splitlines()
|
|
|
|
|
|
|
|
|
|
|
|
def Update():
|
|
|
|
"""Requests an update of the toolchain to the specific hashes we have at
|
|
|
|
this revision. The update outputs a .json of the various configuration
|
|
|
|
information required to pass to gyp which we use in |GetToolchainDir()|.
|
|
|
|
"""
|
|
|
|
depot_tools_win_toolchain = \
|
|
|
|
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
|
|
|
|
if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
|
|
|
|
import find_depot_tools
|
|
|
|
depot_tools_path = find_depot_tools.add_depot_tools_to_path()
|
|
|
|
json_data_file = os.path.join(script_dir, 'win_toolchain.json')
|
|
|
|
get_toolchain_args = [
|
|
|
|
sys.executable,
|
|
|
|
os.path.join(depot_tools_path,
|
|
|
|
'win_toolchain',
|
|
|
|
'get_toolchain_if_necessary.py'),
|
|
|
|
'--output-json', json_data_file,
|
|
|
|
] + _GetDesiredVsToolchainHashes()
|
|
|
|
subprocess.check_call(get_toolchain_args)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def GetToolchainDir():
|
|
|
|
"""Gets location information about the current toolchain (must have been
|
2014-05-29 00:32:01 +04:00
|
|
|
previously updated by 'update'). This is used for the GN build."""
|
2014-04-09 05:56:20 +04:00
|
|
|
SetEnvironmentAndGetRuntimeDllDirs()
|
2014-09-30 23:31:43 +04:00
|
|
|
|
|
|
|
# If WINDOWSSDKDIR is not set, search the default SDK path and set it.
|
|
|
|
if not 'WINDOWSSDKDIR' in os.environ:
|
|
|
|
default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\8.0'
|
|
|
|
if os.path.isdir(default_sdk_path):
|
|
|
|
os.environ['WINDOWSSDKDIR'] = default_sdk_path
|
|
|
|
|
2014-05-29 00:32:01 +04:00
|
|
|
print '''vs_path = "%s"
|
|
|
|
sdk_path = "%s"
|
|
|
|
vs_version = "%s"
|
|
|
|
wdk_dir = "%s"
|
|
|
|
''' % (
|
|
|
|
os.environ['GYP_MSVS_OVERRIDE_PATH'],
|
|
|
|
os.environ['WINDOWSSDKDIR'],
|
|
|
|
os.environ['GYP_MSVS_VERSION'],
|
2014-09-16 05:36:39 +04:00
|
|
|
os.environ.get('WDK_DIR', ''))
|
2014-04-09 05:56:20 +04:00
|
|
|
|
|
|
|
|
2014-03-20 02:01:39 +04:00
|
|
|
def main():
|
2014-04-09 05:56:20 +04:00
|
|
|
if not sys.platform.startswith(('win32', 'cygwin')):
|
|
|
|
return 0
|
|
|
|
commands = {
|
|
|
|
'update': Update,
|
|
|
|
'get_toolchain_dir': GetToolchainDir,
|
Rework win_toolchains a bit and copy the vs runtime DLLs as needed.
In order to run both the visual studio tools and the binaries built
by them (and ninja), we need to ensure that the VS runtime DLLs
are available in the path.
In the GYP build, we accomplish this by copying them into the
Debug and Debug_x64 dirs as appropriate inside the gyp_chromium
script.
In the pure-GN build, then, things would be broken, so we need to
modify the GN build to do the copy as well, or we need to inject
a step somewhere that happens after GN runs but before Ninja tries
to run (since none of the toolchain binaries will work).
This patch accomplishes this by calling out to vs_toolchain.py to
copy the DLLs as neede when the toolchain is defined. This is somewhat
less than ideal (makes 'gn gen' slower) but seems better than forcing
devs to have to run an additional command.
In addition, the GYP build writes targets into Debug and Debug_x64
concurrently. This doesn't really carry over into GN correctly, and
we probably only ever want to write targets into Debug and Debug/64
(or some such).
However, the way the toolchains are currently implemented, it's not
clear if this really works and the interplay between 32-bit and 64-bit
is weird (we apparently normally "force" 32-bit even if we set cpu_arch
to 64-bit, and require you to specify force_win64). To work around this
and make sure that we copy the right DLLs for the right arch into the
outer Debug/ directory, this patch temporarily disables the cross-arch
part of the build, forcing the host_toolchain to match the target_toolchain.
This likely means that 'cpu_arch="x86"' works (the default), but the 'host'
binaries like image_diff and mksnapshot will be compiled in 32-bit mode,
not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and
produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and
won't until we can clean up the above stuff.
R=scottmg@chromium.org, brettw@chromium.org
BUG=430661
Review URL: https://codereview.chromium.org/722723004
Cr-Original-Commit-Position: refs/heads/master@{#304310}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
|
|
|
'copy_dlls': CopyDlls,
|
2014-04-09 05:56:20 +04:00
|
|
|
}
|
|
|
|
if len(sys.argv) < 2 or sys.argv[1] not in commands:
|
|
|
|
print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
|
2014-03-20 21:42:25 +04:00
|
|
|
return 1
|
Rework win_toolchains a bit and copy the vs runtime DLLs as needed.
In order to run both the visual studio tools and the binaries built
by them (and ninja), we need to ensure that the VS runtime DLLs
are available in the path.
In the GYP build, we accomplish this by copying them into the
Debug and Debug_x64 dirs as appropriate inside the gyp_chromium
script.
In the pure-GN build, then, things would be broken, so we need to
modify the GN build to do the copy as well, or we need to inject
a step somewhere that happens after GN runs but before Ninja tries
to run (since none of the toolchain binaries will work).
This patch accomplishes this by calling out to vs_toolchain.py to
copy the DLLs as neede when the toolchain is defined. This is somewhat
less than ideal (makes 'gn gen' slower) but seems better than forcing
devs to have to run an additional command.
In addition, the GYP build writes targets into Debug and Debug_x64
concurrently. This doesn't really carry over into GN correctly, and
we probably only ever want to write targets into Debug and Debug/64
(or some such).
However, the way the toolchains are currently implemented, it's not
clear if this really works and the interplay between 32-bit and 64-bit
is weird (we apparently normally "force" 32-bit even if we set cpu_arch
to 64-bit, and require you to specify force_win64). To work around this
and make sure that we copy the right DLLs for the right arch into the
outer Debug/ directory, this patch temporarily disables the cross-arch
part of the build, forcing the host_toolchain to match the target_toolchain.
This likely means that 'cpu_arch="x86"' works (the default), but the 'host'
binaries like image_diff and mksnapshot will be compiled in 32-bit mode,
not 64-bit mode. 'cpu_arch="x64" force_win64=true' should also work, and
produce all-64-bit binaries. 'cpu_arch="x64"' does not work at all and
won't until we can clean up the above stuff.
R=scottmg@chromium.org, brettw@chromium.org
BUG=430661
Review URL: https://codereview.chromium.org/722723004
Cr-Original-Commit-Position: refs/heads/master@{#304310}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0b95195e49489b7a4d87048d2ce4b747173a5b8a
2014-11-15 03:09:14 +03:00
|
|
|
return commands[sys.argv[1]](*sys.argv[2:])
|
2014-03-20 02:01:39 +04:00
|
|
|
|
2014-03-20 21:42:25 +04:00
|
|
|
|
2014-03-20 02:01:39 +04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|