include gen_dir irrespsective of sources_dir in protoc_gen (#9735)

pull/9752/head
Derek Perez 3 years ago committed by GitHub
parent 5f920d1507
commit b55c8e4084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      protobuf.bzl

@ -79,17 +79,20 @@ def _proto_gen_impl(ctx):
deps = depset(direct=ctx.files.srcs)
source_dir = _SourceDir(ctx)
gen_dir = _GenDir(ctx).rstrip("/")
import_flags = []
if source_dir:
has_sources = any([src.is_source for src in srcs])
has_generated = any([not src.is_source for src in srcs])
import_flags = []
if has_sources:
import_flags += ["-I" + source_dir]
if has_generated:
import_flags += ["-I" + gen_dir]
import_flags = depset(direct=import_flags)
else:
import_flags = depset(direct=["-I."])
import_flags += ["-I."]
has_generated = any([not src.is_source for src in srcs])
if has_generated:
import_flags += ["-I" + gen_dir]
import_flags = depset(direct=import_flags)
for dep in ctx.attr.deps:
if type(dep.proto.import_flags) == "list":
@ -163,7 +166,7 @@ def _proto_gen_impl(ctx):
for out in outs:
orig_command = " ".join(
["$(realpath %s)" % ctx.executable.protoc.path] + args +
import_flags_real + ["-I.", src.basename],
import_flags_real + [src.basename],
)
command = ";".join([
'CMD="%s"' % orig_command,

Loading…
Cancel
Save