diff --git a/go/tools/builders/protoc.go b/go/tools/builders/protoc.go index b303134475..8e5b2adefb 100644 --- a/go/tools/builders/protoc.go +++ b/go/tools/builders/protoc.go @@ -53,7 +53,6 @@ func run(args []string) error { outPath := flags.String("out_path", "", "The base output path to write to.") plugin := flags.String("plugin", "", "The go plugin to use.") importpath := flags.String("importpath", "", "The importpath for the generated sources.") - compilerPath := flags.String("compiler_path", "", "The value for PATH.") flags.Var(&options, "option", "The plugin options.") flags.Var(&descriptors, "descriptor_set", "The descriptor set to read.") flags.Var(&expected, "expected", "The expected output files.") @@ -85,7 +84,6 @@ func run(args []string) error { } protoc_args = append(protoc_args, flags.Args()...) cmd := exec.Command(*protoc, protoc_args...) - cmd.Env = append(os.Environ(), fmt.Sprintf("PATH=%s", *compilerPath)) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { diff --git a/proto/compiler.bzl b/proto/compiler.bzl index 0b48ffaacb..57635d780c 100644 --- a/proto/compiler.bzl +++ b/proto/compiler.bzl @@ -69,7 +69,6 @@ def go_proto_compile(go, compiler, protos, imports, importpath): args.add("-plugin", compiler.plugin) # TODO(jayconrod): can we just use go.env instead? - args.add("-compiler_path", go.cgo_tools.c_compiler_path.rpartition("/")[0]) args.add_all(compiler.options, before_each = "-option") if compiler.import_path_option: args.add_all([importpath], before_each = "-option", format_each = "import_path=%s") diff --git a/tests/core/cross/BUILD.bazel b/tests/core/cross/BUILD.bazel index 3666257938..a278467201 100644 --- a/tests/core/cross/BUILD.bazel +++ b/tests/core/cross/BUILD.bazel @@ -1,4 +1,5 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_source", "go_test") +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@io_bazel_rules_go//tests:bazel_tests.bzl", "bazel_test") test_suite( @@ -80,3 +81,23 @@ go_library( importpath = "github.com/bazelbuild/rules_go/tests/core/cross/ios_lib", tags = ["manual"], ) + +bazel_test( + name = "proto_test", + args = ["--platforms=@io_bazel_rules_go//go/toolchain:ios_amd64"], + command = "build", + targets = [":cross_go_proto"], +) + +proto_library( + name = "cross_proto", + srcs = ["cross.proto"], + tags = ["manual"], +) + +go_proto_library( + name = "cross_go_proto", + importpath = "github.com/bazelbuild/rules_go/tests/core/cross", + protos = [":cross_proto"], + tags = ["manual"], +) diff --git a/tests/core/cross/README.rst b/tests/core/cross/README.rst index 6fd155b779..7b07b72ac5 100644 --- a/tests/core/cross/README.rst +++ b/tests/core/cross/README.rst @@ -25,3 +25,7 @@ a dependency using ``@io_bazel_rules_go//go/platform:darwin``, which is true when building for iOS (tested by ``ios_select_test``) and macOS (tested by ``use_ios_lib``). +proto_test +---------- + +Tests that a ``go_proto_library`` can be cross-compiled with ``--platforms``. diff --git a/tests/core/cross/cross.proto b/tests/core/cross/cross.proto new file mode 100644 index 0000000000..fce63ebf8c --- /dev/null +++ b/tests/core/cross/cross.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package cross; + +option go_package = "github.com/bazelbuild/rules_go/tests/core/cross"; + +message Foo { + int64 x = 1; +}