Optimized google3 build by not including the empty .upb.c file.

Unfortunately in OSS with Bazel it appears that we must include this empty file, otherwise we get compile errors.  More info in: b/300637173

PiperOrigin-RevId: 565699708
pull/14101/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent e690f27dda
commit 0a4c8cbd8d
  1. 7
      upb/bazel/upb_proto_library_internal/aspect.bzl
  2. 5
      upb/upbc/bootstrap_compiler.bzl
  3. 7
      upb/upbc/protoc-gen-upb.cc

@ -90,7 +90,12 @@ def _generate_upb_protos(ctx, generator, proto_info, proto_sources):
ext = "." + generator
tool = getattr(ctx.executable, "_gen_" + generator)
srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources]
srcs = []
if not (generator == "upb" and _is_google3):
# TODO(b/300637173): The OSS build should also exclude this file for the upb generator,
# as it is empty and unnecessary. We only added it to make the OSS build happy on
# Windows and macOS.
srcs += [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources]
hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources]
thunks = []
if generator == "upb":

@ -50,9 +50,8 @@ def _generated_srcs_for_suffix(prefix, srcs, suffix):
def _generated_srcs_for_generator(prefix, srcs, generator):
ret = _generated_srcs_for_suffix(prefix, srcs, ".{}.h".format(generator))
# if not (generator == "upb" and prefix.endswith("stage1")):
# ret += _generated_srcs_for_suffix(prefix, srcs, ".{}.c".format(generator))
ret += _generated_srcs_for_suffix(prefix, srcs, ".{}.c".format(generator))
if not (generator == "upb" and prefix.endswith("stage1")):
ret += _generated_srcs_for_suffix(prefix, srcs, ".{}.c".format(generator))
return ret
def _generated_srcs(prefix, srcs):

@ -1090,9 +1090,12 @@ void GenerateFile(const DefPoolPair& pools, upb::FileDefPtr file,
WriteMiniDescriptorSource(pools, file, options, c_output);
plugin->AddOutputFile(SourceFilename(file), c_output.output());
} else {
// TODO: remove once we can figure out how to make both Blaze and Bazel
// happy with header-only libraries.
// TODO(b/300637173): remove once we can figure out how to make both Blaze
// and Bazel happy with header-only libraries.
// begin:github_only
plugin->AddOutputFile(SourceFilename(file), "\n");
// end:github_only
}
}

Loading…
Cancel
Save