Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Don't generate code for proto dependencies #217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions rules/scala_proto/private/core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def scala_proto_library_implementation(ctx):

protos = [dep.proto for dep in proto_deps]

direct_sources = depset(direct = [source for proto in protos for source in proto.direct_sources])
transitive_sources = depset(transitive = [proto.transitive_sources for proto in protos])
transitive_proto_path = depset(transitive = [proto.transitive_proto_path for proto in protos])

Expand All @@ -32,7 +33,7 @@ def scala_proto_library_implementation(ctx):

args = ctx.actions.args()
args.add("--output_dir", gendir.path)
args.add_all("--", transitive_sources)
args.add_all("--", direct_sources)
args.set_param_file_format("multiline")
args.use_param_file("@%s", use_always = True)

Expand All @@ -43,7 +44,7 @@ def scala_proto_library_implementation(ctx):

ctx.actions.run(
mnemonic = "ScalaProtoCompile",
inputs = depset(direct = [], transitive = [transitive_sources]),
inputs = depset(transitive = [transitive_sources]),
outputs = [gendir],
executable = compiler.compiler.files_to_run.executable,
tools = compiler_inputs,
Expand Down
27 changes: 27 additions & 0 deletions tests/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,30 @@ scala_library(
"@annex_test//:com_thesamet_scalapb_scalapb_runtime_2_12",
],
)

proto_library(
name = "one_proto",
srcs = ["one.proto"],
deps = [
":zero_proto",
],
visibility = ["//visibility:public"],
)

scala_proto_library(
name = "one_scala_proto",
deps = [
":one_proto",
],
)

scala_library(
name = "one_scala",
srcs = [":one_scala_proto"],
deps = [
":zero_scala",
"@annex_test//:com_google_protobuf_protobuf_java",
"@annex_test//:com_thesamet_scalapb_lenses_2_12",
"@annex_test//:com_thesamet_scalapb_scalapb_runtime_2_12",
],
)
10 changes: 10 additions & 0 deletions tests/proto/expected_one
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-rw---- 2.0 fat 0 bx 0% stor 20100101.000000 META-INF/
-rw---- 2.0 fat 48 b- 0% stor 20100101.000000 META-INF/MANIFEST.MF
-rw---- 1.0 fat 0 b- 0% stor 20100101.000000 anx/
-rw---- 1.0 fat 0 b- 0% stor 20100101.000000 anx/proto/
-rw---- 1.0 fat 0 b- 0% stor 20100101.000000 anx/proto/one/
-rw---- 2.0 fat 14827 b- 0% stor 20100101.000002 anx/proto/one/One$.class
-rw---- 2.0 fat 3097 b- 0% stor 20100101.000002 anx/proto/one/One$OneLens.class
-rw---- 2.0 fat 18959 b- 0% stor 20100101.000002 anx/proto/one/One.class
-rw---- 2.0 fat 6376 b- 0% stor 20100101.000002 anx/proto/one/OneProto$.class
-rw---- 2.0 fat 1937 b- 0% stor 20100101.000002 anx/proto/one/OneProto.class
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/proto/one.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto2";

option java_package = "anx.proto";

import "proto/zero.proto";

message One {
optional Zero zero = 1;
}
7 changes: 6 additions & 1 deletion tests/proto/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
[[ "$(bazel version | head -n1 | cut -d: -f2 | tr -d ' ')" =~ 0.15.*|0.16.* ]] || bazel build :zero_scala_proto

bazel build :zero_scala
diff expected <(
diff expected_zero <(
zipinfo -m -T --h-t "$(bazel info bazel-bin)/proto/zero_scala.jar"
)

bazel build :one_scala
diff expected_one <(
zipinfo -m -T --h-t "$(bazel info bazel-bin)/proto/one_scala.jar"
)