From ae0c98ed2715c685b0cb97ac6e5d65101168b625 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 24 Nov 2019 16:56:11 +0000 Subject: [PATCH 1/4] common-mk: don't leak source-absolute paths Source-absolute paths like //vm_tools/whatever were being leaked to subprocesses, which of course didn't know how to understand them. With this patch, source-absolute paths are only used to tell GN the outputs, and normal Unix paths are passed to subprocesses. --- common-mk/external_dependencies/BUILD.gn | 3 ++- common-mk/mojom_bindings_generator.gni | 12 ++++++------ common-mk/mojom_type_mappings_generator.gni | 2 +- common-mk/pkg_config.gni | 3 ++- common-mk/proto_library.gni | 19 ++++++++++--------- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/common-mk/external_dependencies/BUILD.gn b/common-mk/external_dependencies/BUILD.gn index 2581d31ac8..2ead288006 100644 --- a/common-mk/external_dependencies/BUILD.gn +++ b/common-mk/external_dependencies/BUILD.gn @@ -45,6 +45,7 @@ genxml2cpp("dbus-proxies") { action("cloud_policy_proto_generator") { policy_resources_dir = "${sysroot}/usr/share/policy_resources" proto_out_dir = "${target_gen_dir}/proto" + cloud_policy_protobuf_dir = rebase_path(proto_out_dir) policy_tools_dir = "${sysroot}/usr/share/policy_tools" script = "${policy_tools_dir}/generate_policy_source.py" @@ -54,7 +55,7 @@ action("cloud_policy_proto_generator") { ] outputs = [ "${proto_out_dir}/cloud_policy.proto" ] args = [ - "--cloud-policy-protobuf=${proto_out_dir}/cloud_policy.proto", + "--cloud-policy-protobuf=${cloud_policy_protobuf_dir}/cloud_policy.proto", "--chrome-version-file=${policy_resources_dir}/VERSION", "--target-platform=chromeos", "--policy-templates-file=${policy_resources_dir}/policy_templates.json", diff --git a/common-mk/mojom_bindings_generator.gni b/common-mk/mojom_bindings_generator.gni index 038c20ed36..205d7d3037 100644 --- a/common-mk/mojom_bindings_generator.gni +++ b/common-mk/mojom_bindings_generator.gni @@ -100,7 +100,7 @@ template("generate_mojom_bindings_gen") { args = [ "mkdir", "-p", - mojo_templates_dir, + rebase_path(mojo_templates_dir), ] } @@ -116,7 +116,7 @@ template("generate_mojom_bindings_gen") { args = [ "--use_bundled_pylibs", "-o", - mojo_templates_dir, + rebase_path(mojo_templates_dir), "precompile", ] deps = [ ":${mojo_templates_dir_action_name}" ] @@ -143,7 +143,7 @@ template("generate_mojom_bindings_gen") { args = [ "--mojom-file-list={{response_file_name}}", "--output-root", - _mojo_output_base, + rebase_path(_mojo_output_base), "--input-root", mojo_root, # Mojo depth. "--input-root", @@ -188,11 +188,11 @@ template("generate_mojom_bindings_gen") { mojom_bindings_generator, "--use_bundled_pylibs", "--output_dir", - _mojo_output_base, + rebase_path(_mojo_output_base), "generate", "--filelist={{response_file_name}}", "--bytecode_path", - mojo_templates_dir, + rebase_path(mojo_templates_dir), "-I", mojo_root, # Mojo include path. "-d", @@ -216,7 +216,7 @@ template("generate_mojom_bindings_gen") { foreach(typemap, invoker.typemaps) { args += [ "--typemap", - typemap, + rebase_path(typemap), ] } } diff --git a/common-mk/mojom_type_mappings_generator.gni b/common-mk/mojom_type_mappings_generator.gni index ff09397111..959a8b6ca9 100644 --- a/common-mk/mojom_type_mappings_generator.gni +++ b/common-mk/mojom_type_mappings_generator.gni @@ -21,7 +21,7 @@ template("generate_mojom_type_mappings") { outputs = [ "$target_gen_dir/${target_name}_typemapping" ] args = [ "--output", - "$target_gen_dir/${target_name}_typemapping", + rebase_path("$target_gen_dir/${target_name}_typemapping"), ] + rebase_path(sources, root_build_dir) } } diff --git a/common-mk/pkg_config.gni b/common-mk/pkg_config.gni index b2c58845d4..31d3f4ab51 100644 --- a/common-mk/pkg_config.gni +++ b/common-mk/pkg_config.gni @@ -81,7 +81,8 @@ template("generate_pkg_config") { if (!defined(output_name)) { output_name = name } - outputs = [ "${target_out_dir}/${output_name}.pc" ] + lib_path = "${target_out_dir}/${output_name}.pc" + outputs = [ lib_path ] script = "//common-mk/generate-pc.py" args = [ "--output" ] + rebase_path(outputs) + [ "--name=" + name ] diff --git a/common-mk/proto_library.gni b/common-mk/proto_library.gni index e64aedabe0..fb9fb4231d 100644 --- a/common-mk/proto_library.gni +++ b/common-mk/proto_library.gni @@ -56,7 +56,7 @@ template("proto_library") { cc_dir = "${root_gen_dir}/${proto_out_dir}" proto_in_dir = rebase_path(proto_in_dir) - proto_out_dir = rebase_path(proto_out_dir) + proto_out_dir = rebase_path(cc_dir) proto_lib_dirs = [ proto_in_dir, @@ -96,10 +96,9 @@ template("proto_library") { } outputs = [] if (gen_python) { - python_dir = "${root_gen_dir}/${proto_out_dir}/py" args += [ "--python_out", - "${python_dir}", + "${proto_out_dir}/py", ] foreach(source, sources) { source = rebase_path(source, proto_in_dir) @@ -109,19 +108,19 @@ template("proto_library") { } if (gen_grpc) { if (gen_grpc_gmock) { - args += [ "--grpc_out=generate_mock_code=true:${cc_dir}" ] + args += [ "--grpc_out=generate_mock_code=true:${proto_out_dir}" ] foreach(source, sources) { source = rebase_path(source, proto_in_dir) source = string_replace(source, ".proto", "") outputs += [ "${cc_dir}/${source}_mock.grpc.pb.h" ] } } else { - args += [ "--grpc_out=${cc_dir}" ] + args += [ "--grpc_out=${proto_out_dir}" ] } grpc_cpp_plugin = "/usr/bin/grpc_cpp_plugin" args += [ "--plugin=protoc-gen-grpc=${grpc_cpp_plugin}", - "--cpp_out=${gen_cpp_mode}${cc_dir}", + "--cpp_out=${gen_cpp_mode}${proto_out_dir}", ] foreach(source, sources) { source = rebase_path(source, proto_in_dir) @@ -135,7 +134,7 @@ template("proto_library") { } } if (!gen_grpc && !gen_python) { - args += [ "--cpp_out=${gen_cpp_mode}${cc_dir}" ] + args += [ "--cpp_out=${gen_cpp_mode}${proto_out_dir}" ] foreach(source, sources) { source = rebase_path(source, proto_in_dir) source = string_replace(source, ".proto", "") @@ -238,7 +237,9 @@ template("goproto_library") { # otherwise file descriptor var name will conflict. # cf) https://github.com/golang/protobuf/issues/109 + cc_dir = "${root_gen_dir}/${proto_out_dir}" proto_in_dir = rebase_path(invoker.proto_in_dir) + proto_out_dir = rebase_path(cc_dir) # Build protoc command line to run. script = "//common-mk/file_generator_wrapper.py" @@ -278,7 +279,7 @@ template("goproto_library") { "--go_out", # go_out_prefix can be empty, so we can always add a colon here. - "${go_out_prefix}:${root_gen_dir}/${proto_out_dir}", + "${go_out_prefix}:${proto_out_dir}", ] foreach(source, sources) { args += [ rebase_path(source) ] @@ -288,7 +289,7 @@ template("goproto_library") { outputs = [] foreach(source, invoker.sources) { name = get_path_info(source, "name") - outputs += [ "${root_gen_dir}/${proto_out_dir}/${name}.pb.go" ] + outputs += [ "${cc_dir}/${name}.pb.go" ] } } } -- 2.31.1