diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BzlmodRepoRuleFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/BzlmodRepoRuleFunction.java index d097df2ac3b43b..8b36f67ccbfdf2 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BzlmodRepoRuleFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BzlmodRepoRuleFunction.java @@ -240,8 +240,7 @@ private ImmutableMap loadBzlModules( // Load the .bzl module. try { - // TODO(b/22193153, wyv): Determine whether .bzl load visibility should apply at all to this - // type of .bzl load. As it stands, this call checks that bzlFile is visible to package @//. + // No need to check visibility for an extension repospec that is always public return PackageFunction.loadBzlModules( env, PackageIdentifier.EMPTY_PACKAGE_ID, @@ -249,7 +248,8 @@ private ImmutableMap loadBzlModules( programLoads, keys, starlarkSemantics, - null); + null, + /* checkVisibility= */ false); } catch (NoSuchPackageException e) { throw new BzlmodRepoRuleFunctionException(e, Transience.PERSISTENT); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java index 26a223f1da2417..ae8ba7b1c789bb 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java @@ -634,6 +634,7 @@ private static FileValue getBuildFileValue(Environment env, RootedPath buildFile * construction to the caller, so that loadPrelude can become just a call to the factored-out * code. */ + // TODO(18422): Cleanup/refactor this method's signature. @Nullable static ImmutableMap loadBzlModules( Environment env, @@ -642,7 +643,8 @@ static ImmutableMap loadBzlModules( List> programLoads, List keys, StarlarkSemantics semantics, - @Nullable BzlLoadFunction bzlLoadFunctionForInlining) + @Nullable BzlLoadFunction bzlLoadFunctionForInlining, + boolean checkVisibility) throws NoSuchPackageException, InterruptedException { List bzlLoads; try { @@ -655,14 +657,17 @@ static ImmutableMap loadBzlModules( } // Validate that the current BUILD/WORKSPACE file satisfies each loaded dependency's // load visibility. - BzlLoadFunction.checkLoadVisibilities( - packageId, - requestingFileDescription, - bzlLoads, - keys, - programLoads, - /*demoteErrorsToWarnings=*/ !semantics.getBool(BuildLanguageOptions.CHECK_BZL_VISIBILITY), - env.getListener()); + if (checkVisibility) { + BzlLoadFunction.checkLoadVisibilities( + packageId, + requestingFileDescription, + bzlLoads, + keys, + programLoads, + /* demoteErrorsToWarnings= */ !semantics.getBool( + BuildLanguageOptions.CHECK_BZL_VISIBILITY), + env.getListener()); + } } catch (BzlLoadFailedException e) { Throwable rootCause = Throwables.getRootCause(e); throw PackageFunctionException.builder() @@ -1335,7 +1340,8 @@ private LoadedPackage loadPackage( programLoads, keys.build(), starlarkBuiltinsValue.starlarkSemantics, - bzlLoadFunctionForInlining); + bzlLoadFunctionForInlining, + /* checkVisibility= */ true); } catch (NoSuchPackageException e) { throw new PackageFunctionException(e, Transience.PERSISTENT); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java index 7eabc01cd2e7e4..26ddf3d61d4c91 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java @@ -334,7 +334,8 @@ public SkyValue compute(SkyKey skyKey, Environment env) programLoads, keys.build(), starlarkSemantics, - bzlLoadFunctionForInlining); + bzlLoadFunctionForInlining, + /* checkVisibility= */ true); } catch (NoSuchPackageException e) { throw new WorkspaceFileFunctionException(e, Transience.PERSISTENT); }