Commit 9738e829 authored by jianli's avatar jianli Committed by Commit bot

Revert of Move gyp-win-tool to the GN Windows toolchain. (patchset #6...

Revert of Move gyp-win-tool to the GN Windows toolchain. (patchset #6 id:100001 of https://codereview.chromium.org/2287603003/ )

Reason for revert:
https://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20Win/builds/10319/steps/compile/logs/stdio

Original issue's description:
> Move gyp-win-tool to the GN Windows toolchain.
>
> Renames it tool_wrapper.py but otherwise keeps it unchanged from the original
> https://chromium.googlesource.com/external/gyp.git/+/master/pylib/gyp/win_tool.py
>
> I changed internal references to itself to tool_wrapper.py, and split the internal strings containing the word "Copyright" (which it uses to filter tool output) to avoid triggering the copyright presubmit check.
>
> Changes the build to refer to the file in-place rather than copying it to the build directory which was confusing.
>
> The tool runs itself in the link_manifest step. Since the file is no longer copied to what will be the current directory when linking, I believe this will be broken. But the GN build does not use the manifest linking command. To keep changes minimal, I kept this code in for now.
>
> Committed: https://crrev.com/6afaa104b1fa8c6caee4e53b2e37142832ec9f9e
> Cr-Commit-Position: refs/heads/master@{#414859}

TBR=scottmg@chromium.org,dpranke@chromium.org,brettw@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2287833002
Cr-Commit-Position: refs/heads/master@{#414880}
parent d8f0aefd
......@@ -77,10 +77,10 @@ require_administrator_manifest = "//build/win/require_administrator.manifest"
# }
if (is_win) {
# This is the environment file that tool_wrapper.py will use for the current
# This is the environment file that gyp-win-tool will use for the current
# toolchain. It is placed in root_build_dir by the toolchain setup. This
# variable is the path relative to the root_build_dir which is what
# tool_wrapper.py expects as an argument.
# gyp-win-tool expects as an argument.
_environment_file = "environment.$current_cpu"
template("windows_manifest") {
......@@ -98,7 +98,7 @@ if (is_win) {
":$rc_action_name",
]
script = "//build/toolchain/win/tool_wrapper.py"
script = "$root_build_dir/gyp-win-tool"
assert(defined(invoker.sources),
"\"sources\" must be defined for a windows_manifest target")
......@@ -126,11 +126,11 @@ if (is_win) {
# Make the .rc file that references the final manifest file.
#
# This could easily be combined into one step, but this current separation
# of .manifest and .rc matches GYP and allows us to re-use tool_wrapper.py.
# of .manifest and .rc matches GYP and allows us to re-use gyp-win-tool.
action(rc_action_name) {
visibility = [ ":$source_set_name" ]
script = "//build/toolchain/win/tool_wrapper.py"
script = "$root_build_dir/gyp-win-tool"
outputs = [
rcfile,
......
......@@ -92,12 +92,9 @@ if (is_posix) {
stamp_description = "STAMP {{output}}"
copy_description = "COPY {{source}} {{output}}"
if (host_os == "win") {
_tool_wrapper_path =
rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)
stamp_command = "$python_path $_tool_wrapper_path stamp {{output}}"
stamp_command = "$python_path gyp-win-tool stamp {{output}}"
copy_command =
"$python_path $_tool_wrapper_path recursive-mirror {{source}} {{output}}"
"$python_path gyp-win-tool recursive-mirror {{source}} {{output}}"
} else {
stamp_command = "touch {{output}}"
copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
......
......@@ -17,9 +17,8 @@ assert(is_win)
# Its arguments are the VS path and the compiler wrapper tool. It will write
# "environment.x86" and "environment.x64" to the build directory and return a
# list to us.
# This tool will is used as a wrapper for various commands below.
tool_wrapper_path = rebase_path("tool_wrapper.py", root_build_dir)
gyp_win_tool_path =
rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir)
if (use_goma) {
goma_prefix = "$goma_dir/gomacc.exe "
......@@ -161,7 +160,7 @@ template("msvc_toolchain") {
}
tool("rc") {
command = "$python_path $tool_wrapper_path rc-wrapper $env rc.exe {{defines}} {{include_dirs}} /fo{{output}} {{source}}"
command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{include_dirs}} /fo{{output}} {{source}}"
outputs = [
"$object_subdir/{{source_name_part}}.res",
]
......@@ -174,7 +173,7 @@ template("msvc_toolchain") {
} else {
ml = "ml.exe"
}
command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}"
command = "$python_path gyp-win-tool asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}"
description = "ASM {{output}}"
outputs = [
"$object_subdir/{{source_name_part}}.obj",
......@@ -183,7 +182,7 @@ template("msvc_toolchain") {
tool("alink") {
rspfile = "{{output}}.rsp"
command = "$python_path $tool_wrapper_path link-wrapper $env False $lib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
command = "$python_path gyp-win-tool link-wrapper $env False $lib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
description = "LIB {{output}}"
outputs = [
# Ignore {{output_extension}} and always use .lib, there's no reason to
......@@ -205,7 +204,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
command = "$python_path gyp-win-tool link-wrapper $env False $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}"
......@@ -238,7 +237,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
command = "$python_path gyp-win-tool link-wrapper $env False $link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}"
......@@ -262,7 +261,7 @@ template("msvc_toolchain") {
rspfile = "$exename.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
command = "$python_path gyp-win-tool link-wrapper $env False $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
default_output_extension = ".exe"
default_output_dir = "{{root_out_dir}}"
......@@ -314,6 +313,7 @@ if (target_cpu == "x86") {
x86_toolchain_data = exec_script("setup_toolchain.py",
[
visual_studio_path,
gyp_win_tool_path,
windows_sdk_path,
visual_studio_runtime_dirs,
"x86",
......@@ -347,6 +347,7 @@ if (target_cpu == "x86") {
x64_toolchain_data = exec_script("setup_toolchain.py",
[
visual_studio_path,
gyp_win_tool_path,
windows_sdk_path,
visual_studio_runtime_dirs,
"x64",
......
......@@ -44,8 +44,8 @@ template("midl") {
# This functionality is handled by the win-tool because the GYP build has
# MIDL support built-in.
# TODO(brettw) move this to a separate MIDL wrapper script for better
# clarity.
script = "//build/toolchain/win/tool_wrapper.py"
# clarity once GYP support is not needed.
script = "$root_build_dir/gyp-win-tool"
sources = invoker.sources
......
......@@ -46,7 +46,7 @@ def _ExtractImportantEnvironment(output_of_set):
if re.match(envvar + '=', line.lower()):
var, setting = line.split('=', 1)
if envvar == 'path':
# Our own rules (for running tool_wrapper.py) and other actions in
# Our own rules (for running gyp-win-tool) and other actions in
# Chromium rely on python being in the path. Add the path to this
# python here so that if it's not in the path when ninja is run
# later, python will still be found.
......@@ -147,16 +147,45 @@ def _FormatAsEnvironmentBlock(envvar_dict):
return block
def _CopyTool(source_path):
"""Copies the given tool to the current directory, including a warning not
to edit it."""
with open(source_path) as source_file:
tool_source = source_file.readlines()
# Add header and write it out to the current directory (which should be the
# root build dir). Don't write the file if a matching file already exists
# because that causes a cascade of unnecessary rebuilds.
match = False
contents = ''.join([tool_source[0],
'# Generated by setup_toolchain.py do not edit.\n']
+ tool_source[1:])
out_path = 'gyp-win-tool'
try:
with open(out_path, 'rb') as read_tool_file:
existing_contents = read_tool_file.read()
if existing_contents == contents:
match = True
except:
pass
if not match:
with open(out_path, 'wb') as write_tool_file:
write_tool_file.write(contents)
def main():
if len(sys.argv) != 6:
if len(sys.argv) != 7:
print('Usage setup_toolchain.py '
'<visual studio path> <win sdk path> '
'<visual studio path> <win tool path> <win sdk path> '
'<runtime dirs> <target_cpu> <include prefix>')
sys.exit(2)
win_sdk_path = sys.argv[2]
runtime_dirs = sys.argv[3]
target_cpu = sys.argv[4]
include_prefix = sys.argv[5]
tool_source = sys.argv[2]
win_sdk_path = sys.argv[3]
runtime_dirs = sys.argv[4]
target_cpu = sys.argv[5]
include_prefix = sys.argv[6]
_CopyTool(tool_source)
cpus = ('x86', 'x64')
assert target_cpu in cpus
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment