Commit 6afaa104 authored by brettw's avatar brettw Committed by Commit bot

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.

Review-Url: https://codereview.chromium.org/2287603003
Cr-Commit-Position: refs/heads/master@{#414859}
parent 12bda387
...@@ -77,10 +77,10 @@ require_administrator_manifest = "//build/win/require_administrator.manifest" ...@@ -77,10 +77,10 @@ require_administrator_manifest = "//build/win/require_administrator.manifest"
# } # }
if (is_win) { if (is_win) {
# This is the environment file that gyp-win-tool will use for the current # This is the environment file that tool_wrapper.py will use for the current
# toolchain. It is placed in root_build_dir by the toolchain setup. This # 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 # variable is the path relative to the root_build_dir which is what
# gyp-win-tool expects as an argument. # tool_wrapper.py expects as an argument.
_environment_file = "environment.$current_cpu" _environment_file = "environment.$current_cpu"
template("windows_manifest") { template("windows_manifest") {
...@@ -98,7 +98,7 @@ if (is_win) { ...@@ -98,7 +98,7 @@ if (is_win) {
":$rc_action_name", ":$rc_action_name",
] ]
script = "$root_build_dir/gyp-win-tool" script = "//build/toolchain/win/tool_wrapper.py"
assert(defined(invoker.sources), assert(defined(invoker.sources),
"\"sources\" must be defined for a windows_manifest target") "\"sources\" must be defined for a windows_manifest target")
...@@ -126,11 +126,11 @@ if (is_win) { ...@@ -126,11 +126,11 @@ if (is_win) {
# Make the .rc file that references the final manifest file. # Make the .rc file that references the final manifest file.
# #
# This could easily be combined into one step, but this current separation # This could easily be combined into one step, but this current separation
# of .manifest and .rc matches GYP and allows us to re-use gyp-win-tool. # of .manifest and .rc matches GYP and allows us to re-use tool_wrapper.py.
action(rc_action_name) { action(rc_action_name) {
visibility = [ ":$source_set_name" ] visibility = [ ":$source_set_name" ]
script = "$root_build_dir/gyp-win-tool" script = "//build/toolchain/win/tool_wrapper.py"
outputs = [ outputs = [
rcfile, rcfile,
......
...@@ -92,9 +92,12 @@ if (is_posix) { ...@@ -92,9 +92,12 @@ if (is_posix) {
stamp_description = "STAMP {{output}}" stamp_description = "STAMP {{output}}"
copy_description = "COPY {{source}} {{output}}" copy_description = "COPY {{source}} {{output}}"
if (host_os == "win") { if (host_os == "win") {
stamp_command = "$python_path gyp-win-tool stamp {{output}}" _tool_wrapper_path =
rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)
stamp_command = "$python_path $_tool_wrapper_path stamp {{output}}"
copy_command = copy_command =
"$python_path gyp-win-tool recursive-mirror {{source}} {{output}}" "$python_path $_tool_wrapper_path recursive-mirror {{source}} {{output}}"
} else { } else {
stamp_command = "touch {{output}}" stamp_command = "touch {{output}}"
copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
......
...@@ -17,8 +17,9 @@ assert(is_win) ...@@ -17,8 +17,9 @@ assert(is_win)
# Its arguments are the VS path and the compiler wrapper tool. It will write # 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 # "environment.x86" and "environment.x64" to the build directory and return a
# list to us. # list to us.
gyp_win_tool_path =
rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir) # This tool will is used as a wrapper for various commands below.
tool_wrapper_path = rebase_path("tool_wrapper.py", root_build_dir)
if (use_goma) { if (use_goma) {
goma_prefix = "$goma_dir/gomacc.exe " goma_prefix = "$goma_dir/gomacc.exe "
...@@ -160,7 +161,7 @@ template("msvc_toolchain") { ...@@ -160,7 +161,7 @@ template("msvc_toolchain") {
} }
tool("rc") { tool("rc") {
command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{include_dirs}} /fo{{output}} {{source}}" command = "$python_path $tool_wrapper_path rc-wrapper $env rc.exe {{defines}} {{include_dirs}} /fo{{output}} {{source}}"
outputs = [ outputs = [
"$object_subdir/{{source_name_part}}.res", "$object_subdir/{{source_name_part}}.res",
] ]
...@@ -173,7 +174,7 @@ template("msvc_toolchain") { ...@@ -173,7 +174,7 @@ template("msvc_toolchain") {
} else { } else {
ml = "ml.exe" ml = "ml.exe"
} }
command = "$python_path gyp-win-tool asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}"
description = "ASM {{output}}" description = "ASM {{output}}"
outputs = [ outputs = [
"$object_subdir/{{source_name_part}}.obj", "$object_subdir/{{source_name_part}}.obj",
...@@ -182,7 +183,7 @@ template("msvc_toolchain") { ...@@ -182,7 +183,7 @@ template("msvc_toolchain") {
tool("alink") { tool("alink") {
rspfile = "{{output}}.rsp" rspfile = "{{output}}.rsp"
command = "$python_path gyp-win-tool link-wrapper $env False $lib /nologo {{arflags}} /OUT:{{output}} @$rspfile" command = "$python_path $tool_wrapper_path link-wrapper $env False $lib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
description = "LIB {{output}}" description = "LIB {{output}}"
outputs = [ outputs = [
# Ignore {{output_extension}} and always use .lib, there's no reason to # Ignore {{output_extension}} and always use .lib, there's no reason to
...@@ -204,7 +205,7 @@ template("msvc_toolchain") { ...@@ -204,7 +205,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp" rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path gyp-win-tool link-wrapper $env False $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll" default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}" default_output_dir = "{{root_out_dir}}"
...@@ -237,7 +238,7 @@ template("msvc_toolchain") { ...@@ -237,7 +238,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp" rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path gyp-win-tool link-wrapper $env False $link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll" default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}" default_output_dir = "{{root_out_dir}}"
...@@ -261,7 +262,7 @@ template("msvc_toolchain") { ...@@ -261,7 +262,7 @@ template("msvc_toolchain") {
rspfile = "$exename.rsp" rspfile = "$exename.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path gyp-win-tool link-wrapper $env False $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile" command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
default_output_extension = ".exe" default_output_extension = ".exe"
default_output_dir = "{{root_out_dir}}" default_output_dir = "{{root_out_dir}}"
...@@ -313,7 +314,6 @@ if (target_cpu == "x86") { ...@@ -313,7 +314,6 @@ if (target_cpu == "x86") {
x86_toolchain_data = exec_script("setup_toolchain.py", x86_toolchain_data = exec_script("setup_toolchain.py",
[ [
visual_studio_path, visual_studio_path,
gyp_win_tool_path,
windows_sdk_path, windows_sdk_path,
visual_studio_runtime_dirs, visual_studio_runtime_dirs,
"x86", "x86",
...@@ -347,7 +347,6 @@ if (target_cpu == "x86") { ...@@ -347,7 +347,6 @@ if (target_cpu == "x86") {
x64_toolchain_data = exec_script("setup_toolchain.py", x64_toolchain_data = exec_script("setup_toolchain.py",
[ [
visual_studio_path, visual_studio_path,
gyp_win_tool_path,
windows_sdk_path, windows_sdk_path,
visual_studio_runtime_dirs, visual_studio_runtime_dirs,
"x64", "x64",
......
...@@ -44,8 +44,8 @@ template("midl") { ...@@ -44,8 +44,8 @@ template("midl") {
# This functionality is handled by the win-tool because the GYP build has # This functionality is handled by the win-tool because the GYP build has
# MIDL support built-in. # MIDL support built-in.
# TODO(brettw) move this to a separate MIDL wrapper script for better # TODO(brettw) move this to a separate MIDL wrapper script for better
# clarity once GYP support is not needed. # clarity.
script = "$root_build_dir/gyp-win-tool" script = "//build/toolchain/win/tool_wrapper.py"
sources = invoker.sources sources = invoker.sources
......
...@@ -46,7 +46,7 @@ def _ExtractImportantEnvironment(output_of_set): ...@@ -46,7 +46,7 @@ def _ExtractImportantEnvironment(output_of_set):
if re.match(envvar + '=', line.lower()): if re.match(envvar + '=', line.lower()):
var, setting = line.split('=', 1) var, setting = line.split('=', 1)
if envvar == 'path': if envvar == 'path':
# Our own rules (for running gyp-win-tool) and other actions in # Our own rules (for running tool_wrapper.py) and other actions in
# Chromium rely on python being in the path. Add the path to this # 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 # python here so that if it's not in the path when ninja is run
# later, python will still be found. # later, python will still be found.
...@@ -147,45 +147,16 @@ def _FormatAsEnvironmentBlock(envvar_dict): ...@@ -147,45 +147,16 @@ def _FormatAsEnvironmentBlock(envvar_dict):
return block 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(): def main():
if len(sys.argv) != 7: if len(sys.argv) != 6:
print('Usage setup_toolchain.py ' print('Usage setup_toolchain.py '
'<visual studio path> <win tool path> <win sdk path> ' '<visual studio path> <win sdk path> '
'<runtime dirs> <target_cpu> <include prefix>') '<runtime dirs> <target_cpu> <include prefix>')
sys.exit(2) sys.exit(2)
tool_source = sys.argv[2] win_sdk_path = sys.argv[2]
win_sdk_path = sys.argv[3] runtime_dirs = sys.argv[3]
runtime_dirs = sys.argv[4] target_cpu = sys.argv[4]
target_cpu = sys.argv[5] include_prefix = sys.argv[5]
include_prefix = sys.argv[6]
_CopyTool(tool_source)
cpus = ('x86', 'x64') cpus = ('x86', 'x64')
assert target_cpu in cpus assert target_cpu in cpus
......
# Copyright (c) 2012 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.
"""Utility functions for Windows builds.
This file is copied to the build directory as part of toolchain setup and
is used to set up calls to tools used by the build that need wrappers.
"""
import os
import re
import shutil
import subprocess
import stat
import string
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# A regex matching an argument corresponding to the output filename passed to
# link.exe.
_LINK_EXE_OUT_ARG = re.compile('/OUT:(?P<out>.+)$', re.IGNORECASE)
def main(args):
executor = WinTool()
exit_code = executor.Dispatch(args)
if exit_code is not None:
sys.exit(exit_code)
class WinTool(object):
"""This class performs all the Windows tooling steps. The methods can either
be executed directly, or dispatched from an argument list."""
def _UseSeparateMspdbsrv(self, env, args):
"""Allows to use a unique instance of mspdbsrv.exe per linker instead of a
shared one."""
if len(args) < 1:
raise Exception("Not enough arguments")
if args[0] != 'link.exe':
return
# Use the output filename passed to the linker to generate an endpoint name
# for mspdbsrv.exe.
endpoint_name = None
for arg in args:
m = _LINK_EXE_OUT_ARG.match(arg)
if m:
endpoint_name = re.sub(r'\W+', '',
'%s_%d' % (m.group('out'), os.getpid()))
break
if endpoint_name is None:
return
# Adds the appropriate environment variable. This will be read by link.exe
# to know which instance of mspdbsrv.exe it should connect to (if it's
# not set then the default endpoint is used).
env['_MSPDBSRV_ENDPOINT_'] = endpoint_name
def Dispatch(self, args):
"""Dispatches a string command to a method."""
if len(args) < 1:
raise Exception("Not enough arguments")
method = "Exec%s" % self._CommandifyName(args[0])
return getattr(self, method)(*args[1:])
def _CommandifyName(self, name_string):
"""Transforms a tool name like recursive-mirror to RecursiveMirror."""
return name_string.title().replace('-', '')
def _GetEnv(self, arch):
"""Gets the saved environment from a file for a given architecture."""
# The environment is saved as an "environment block" (see CreateProcess
# and msvs_emulation for details). We convert to a dict here.
# Drop last 2 NULs, one for list terminator, one for trailing vs. separator.
pairs = open(arch).read()[:-2].split('\0')
kvs = [item.split('=', 1) for item in pairs]
return dict(kvs)
def ExecStamp(self, path):
"""Simple stamp command."""
open(path, 'w').close()
def ExecRecursiveMirror(self, source, dest):
"""Emulation of rm -rf out && cp -af in out."""
if os.path.exists(dest):
if os.path.isdir(dest):
def _on_error(fn, path, excinfo):
# The operation failed, possibly because the file is set to
# read-only. If that's why, make it writable and try the op again.
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWRITE)
fn(path)
shutil.rmtree(dest, onerror=_on_error)
else:
if not os.access(dest, os.W_OK):
# Attempt to make the file writable before deleting it.
os.chmod(dest, stat.S_IWRITE)
os.unlink(dest)
if os.path.isdir(source):
shutil.copytree(source, dest)
else:
shutil.copy2(source, dest)
def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args):
"""Filter diagnostic output from link that looks like:
' Creating library ui.dll.lib and object ui.dll.exp'
This happens when there are exports from the dll or exe.
"""
env = self._GetEnv(arch)
if use_separate_mspdbsrv == 'True':
self._UseSeparateMspdbsrv(env, args)
if sys.platform == 'win32':
args = list(args) # *args is a tuple by default, which is read-only.
args[0] = args[0].replace('/', '\\')
# https://docs.python.org/2/library/subprocess.html:
# "On Unix with shell=True [...] if args is a sequence, the first item
# specifies the command string, and any additional items will be treated as
# additional arguments to the shell itself. That is to say, Popen does the
# equivalent of:
# Popen(['/bin/sh', '-c', args[0], args[1], ...])"
# For that reason, since going through the shell doesn't seem necessary on
# non-Windows don't do that there.
link = subprocess.Popen(args, shell=sys.platform == 'win32', env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = link.communicate()
for line in out.splitlines():
if (not line.startswith(' Creating library ') and
not line.startswith('Generating code') and
not line.startswith('Finished generating code')):
print line
return link.returncode
def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname,
mt, rc, intermediate_manifest, *manifests):
"""A wrapper for handling creating a manifest resource and then executing
a link command."""
# The 'normal' way to do manifests is to have link generate a manifest
# based on gathering dependencies from the object files, then merge that
# manifest with other manifests supplied as sources, convert the merged
# manifest to a resource, and then *relink*, including the compiled
# version of the manifest resource. This breaks incremental linking, and
# is generally overly complicated. Instead, we merge all the manifests
# provided (along with one that includes what would normally be in the
# linker-generated one, see msvs_emulation.py), and include that into the
# first and only link. We still tell link to generate a manifest, but we
# only use that to assert that our simpler process did not miss anything.
variables = {
'python': sys.executable,
'arch': arch,
'out': out,
'ldcmd': ldcmd,
'resname': resname,
'mt': mt,
'rc': rc,
'intermediate_manifest': intermediate_manifest,
'manifests': ' '.join(manifests),
}
add_to_ld = ''
if manifests:
subprocess.check_call(
'%(python)s tool_wrapper.py manifest-wrapper %(arch)s %(mt)s -nologo '
'-manifest %(manifests)s -out:%(out)s.manifest' % variables)
if embed_manifest == 'True':
subprocess.check_call(
'%(python)s tool_wrapper.py manifest-to-rc %(arch)s'
'%(out)s.manifest %(out)s.manifest.rc %(resname)s' % variables)
subprocess.check_call(
'%(python)s tool_wrapper.py rc-wrapper %(arch)s %(rc)s '
'%(out)s.manifest.rc' % variables)
add_to_ld = ' %(out)s.manifest.res' % variables
subprocess.check_call(ldcmd + add_to_ld)
# Run mt.exe on the theoretically complete manifest we generated, merging
# it with the one the linker generated to confirm that the linker
# generated one does not add anything. This is strictly unnecessary for
# correctness, it's only to verify that e.g. /MANIFESTDEPENDENCY was not
# used in a #pragma comment.
if manifests:
# Merge the intermediate one with ours to .assert.manifest, then check
# that .assert.manifest is identical to ours.
subprocess.check_call(
'%(python)s tool_wrapper.py manifest-wrapper %(arch)s %(mt)s -nologo '
'-manifest %(out)s.manifest %(intermediate_manifest)s '
'-out:%(out)s.assert.manifest' % variables)
assert_manifest = '%(out)s.assert.manifest' % variables
our_manifest = '%(out)s.manifest' % variables
# Load and normalize the manifests. mt.exe sometimes removes whitespace,
# and sometimes doesn't unfortunately.
with open(our_manifest, 'rb') as our_f:
with open(assert_manifest, 'rb') as assert_f:
our_data = our_f.read().translate(None, string.whitespace)
assert_data = assert_f.read().translate(None, string.whitespace)
if our_data != assert_data:
os.unlink(out)
def dump(filename):
sys.stderr.write('%s\n-----\n' % filename)
with open(filename, 'rb') as f:
sys.stderr.write(f.read() + '\n-----\n')
dump(intermediate_manifest)
dump(our_manifest)
dump(assert_manifest)
sys.stderr.write(
'Linker generated manifest "%s" added to final manifest "%s" '
'(result in "%s"). '
'Were /MANIFEST switches used in #pragma statements? ' % (
intermediate_manifest, our_manifest, assert_manifest))
return 1
def ExecManifestWrapper(self, arch, *args):
"""Run manifest tool with environment set. Strip out undesirable warning
(some XML blocks are recognized by the OS loader, but not the manifest
tool)."""
env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
for line in out.splitlines():
if line and 'manifest authoring warning 81010002' not in line:
print line
return popen.returncode
def ExecManifestToRc(self, arch, *args):
"""Creates a resource file pointing a SxS assembly manifest.
|args| is tuple containing path to resource file, path to manifest file
and resource name which can be "1" (for executables) or "2" (for DLLs)."""
manifest_path, resource_path, resource_name = args
with open(resource_path, 'wb') as output:
output.write('#include <windows.h>\n%s RT_MANIFEST "%s"' % (
resource_name,
os.path.abspath(manifest_path).replace('\\', '/')))
def ExecMidlWrapper(self, arch, outdir, tlb, h, dlldata, iid, proxy, idl,
*flags):
"""Filter noisy filenames output from MIDL compile step that isn't
quietable via command line flags.
"""
args = ['midl', '/nologo'] + list(flags) + [
'/out', outdir,
'/tlb', tlb,
'/h', h,
'/dlldata', dlldata,
'/iid', iid,
'/proxy', proxy,
idl]
env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
# Filter junk out of stdout, and write filtered versions. Output we want
# to filter is pairs of lines that look like this:
# Processing C:\Program Files (x86)\Microsoft SDKs\...\include\objidl.idl
# objidl.idl
lines = out.splitlines()
prefixes = ('Processing ', '64 bit Processing ')
processing = set(os.path.basename(x)
for x in lines if x.startswith(prefixes))
for line in lines:
if not line.startswith(prefixes) and line not in processing:
print line
return popen.returncode
def ExecAsmWrapper(self, arch, *args):
"""Filter logo banner from invocations of asm.exe."""
env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
for line in out.splitlines():
# Split to avoid triggering license checks:
if (not line.startswith('Copy' + 'right (C' +
') Microsoft Corporation') and
not line.startswith('Microsoft (R) Macro Assembler') and
not line.startswith(' Assembling: ') and
line):
print line
return popen.returncode
def ExecRcWrapper(self, arch, *args):
"""Filter logo banner from invocations of rc.exe. Older versions of RC
don't support the /nologo flag."""
env = self._GetEnv(arch)
popen = subprocess.Popen(args, shell=True, env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
for line in out.splitlines():
if (not line.startswith('Microsoft (R) Windows (R) Resource Compiler') and
not line.startswith('Copy' + 'right (C' +
') Microsoft Corporation') and
line):
print line
return popen.returncode
def ExecActionWrapper(self, arch, rspfile, *dir):
"""Runs an action command line from a response file using the environment
for |arch|. If |dir| is supplied, use that as the working directory."""
env = self._GetEnv(arch)
# TODO(scottmg): This is a temporary hack to get some specific variables
# through to actions that are set after GN-time. http://crbug.com/333738.
for k, v in os.environ.iteritems():
if k not in env:
env[k] = v
args = open(rspfile).read()
dir = dir[0] if dir else None
return subprocess.call(args, shell=True, env=env, cwd=dir)
def ExecClCompile(self, project_dir, selected_files):
"""Executed by msvs-ninja projects when the 'ClCompile' target is used to
build selected C/C++ files."""
project_dir = os.path.relpath(project_dir, BASE_DIR)
selected_files = selected_files.split(';')
ninja_targets = [os.path.join(project_dir, filename) + '^^'
for filename in selected_files]
cmd = ['ninja.exe']
cmd.extend(ninja_targets)
return subprocess.call(cmd, shell=True, cwd=BASE_DIR)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
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