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

Add transitive path arguments when compiling protobuf #289

Closed
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
10 changes: 9 additions & 1 deletion rules/scala_proto/private/ScalaProtoWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ object ScalaProtoWorker extends WorkerMain[Unit] {

private[this] val argParser: ArgumentParser = {
val parser = ArgumentParsers.newFor("proto").addHelp(true).fromFilePrefix("@").build
parser
.addArgument("--proto_path")
.help("Proto path")
.metavar("proto_path")
.nargs("*")
.`type`(Arguments.fileType.verifyIsDirectory)
.setDefault_(Collections.emptyList)
parser
.addArgument("--output_dir")
.help("Output dir")
Expand All @@ -36,11 +43,12 @@ object ScalaProtoWorker extends WorkerMain[Unit] {
protected[this] def work(ctx: Unit, args: Array[String]): Unit = {
val namespace = argParser.parseArgs(args)
val sources = namespace.getList[File]("sources").asScala.toList
val path = namespace.getList[File]("proto_path").asScala.toList

val scalaOut = namespace.get[File]("output_dir").toPath
Files.createDirectories(scalaOut)

val params = s"--scala_out=$scalaOut" :: sources.map(_.getPath)
val params = s"--scala_out=$scalaOut" :: path.map("--proto_path " ++ _.getPath) ++ sources.map(_.getPath)

ProtocBridge.runWithGenerators(
protoc = a => com.github.os72.protocjar.Protoc.runProtoc(a.toArray),
Expand Down
1 change: 1 addition & 0 deletions rules/scala_proto/private/core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def scala_proto_library_implementation(ctx):

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