Skip to content

Commit

Permalink
Pull buildtools to get GN r282653
Browse files Browse the repository at this point in the history
This uses the proto file directory for the generated files rather than the directory of the BUILD file. This makes it more natural when you have a BUILD file in a different directory than the proto files.

Fixes a search-and-replace error that accidentally changed the fallback source_prereqs code to use "inputs".

Fix ozone build.

BUG=
R=ajwong@chromium.org

Review URL: https://codereview.chromium.org/386943006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282998 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Jul 14, 2014
1 parent 228b7d9 commit 3b6e683
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 51 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling build tools
# and whatever else without interference from each other.
"buildtools_revision": "8e5430c72df4f1482eb8cae5cdb9fe963d5a50c4",
"buildtools_revision": "59b93247766e1cdac6e482637ad493df38f7aeb7",
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling PDFIum
# and whatever else without interference from each other.
Expand Down
9 changes: 6 additions & 3 deletions build/secondary/tools/grit/grit_rule.gni
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ template("grit") {
grit_flags,
"list lines")

# The inputs are relative to the current (build) directory, rebase to
# the current one.
grit_outputs = rebase_path(grit_outputs_build_rel, ".", root_build_dir)
# The names returned by grit are relative to the current (build) directory,
# but references to files in this template are expected to be relative to the
# invoking BUILD.gn file's directory. Make it absolute so there's no
# ambiguity.
grit_outputs = get_path_info(
rebase_path(grit_outputs_build_rel, ".", root_build_dir), "abspath")

# The config and the action below get this visibility son only the generated
# source set can depend on them. The variable "target_name" will get
Expand Down
1 change: 0 additions & 1 deletion components/autofill/content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ proto_library("risk_proto") {
sources = [
"risk/proto/fingerprint.proto",
]
proto_in_dir = "risk/proto"
proto_out_dir = "components/autofill/content/browser/risk/proto"
}

