Selectively add source or gen dir to includes. (#9438)

When both directories are added this results in protoc emitting a
"warning: directory does not exist.". This makes sense because when
there are no inputs from the other directory, it is also not present
n the sandbox where protoc is executed.
pull/9459/head
Ivo List 3 years ago committed by GitHub
parent fa57149caa
commit 15add1af49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      protobuf.bzl

@ -80,7 +80,14 @@ def _proto_gen_impl(ctx):
source_dir = _SourceDir(ctx) source_dir = _SourceDir(ctx)
gen_dir = _GenDir(ctx).rstrip("/") gen_dir = _GenDir(ctx).rstrip("/")
if source_dir: if source_dir:
import_flags = depset(direct=["-I" + source_dir, "-I" + gen_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: else:
import_flags = depset(direct=["-I."]) import_flags = depset(direct=["-I."])

Loading…
Cancel
Save