Fix upb proto libraryies for default strip_import_prefix.

pull/13171/head
Ivo List 2 years ago
parent f44653bc52
commit 9e19bec587
  1. 2
      bazel/py_proto_library.bzl
  2. 2
      bazel/upb_proto_library.bzl
  3. 4
      upb/bindings/lua/lua_proto_library.bzl

@ -78,7 +78,7 @@ def _generate_output_file(ctx, src, extension):
package = ctx.label.package package = ctx.label.package
if not _is_google3: if not _is_google3:
strip_import_prefix = ctx.rule.attr.strip_import_prefix strip_import_prefix = ctx.rule.attr.strip_import_prefix
if strip_import_prefix: if strip_import_prefix and strip_import_prefix != "/":
if not package.startswith(strip_import_prefix[1:]): if not package.startswith(strip_import_prefix[1:]):
fail("%s does not begin with prefix %s" % (package, strip_import_prefix)) fail("%s does not begin with prefix %s" % (package, strip_import_prefix))
package = package[len(strip_import_prefix):] package = package[len(strip_import_prefix):]

@ -81,7 +81,7 @@ def _generate_output_file(ctx, src, extension):
package = ctx.label.package package = ctx.label.package
if not _is_google3: if not _is_google3:
strip_import_prefix = ctx.rule.attr.strip_import_prefix strip_import_prefix = ctx.rule.attr.strip_import_prefix
if strip_import_prefix: if strip_import_prefix and strip_import_prefix != "/":
if not package.startswith(strip_import_prefix[1:]): if not package.startswith(strip_import_prefix[1:]):
fail("%s does not begin with prefix %s" % (package, strip_import_prefix)) fail("%s does not begin with prefix %s" % (package, strip_import_prefix))
package = package[len(strip_import_prefix):] package = package[len(strip_import_prefix):]

@ -57,13 +57,13 @@ def _get_real_short_path(file):
def _get_real_root(ctx, file): def _get_real_root(ctx, file):
real_short_path = _get_real_short_path(file) real_short_path = _get_real_short_path(file)
root = file.path[:-len(real_short_path) - 1] root = file.path[:-len(real_short_path) - 1]
if not _is_google3 and ctx.rule.attr.strip_import_prefix and ctx.rule.attr.strip_import_prefix != "DO_NOT_STRIP": if not _is_google3 and ctx.rule.attr.strip_import_prefix:
root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:]) root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:])
return root return root
def _generate_output_file(ctx, src, extension): def _generate_output_file(ctx, src, extension):
package = ctx.label.package package = ctx.label.package
if not _is_google3 and ctx.rule.attr.strip_import_prefix and ctx.rule.attr.strip_import_prefix != "DO_NOT_STRIP": if not _is_google3 and ctx.rule.attr.strip_import_prefix and ctx.rule.attr.strip_import_prefix != "/":
package = package[len(ctx.rule.attr.strip_import_prefix):] package = package[len(ctx.rule.attr.strip_import_prefix):]
real_short_path = _get_real_short_path(src) real_short_path = _get_real_short_path(src)
real_short_path = paths.relativize(real_short_path, package) real_short_path = paths.relativize(real_short_path, package)

Loading…
Cancel
Save