Add yasm to the GN build.
This is forked off of https://codereview.chromium.org/266613002 The code to compile yasm itself is mostly from that patch, with a few updates for the other changes. Adds a template for running compiled binaries. Compared to Albert's patch above, this assumes the binary is generated by the source tree so can have a cleaner interface (just specify the label of the tool you use). The yasm rule is new compared to Albert's patch. It uses a special wrapper script instead of the new compiled_action templates so it can properly support depfiles. This also adds convenient support for defines and include dirs. This adds some trivial ios changes to the content/public/browser. This should be a NOP now. Fixes a bug in GN depfile creation. Previously, the .d file was emitted as an output of the script, but this confuses ninja. This change just removes that. BUG= R=ajwong@chromium.org Review URL: https://codereview.chromium.org/321323004 git-svn-id: http://src.chromium.org/svn/trunk/src/build@276772 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
00a2d7c2ff
Коммит
2e63e4f6df
|
@ -0,0 +1,148 @@
|
|||
# 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.
|
||||
|
||||
# This file introduces two related templates that act like action and
|
||||
# action_foreach but instead of running a Python script, it will compile a
|
||||
# given tool in the host toolchain and run that (either once or over the list
|
||||
# of inputs, depending on the variant).
|
||||
#
|
||||
# Parameters
|
||||
#
|
||||
# tool (required)
|
||||
# [label] Label of the tool to run. This should be an executable, and
|
||||
# this label should not include a toolchain (anything in parens). The
|
||||
# host compile of this tool will be used.
|
||||
#
|
||||
# outputs (required)
|
||||
# [list of files] Like the outputs of action (if using "compiled_action",
|
||||
# this would be just the list of outputs), or action_foreach (if using
|
||||
# "compiled_action_foreach", this would contain source expansions mapping
|
||||
# input to output files).
|
||||
#
|
||||
# args (required)
|
||||
# [list of strings] Same meaning as action/action_foreach.
|
||||
#
|
||||
# visibility
|
||||
# source_prereqs
|
||||
# deps
|
||||
# args (all optional)
|
||||
# Same meaning as action/action_foreach.
|
||||
#
|
||||
#
|
||||
# Example of usage:
|
||||
#
|
||||
# compiled_action("run_my_tool") {
|
||||
# tool = "//tools/something:mytool"
|
||||
# outputs = [
|
||||
# "$target_gen_dir/mysource.cc",
|
||||
# "$target_gen_dir/mysource.h",
|
||||
# ]
|
||||
#
|
||||
# # The tool takes this input.
|
||||
# source_prereqs = [ "my_input_file.idl" ]
|
||||
#
|
||||
# # In this case, the tool takes as arguments the input file and the output
|
||||
# # build dir (both relative to the "cd" that the script will be run in)
|
||||
# # and will produce the output files listed above.
|
||||
# args = [
|
||||
# rebase_path("my_input_file.idl", root_build_dir),
|
||||
# "--output-dir", rebase_path(target_gen_dir, root_build_dir),
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
# You would typically declare your tool like this:
|
||||
# if (host_toolchain == current_toolchain) {
|
||||
# executable("mytool") {
|
||||
# ...
|
||||
# }
|
||||
# }
|
||||
# The if statement around the executable is optional. That says "I only care
|
||||
# about this target in the host toolchain". Usually this is what you want, and
|
||||
# saves unnecessarily compiling your tool for the target platform. But if you
|
||||
# need a target build of your tool as well, just leave off the if statement.
|
||||
|
||||
template("compiled_action") {
|
||||
assert(defined(invoker.tool), "tool must be defined for $target_name")
|
||||
assert(defined(invoker.outputs), "outputs must be defined for $target_name")
|
||||
assert(defined(invoker.args), "args must be defined for $target_name")
|
||||
|
||||
action(target_name) {
|
||||
if (defined(invoker.visibility)) {
|
||||
visibility = invoker.visibility
|
||||
}
|
||||
|
||||
script = "//build/gn_run_binary.py"
|
||||
|
||||
if (defined(invoker.source_prereqs)) {
|
||||
source_prereqs = invoker.source_prereqs
|
||||
}
|
||||
outputs = invoker.outputs
|
||||
|
||||
# Constuct the host toolchain version of the tool.
|
||||
host_tool = invoker.tool + "($host_toolchain)"
|
||||
|
||||
# Get the path to the executable. Currently, this assumes that the tool
|
||||
# does not specify output_name so that the target name is the name to use.
|
||||
# If that's not the case, we'll need another argument to the script to
|
||||
# specify this, since we can't know what the output name is (it might be in
|
||||
# another file not processed yet).
|
||||
host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
|
||||
get_label_info(host_tool, "name")
|
||||
|
||||
deps = [ host_tool ]
|
||||
if (defined(invoker.deps)) {
|
||||
deps += invoker.deps
|
||||
}
|
||||
|
||||
# The script takes as arguments the binary to run, and then the arguments
|
||||
# to pass it.
|
||||
args = [
|
||||
rebase_path(host_executable, root_build_dir)
|
||||
] + invoker.args
|
||||
}
|
||||
}
|
||||
|
||||
template("compiled_action_foreach") {
|
||||
assert(defined(invoker.sources), "sources must be defined for $target_name")
|
||||
assert(defined(invoker.tool), "tool must be defined for $target_name")
|
||||
assert(defined(invoker.outputs), "outputs must be defined for $target_name")
|
||||
assert(defined(invoker.args), "args must be defined for $target_name")
|
||||
|
||||
action_foreach(target_name) {
|
||||
# Otherwise this is a standalone action, define visibility if requested.
|
||||
if (defined(invoker.visibility)) {
|
||||
visibility = invoker.visibility
|
||||
}
|
||||
|
||||
script = "//build/gn_run_binary.py"
|
||||
sources = invoker.sources
|
||||
|
||||
if (defined(invoker.source_prereqs)) {
|
||||
source_prereqs = invoker.source_prereqs
|
||||
}
|
||||
outputs = invoker.outputs
|
||||
|
||||
# Constuct the host toolchain version of the tool.
|
||||
host_tool = invoker.tool + "($host_toolchain)"
|
||||
|
||||
# Get the path to the executable. Currently, this assumes that the tool
|
||||
# does not specify output_name so that the target name is the name to use.
|
||||
# If that's not the case, we'll need another argument to the script to
|
||||
# specify this, since we can't know what the output name is (it might be in
|
||||
# another file not processed yet).
|
||||
host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
|
||||
get_label_info(host_tool, "name")
|
||||
|
||||
deps = [ host_tool ]
|
||||
if (defined(invoker.deps)) {
|
||||
deps += invoker.deps
|
||||
}
|
||||
|
||||
# The script takes as arguments the binary to run, and then the arguments
|
||||
# to pass it.
|
||||
args = [
|
||||
rebase_path(host_executable, root_build_dir)
|
||||
] + invoker.args
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
# 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.
|
||||
|
||||
"""Helper script for GN to run an arbitrary binary. See compiled_action.gni.
|
||||
|
||||
Run with:
|
||||
python gn_run_binary.py <binary_name> [args ...]
|
||||
"""
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# This script is designed to run binaries produced by the current build. We
|
||||
# always prefix it with "./" to avoid picking up system versions that might
|
||||
# also be on the path.
|
||||
path = './' + sys.argv[1]
|
||||
|
||||
# The rest of the arguements are passed directly to the executable.
|
||||
args = [path] + sys.argv[2:]
|
||||
|
||||
sys.exit(subprocess.call(args))
|
Загрузка…
Ссылка в новой задаче