Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.2.1] Do not eval WORKSPACE in LocalRepositoryLookupFunction when --noenable_workspace #22837

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.packages.WorkspaceFileValue;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import com.google.devtools.build.lib.repository.ExternalPackageHelper;
import com.google.devtools.build.lib.rules.repository.LocalRepositoryRule;
import com.google.devtools.build.lib.rules.repository.WorkspaceFileHelper;
Expand All @@ -42,6 +43,7 @@
import com.google.devtools.build.skyframe.SkyValue;
import java.io.IOException;
import javax.annotation.Nullable;
import net.starlark.java.eval.StarlarkSemantics;

/** SkyFunction for {@link LocalRepositoryLookupValue}s. */
public class LocalRepositoryLookupFunction implements SkyFunction {
Expand All @@ -58,6 +60,14 @@ public LocalRepositoryLookupFunction(ExternalPackageHelper externalPackageHelper
@Override
public SkyValue compute(SkyKey skyKey, Environment env)
throws SkyFunctionException, InterruptedException {
StarlarkSemantics semantics = PrecomputedValue.STARLARK_SEMANTICS.get(env);
if (semantics == null) {
return null;
}
if (!semantics.getBool(BuildLanguageOptions.ENABLE_WORKSPACE)) {
// TODO: #22208, #21515 - Figure out what to do here.
return LocalRepositoryLookupValue.mainRepository();
}
RootedPath directory = (RootedPath) skyKey.argument();

// Is this the root directory? If so, we're in the MAIN repository. This assumes that the main
Expand Down
6 changes: 6 additions & 0 deletions src/test/py/bazel/bzlmod/bazel_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,12 @@ def testPendingDownloadDetected(self):
stderr,
)

def testRegression22754(self):
"""Regression test for issue #22754."""
self.ScratchFile('BUILD.bazel', ['print(glob(["testdata/**"]))'])
self.ScratchFile('testdata/WORKSPACE')
self.RunBazel(['build', ':all'])


if __name__ == '__main__':
absltest.main()
Loading