From 3b6e6832197c9b46e2f62ff0f0d61ffb05c17ff4 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Mon, 14 Jul 2014 19:25:57 +0000 Subject: [PATCH] Pull buildtools to get GN r282653 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 --- DEPS | 2 +- build/secondary/tools/grit/grit_rule.gni | 9 ++- components/autofill/content/browser/BUILD.gn | 1 - components/policy/BUILD.gn | 2 - device/media_transfer_protocol/BUILD.gn | 2 - third_party/libphonenumber/BUILD.gn | 3 +- third_party/protobuf/proto_library.gni | 60 +++++++++----------- tools/gn/file_template.h | 5 +- tools/gn/filesystem_utils.cc | 2 +- tools/gn/target_generator.cc | 4 +- ui/ozone/BUILD.gn | 2 +- 11 files changed, 41 insertions(+), 51 deletions(-) diff --git a/DEPS b/DEPS index 6b63f7702354..f7eaa7fa34ef 100644 --- a/DEPS +++ b/DEPS @@ -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. diff --git a/build/secondary/tools/grit/grit_rule.gni b/build/secondary/tools/grit/grit_rule.gni index a9745b444a43..2f03335f3c4d 100644 --- a/build/secondary/tools/grit/grit_rule.gni +++ b/build/secondary/tools/grit/grit_rule.gni @@ -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 diff --git a/components/autofill/content/browser/BUILD.gn b/components/autofill/content/browser/BUILD.gn index fd2b85bae981..bdae0f2f5406 100644 --- a/components/autofill/content/browser/BUILD.gn +++ b/components/autofill/content/browser/BUILD.gn @@ -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" } diff --git a/components/policy/BUILD.gn b/components/policy/BUILD.gn index 9a4f61e4cc97..9f992aaf70a4 100644 --- a/components/policy/BUILD.gn +++ b/components/policy/BUILD.gn @@ -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" @@ -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 = [ diff --git a/device/media_transfer_protocol/BUILD.gn b/device/media_transfer_protocol/BUILD.gn index 0e2ff84b28be..aea3c6b6365b 100644 --- a/device/media_transfer_protocol/BUILD.gn +++ b/device/media_transfer_protocol/BUILD.gn @@ -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" } diff --git a/third_party/libphonenumber/BUILD.gn b/third_party/libphonenumber/BUILD.gn index c4d244babff5..994eb3438ea6 100644 --- a/third_party/libphonenumber/BUILD.gn +++ b/third_party/libphonenumber/BUILD.gn @@ -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) { diff --git a/third_party/protobuf/proto_library.gni b/third_party/protobuf/proto_library.gni index 3f4cae906a0f..6382670237e5 100644 --- a/third_party/protobuf/proto_library.gni +++ b/third_party/protobuf/proto_library.gni @@ -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 @@ -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 = [] @@ -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", @@ -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), ] @@ -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 ] diff --git a/tools/gn/file_template.h b/tools/gn/file_template.h index ddbd67fd5a46..2071336c9f5e 100644 --- a/tools/gn/file_template.h +++ b/tools/gn/file_template.h @@ -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, diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc index 17fec9f4fb61..097a2276b225 100644 --- a/tools/gn/filesystem_utils.cc +++ b/tools/gn/filesystem_utils.cc @@ -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) { diff --git a/tools/gn/target_generator.cc b/tools/gn/target_generator.cc index d38dbd938770..12d09fca1527 100644 --- a/tools/gn/target_generator.cc +++ b/tools/gn/target_generator.cc @@ -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; diff --git a/ui/ozone/BUILD.gn b/ui/ozone/BUILD.gn index 8f66249542ae..b1c9928a6cfd 100644 --- a/ui/ozone/BUILD.gn +++ b/ui/ozone/BUILD.gn @@ -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",