forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify mc.exe calling in GN, set environment.
There were previously two message compiler wrapper scripts which this unifies into one template and script in build. Explicitly sets the environment block when running mc.exe. Currently GN sets this automatically but will soon stop doing this. Review URL: https://codereview.chromium.org/1440693003 Cr-Commit-Position: refs/heads/master@{#359155}
- Loading branch information
brettw
authored and
Commit bot
committed
Nov 11, 2015
1 parent
f37b704
commit 4744642
Showing
7 changed files
with
105 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2015 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. | ||
|
||
assert(is_win, "This only runs on Windows.") | ||
|
||
# Runs mc.exe over a list of sources. The outputs (a header and rc file) are | ||
# placed in the target gen dir, and compiled. | ||
# | ||
# sources | ||
# List of message files to process. | ||
# | ||
# user_mode_logging (optional bool) | ||
# Generates user-mode logging code. Defaults to false (no logging code). | ||
# | ||
# deps, public_deps, visibility | ||
# Normal meaning. | ||
template("message_compiler") { | ||
action_name = "${target_name}_mc" | ||
source_set_name = target_name | ||
|
||
action_foreach(action_name) { | ||
visibility = [ ":$source_set_name" ] | ||
|
||
script = "//build/win/message_compiler.py" | ||
|
||
outputs = [ | ||
"$target_gen_dir/{{source_name_part}}.h", | ||
"$target_gen_dir/{{source_name_part}}.rc", | ||
] | ||
|
||
args = [ | ||
# The first argument is the environment file saved to the build | ||
# directory. This is required because the Windows toolchain setup saves | ||
# the VC paths and such so that running "mc.exe" will work with the | ||
# configured toolchain. This file is in the root build dir. | ||
"environment.$current_cpu", | ||
|
||
# Where to put the header. | ||
"-h", | ||
rebase_path(target_gen_dir, root_build_dir), | ||
|
||
# Where to put the .rc file. | ||
"-r", | ||
rebase_path(target_gen_dir, root_build_dir), | ||
|
||
# Input is Unicode. | ||
"-u", | ||
] | ||
if (defined(invoker.user_mode_logging) && invoker.user_mode_logging) { | ||
args += [ "-um" ] | ||
} | ||
args += [ "{{source}}" ] | ||
|
||
forward_variables_from(invoker, | ||
[ | ||
"deps", | ||
"public_deps", | ||
"sources", | ||
]) | ||
} | ||
|
||
# Compile the generated rc file. | ||
source_set(source_set_name) { | ||
forward_variables_from(invoker, [ "visibility" ]) | ||
sources = get_target_outputs(":$action_name") | ||
deps = [ | ||
":$action_name", | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2015 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. | ||
|
||
# Runs the Microsoft Message Compiler (mc.exe). This Python adapter is for the | ||
# GN build, which can only run Python and not native binaries. | ||
# | ||
# Usage: message_compiler.py <environment_file> [<args to mc.exe>*] | ||
|
||
import subprocess | ||
import sys | ||
|
||
# Read the environment block from the file. This is stored in the format used | ||
# by CreateProcess. Drop last 2 NULs, one for list terminator, one for trailing | ||
# vs. separator. | ||
env_pairs = open(sys.argv[1]).read()[:-2].split('\0') | ||
env_dict = dict([item.split('=', 1) for item in env_pairs]) | ||
|
||
# mc writes to stderr, so this explicitly redirects to stdout and eats it. | ||
try: | ||
subprocess.check_output(["mc.exe"] + sys.argv[2:], | ||
env=env_dict, | ||
stderr=subprocess.STDOUT) | ||
except subprocess.CalledProcessError as e: | ||
print e.output | ||
sys.exit(e.returncode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.