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

Include transitive_proto_paths in the call to protoc #211

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
8 changes: 7 additions & 1 deletion rules/scala_proto/private/ScalaProtoWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,24 @@ object ScalaProtoWorker extends WorkerMain[Unit] {
.`type`(Arguments.fileType.verifyCanRead.verifyIsFile)
.setDefault_(Collections.emptyList)
parser
.addArgument("-I", "--proto_path")
.help("Proto include paths")
.metavar("proto_path")
.action(Arguments.append())
parser
}

override def init(args: Option[Array[String]]): Unit = ()

protected[this] def work(ctx: Unit, args: Array[String]): Unit = {
val namespace = argParser.parseArgs(args)
val proto_paths = namespace.getList[String]("proto_path").asScala.map(f => s"--proto_path=$f").toList
val sources = namespace.getList[File]("sources").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" :: proto_paths ++ sources.map(_.getPath)

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

args = ctx.actions.args()
args.add("--output_dir", gendir.path)

for path in transitive_proto_path.to_list():
args.add("--proto_path=" + path)
if compiler.generator_params:
args.add("--generator_params", compiler.generator_params)
args.add_all("--", transitive_sources)
args.set_param_file_format("multiline")
args.use_param_file("@%s", use_always = True)
Expand Down