diff --git a/scala_proto/scala_proto.bzl b/scala_proto/scala_proto.bzl index b598f2c9b..bb9f7756a 100644 --- a/scala_proto/scala_proto.bzl +++ b/scala_proto/scala_proto.bzl @@ -320,7 +320,7 @@ def _colon_paths(data): def _gen_proto_srcjar_impl(ctx): acc_imports = depset() - transitive_proto_path_flags = depset() + transitive_proto_paths = depset() proto_deps, jvm_deps = [], [] for target in ctx.attr.deps: @@ -328,8 +328,8 @@ def _gen_proto_srcjar_impl(ctx): proto_deps.append(target) acc_imports += target.proto.transitive_sources #inline this if after 0.12.0 is the oldest supported version - if hasattr(target.proto, 'transitive_proto_path_flags'): - transitive_proto_path_flags += target.proto.transitive_proto_path_flags + if hasattr(target.proto, 'transitive_proto_path'): + transitive_proto_paths += target.proto.transitive_proto_path else: jvm_deps.append(target) @@ -344,7 +344,7 @@ def _gen_proto_srcjar_impl(ctx): # Command line args to worker cannot be empty so using padding flags_arg = "-" + ",".join(ctx.attr.flags), # Command line args to worker cannot be empty so using padding - packages = "-" + ":".join(transitive_proto_path_flags.to_list()) + packages = "-" + ":".join(transitive_proto_paths.to_list()) ) argfile = ctx.new_file(ctx.outputs.srcjar, "%s_worker_input" % ctx.label.name) ctx.file_action(output=argfile, content=worker_content) diff --git a/src/scala/scripts/PBGenerateRequest.scala b/src/scala/scripts/PBGenerateRequest.scala index b38c16c1c..091d0c02a 100644 --- a/src/scala/scripts/PBGenerateRequest.scala +++ b/src/scala/scripts/PBGenerateRequest.scala @@ -5,6 +5,7 @@ import java.nio.file.{Files, Path, Paths} class PBGenerateRequest(val jarOutput: String, val scalaPBOutput: Path, val scalaPBArgs: List[String]) object PBGenerateRequest { + def from(args: java.util.List[String]): PBGenerateRequest = { val jarOutput = args.get(0) val parsedProtoFiles = args.get(1).split(':').toList.map { rootAndFile => @@ -31,15 +32,20 @@ object PBGenerateRequest { case s if s.charAt(0) == '-' => Some(s.tail) //drop padding character case other => sys.error(s"expected a padding character of - (dash), but found: $other") } - val transitiveProtoPathFlags = args.get(3) match { + val transitiveProtoPaths = args.get(3) match { case "-" => Nil case s if s.charAt(0) == '-' => s.tail.split(':').toList //drop padding character case other => sys.error(s"expected a padding character of - (dash), but found: $other") } + val tmp = Paths.get(Option(System.getProperty("java.io.tmpdir")).getOrElse("/tmp")) val scalaPBOutput = Files.createTempDirectory(tmp, "bazelscalapb") val flagPrefix = flagOpt.fold("")(_ + ":") - val scalaPBArgs = s"--scala_out=$flagPrefix$scalaPBOutput" :: (transitiveProtoPathFlags ++ imports ++ protoFiles) + val scalaPBArgs = s"--scala_out=$flagPrefix$scalaPBOutput" :: (padWithProtoPathPrefix(transitiveProtoPaths) ++ imports ++ protoFiles) new PBGenerateRequest(jarOutput, scalaPBOutput, scalaPBArgs) } + + private def padWithProtoPathPrefix(transitiveProtoPathFlags: List[String]) = + transitiveProtoPathFlags.map("--proto_path="+_) + } \ No newline at end of file