Expand Down
2 changes: 0 additions & 2 deletions components/policy/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ if (enable_configuration_policy) {
proto_library("cloud_policy_proto_generated_compile") {
sources = [ cloud_policy_proto_path ]

proto_in_dir = policy_gen_dir
proto_out_dir = "policy/proto"
cc_generator_options = "dllexport_decl=POLICY_PROTO_EXPORT:"
cc_include = "components/policy/policy_proto_export.h"
Expand All @@ -106,7 +105,6 @@ if (enable_configuration_policy) {
# This target builds the "full" protobuf, used for tests only.
proto_library("chrome_settings_proto_generated_compile") {
sources = [ chrome_settings_proto_path ]
proto_in_dir = policy_gen_dir
proto_out_dir = "policy/proto"

deps = [
Expand Down
2 changes: 0 additions & 2 deletions device/media_transfer_protocol/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import("//third_party/protobuf/proto_library.gni")
# GYP version: device/media_transfer_protocol/media_transfer_protocol.gyp:mtp_file_entry_proto
proto_library("mtp_file_entry_proto") {
sources = [ "//third_party/cros_system_api/dbus/mtp_file_entry.proto" ]
proto_in_dir = "//third_party/cros_system_api/dbus"
proto_out_dir = "device/media_transfer_protocol"
}

# GYP version: device/media_transfer_protocol/media_transfer_protocol.gyp:mtp_storage_info_proto
proto_library("mtp_storage_info_proto") {
sources = [ "//third_party/cros_system_api/dbus/mtp_storage_info.proto" ]
proto_in_dir = "//third_party/cros_system_api/dbus"
proto_out_dir = "device/media_transfer_protocol"
}

Expand Down
3 changes: 1 addition & 2 deletions third_party/libphonenumber/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ proto_library("proto") {
"src/resources/phonemetadata.proto",
"src/resources/phonenumber.proto",
]
proto_in_dir = "src/resources"
proto_out_dir = "third_party/libphonenumber/phonenumbers"
}

config("libphonenumber_config") {
include_dirs = [
"src",
"$root_gen_dir/protoc_out/third_party/libphonenumber",
"$root_gen_dir/third_party/libphonenumber",
]
defines = [ "I18N_PHONENUMBERS_USE_ICU_REGEXP=1" ]
if (!is_android) {
Expand Down
60 changes: 26 additions & 34 deletions third_party/protobuf/proto_library.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
#
# Protobuf parameters:
#
# proto_in_dir (optional)
# The path to the directory containing the .proto files. If left out, it
# defaults to '.'.
#
# proto_out_dir (optional)
# Specifies the path suffix that output files are generated under.
# Targets that gyp-depend on my_proto_lib will be able to include the
# Specifies the path suffix that output files are generated under. This
# path will be appended to the root_gen_dir.
#
# Targets that depend on the proto target will be able to include the
# resulting proto headers with an include like:
# #include "dir/for/my_proto_lib/foo.pb.h"
# If undefined, this defaults to matching the input directory.
# If undefined, this defaults to matching the input directory for each
# .proto file (you should almost always use the default mode).
#
# cc_generator_options (optional)
# List of extra flags passed to the protocol compiler. If you need to
Expand Down Expand Up @@ -62,22 +61,25 @@ template("proto_library") {

sources = invoker.sources

# TODO(brettw) it would be better if this used the target gen dir.
# Compute the output directory, both relative to the source root (for
# declaring "outputs") and relative to the build dir (for passing to the
# script).
if (defined(invoker.proto_out_dir)) {
proto_out_dir = invoker.proto_out_dir
# Put the results in the specified dir in the gen tree.
out_dir = "$root_gen_dir/" + invoker.proto_out_dir
rel_out_dir = rebase_path(out_dir, root_build_dir)
} else {
# This computes the relative path inside the target_gen_dir that
# we'd put the files in, which maps to the current directory path.
# We'll insert "protoc_out" at the beginning for compatibility with GYP.
proto_out_dir = rebase_path(target_gen_dir, root_gen_dir)
# Use the gen directory corresponding to the source file. This expansion
# will be done differently in the outputs and the args, so we don't need
# to worry about rebasing as above.
out_dir = "{{source_gen_dir}}"
rel_out_dir = "{{source_gen_dir}}"
}
cc_dir = "$root_gen_dir/protoc_out/$proto_out_dir"
py_dir = "$root_gen_dir/pyproto/$proto_out_dir"

outputs = [
"$py_dir/{{source_name_part}}_pb2.py",
"$cc_dir/{{source_name_part}}.pb.cc",
"$cc_dir/{{source_name_part}}.pb.h",
"$out_dir/{{source_name_part}}_pb2.py",
"$out_dir/{{source_name_part}}.pb.cc",
"$out_dir/{{source_name_part}}.pb.h",
]

args = []
Expand All @@ -86,19 +88,8 @@ template("proto_library") {
}

args += [
"--protobuf",
rebase_path("$cc_dir/{{source_name_part}}.pb.h", root_build_dir),
]

if (defined(invoker.proto_in_dir)) {
proto_in_dir = invoker.proto_in_dir
} else {
# Extract the current source dir.
proto_in_dir = get_label_info(":$target_name", "dir")
}
args += [
"--proto-in-dir",
rebase_path(proto_in_dir, root_build_dir),
"--protobuf", "$rel_out_dir/{{source_name_part}}.pb.h",
"--proto-in-dir", "{{source_dir}}",
"--proto-in-file", "{{source_file_part}}",
# TODO(brettw) support system protobuf compiler.
"--use-system-protobuf=0",
Expand All @@ -109,7 +100,7 @@ template("proto_library") {
"--",
# Prepend with "./" so this will never pick up the system one (normally
# when not cross-compiling, protoc's output directory will be the same
# as the build dir, so the relative location will be empty.
# as the build dir, so the relative location will be empty).
"./" + rebase_path(get_label_info(protoc_label, "root_out_dir") +
"/protoc", root_build_dir),
]
Expand All @@ -123,8 +114,9 @@ template("proto_library") {
cc_generator_options = ""
}
args += [
"--cpp_out", cc_generator_options + rebase_path(cc_dir, root_build_dir),
"--python_out", rebase_path(py_dir, root_build_dir),
# cc_generator_options is supposed to end in a colon if it's nonempty.
"--cpp_out", "$cc_generator_options$rel_out_dir",
"--python_out", rel_out_dir,
]

deps = [ protoc_label ]
Expand Down
5 changes: 3 additions & 2 deletions tools/gn/file_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ class FileTemplate {
static const char* GetNinjaVariableNameForType(Subrange::Type type);

// Extracts the given type of substitution from the given source file.
// If output_style is RELATIVE, relative_to indicates the directory that the
// relative directories should be relative to, otherwise it is ignored.
// If output_style is OUTPUT_RELATIVE, relative_to indicates the directory
// that the relative directories should be relative to, otherwise it is
// ignored.
static std::string GetSubstitution(const Settings* settings,
const SourceFile& source,
Subrange::Type type,
Expand Down
2 changes: 1 addition & 1 deletion tools/gn/filesystem_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ bool EnsureStringIsInOutputDir(const SourceDir& dir,
// This check will be wrong for all proper prefixes "e.g. "/output" will
// match "/out" but we don't really care since this is just a sanity check.
const std::string& dir_str = dir.value();
if (str.compare(0, dir_str.length(), dir_str, 0, dir_str.length()) == 0)
if (str.compare(0, dir_str.length(), dir_str) == 0)
return true; // Output directory is hardcoded.

if (allow_templates) {
Expand Down
4 changes: 2 additions & 2 deletions tools/gn/target_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ void TargetGenerator::FillPublic() {
void TargetGenerator::FillInputs() {
const Value* value = scope_->GetValue(variables::kInputs, true);
if (!value) {
// Older versions used "inputs". Allow use of this variable until
// Older versions used "source_prereqs". Allow use of this variable until
// all callers are updated.
// TODO(brettw) remove this eventually.
value = scope_->GetValue("inputs", true);
value = scope_->GetValue("source_prereqs", true);

if (!value)
return;
Expand Down
2 changes: 1 addition & 1 deletion ui/ozone/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ component("ozone") {
"//ipc",
"//skia",
"//ui/events",
"//ui/events/ozone",
"//ui/events/ozone:events_ozone",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gfx/ipc",
Expand Down

0 comments on commit 3b6e683

Please sign in to comment.