diff --git a/internal/js_library/js_library.bzl b/internal/js_library/js_library.bzl index 40134ad3f6..7279f3a4c0 100644 --- a/internal/js_library/js_library.bzl +++ b/internal/js_library/js_library.bzl @@ -110,14 +110,16 @@ def _link_path(ctx, all_files): link_path += "/" + ctx.attr.strip_prefix # Check that strip_prefix contains at least one src path - # check_prefix = "/".join([p for p in [ctx.label.package, ctx.attr.strip_prefix] if p]) - # prefix_contains_src = False - # for file in all_files: - # if file.short_path.startswith(check_prefix): - # prefix_contains_src = True - # break - # if not prefix_contains_src: - # fail("js_library %s strip_prefix path does not contain any of the provided sources" % ctx.label) + check_prefix = "/".join([p for p in [ctx.label.workspace_name, ctx.label.package, ctx.attr.strip_prefix] if p]) + + prefix_contains_src = False + for file in all_files: + filepath = file.short_path[3:] if file.short_path.startswith("../") else file.short_path + if filepath.startswith(check_prefix): + prefix_contains_src = True + break + if not prefix_contains_src: + fail(" js_library %s strip_prefix path does not contain any of the provided sources" % ctx.label) return link_path