diff --git a/rules/scala_proto/private/ScalaProtoWorker.scala b/rules/scala_proto/private/ScalaProtoWorker.scala index 195e0f9a2..96433254c 100644 --- a/rules/scala_proto/private/ScalaProtoWorker.scala +++ b/rules/scala_proto/private/ScalaProtoWorker.scala @@ -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), diff --git a/rules/scala_proto/private/core.bzl b/rules/scala_proto/private/core.bzl index 44d7277e2..290679d66 100644 --- a/rules/scala_proto/private/core.bzl +++ b/rules/scala_proto/private/core.bzl @@ -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)