Skip to content

Commit 60bde98

Browse files
bazel-ioWyverald
andauthored
[7.3.0] Do not eval WORKSPACE in LocalRepositoryLookupFunction when --noenable_workspace (#22911)
This still leaves the question of "what do we do instead?". See issues #22208 and #21515. Fixes #22754. Closes #22774. PiperOrigin-RevId: 645148811 Change-Id: Ib9d07d2ecbc3a79e3341de6739de1c3349124d6b Commit 1246ff4 Co-authored-by: Xdng Yng <[email protected]>
1 parent 4d0b34f commit 60bde98

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.devtools.build.lib.packages.Rule;
2929
import com.google.devtools.build.lib.packages.Type;
3030
import com.google.devtools.build.lib.packages.WorkspaceFileValue;
31+
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
3132
import com.google.devtools.build.lib.repository.ExternalPackageHelper;
3233
import com.google.devtools.build.lib.rules.repository.LocalRepositoryRule;
3334
import com.google.devtools.build.lib.rules.repository.WorkspaceFileHelper;
@@ -42,6 +43,7 @@
4243
import com.google.devtools.build.skyframe.SkyValue;
4344
import java.io.IOException;
4445
import javax.annotation.Nullable;
46+
import net.starlark.java.eval.StarlarkSemantics;
4547

4648
/** SkyFunction for {@link LocalRepositoryLookupValue}s. */
4749
public class LocalRepositoryLookupFunction implements SkyFunction {
@@ -58,6 +60,14 @@ public LocalRepositoryLookupFunction(ExternalPackageHelper externalPackageHelper
5860
@Override
5961
public SkyValue compute(SkyKey skyKey, Environment env)
6062
throws SkyFunctionException, InterruptedException {
63+
StarlarkSemantics semantics = PrecomputedValue.STARLARK_SEMANTICS.get(env);
64+
if (semantics == null) {
65+
return null;
66+
}
67+
if (!semantics.getBool(BuildLanguageOptions.ENABLE_WORKSPACE)) {
68+
// TODO: #22208, #21515 - Figure out what to do here.
69+
return LocalRepositoryLookupValue.mainRepository();
70+
}
6171
RootedPath directory = (RootedPath) skyKey.argument();
6272

6373
// Is this the root directory? If so, we're in the MAIN repository. This assumes that the main

src/test/py/bazel/bzlmod/bazel_module_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,12 @@ def testPendingDownloadDetected(self):
10631063
stderr,
10641064
)
10651065

1066+
def testRegression22754(self):
1067+
"""Regression test for issue #22754."""
1068+
self.ScratchFile('BUILD.bazel', ['print(glob(["testdata/**"]))'])
1069+
self.ScratchFile('testdata/WORKSPACE')
1070+
self.RunBazel(['build', ':all'])
1071+
10661072

10671073
if __name__ == '__main__':
10681074
absltest.main()

0 commit comments

Comments
 (0)