diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java index d6621ccab8948e..3bd09647a4fbc4 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java @@ -46,6 +46,7 @@ import com.google.devtools.build.lib.bazel.bzlmod.RegistryFactory; import com.google.devtools.build.lib.bazel.bzlmod.RegistryFactoryImpl; import com.google.devtools.build.lib.bazel.bzlmod.RepoSpec; +import com.google.devtools.build.lib.bazel.bzlmod.RepoSpecFunction; import com.google.devtools.build.lib.bazel.bzlmod.SingleExtensionEvalFunction; import com.google.devtools.build.lib.bazel.bzlmod.SingleExtensionUsagesFunction; import com.google.devtools.build.lib.bazel.bzlmod.YankedVersionsUtil; @@ -272,7 +273,8 @@ SkyFunctions.BAZEL_LOCK_FILE, new BazelLockFileFunction(directories.getWorkspace .addSkyFunction(SkyFunctions.BAZEL_MODULE_INSPECTION, new BazelModuleInspectorFunction()) .addSkyFunction(SkyFunctions.BAZEL_MODULE_RESOLUTION, new BazelModuleResolutionFunction()) .addSkyFunction(SkyFunctions.SINGLE_EXTENSION_EVAL, singleExtensionEvalFunction) - .addSkyFunction(SkyFunctions.SINGLE_EXTENSION_USAGES, new SingleExtensionUsagesFunction()); + .addSkyFunction(SkyFunctions.SINGLE_EXTENSION_USAGES, new SingleExtensionUsagesFunction()) + .addSkyFunction(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)); filesystem = runtime.getFileSystem(); credentialModule = Preconditions.checkNotNull(runtime.getBlazeModule(CredentialModule.class)); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD index b747623a3de343..0830f09d87d558 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BUILD @@ -24,6 +24,7 @@ java_library( ], deps = [ "//src/main/java/com/google/devtools/build/lib/cmdline", + "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//src/main/java/net/starlark/java/eval", "//third_party:auto_value", "//third_party:gson", @@ -131,6 +132,7 @@ java_library( "MultipleVersionOverride.java", "NonRegistryOverride.java", "RegistryOverride.java", + "RepoSpecKey.java", "SingleExtensionEvalValue.java", "SingleExtensionUsagesValue.java", "SingleVersionOverride.java", @@ -174,6 +176,7 @@ java_library( "ModuleExtensionContext.java", "ModuleFileFunction.java", "ModuleFileGlobals.java", + "RepoSpecFunction.java", "Selection.java", "SingleExtensionEvalFunction.java", "SingleExtensionUsagesFunction.java", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunction.java index 5f329ae1d45cde..dc9f79692bdf44 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunction.java @@ -15,10 +15,13 @@ package com.google.devtools.build.lib.bazel.bzlmod; +import static com.google.common.collect.ImmutableSet.toImmutableSet; + import com.google.common.base.Strings; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.devtools.build.lib.analysis.BlazeVersionInfo; import com.google.devtools.build.lib.bazel.BazelVersion; @@ -29,6 +32,7 @@ import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.events.ExtendedEventHandler; +import com.google.devtools.build.lib.events.StoredEventHandler; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.ProfilerTask; import com.google.devtools.build.lib.profiler.SilentCloseable; @@ -39,7 +43,7 @@ import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; -import java.io.IOException; +import com.google.devtools.build.skyframe.SkyframeLookupResult; import java.util.Map; import java.util.Objects; import javax.annotation.Nullable; @@ -64,12 +68,61 @@ public SkyValue compute(SkyKey skyKey, Environment env) if (root == null) { return null; } + + var state = env.getState(ModuleResolutionComputeState::new); + try { + if (state.selectionResult == null) { + state.storedEventHandler = new StoredEventHandler(); + state.selectionResult = discoverAndSelect(env, root, state.storedEventHandler); + if (state.selectionResult == null) { + return null; + } + } + } finally { + state.storedEventHandler.replayOn(env.getListener()); + } + + ImmutableSet repoSpecKeys = + state.selectionResult.getResolvedDepGraph().values().stream() + // Modules with a null registry have a non-registry override. We don't need to + // fetch or store the repo spec in this case. + .filter(module -> module.getRegistry() != null) + .map(RepoSpecKey::of) + .collect(toImmutableSet()); + SkyframeLookupResult repoSpecResults = env.getValuesAndExceptions(repoSpecKeys); + ImmutableMap.Builder remoteRepoSpecs = ImmutableMap.builder(); + for (RepoSpecKey repoSpecKey : repoSpecKeys) { + RepoSpec repoSpec = (RepoSpec) repoSpecResults.get(repoSpecKey); + if (repoSpec == null) { + return null; + } + remoteRepoSpecs.put(repoSpecKey.getModuleKey(), repoSpec); + } + + ImmutableMap finalDepGraph; + try (SilentCloseable c = + Profiler.instance().profile(ProfilerTask.BZLMOD, "compute final dep graph")) { + finalDepGraph = + computeFinalDepGraph( + state.selectionResult.getResolvedDepGraph(), + root.getOverrides(), + remoteRepoSpecs.buildOrThrow()); + } + + return BazelModuleResolutionValue.create( + finalDepGraph, state.selectionResult.getUnprunedDepGraph()); + } + + @Nullable + private static Selection.Result discoverAndSelect( + Environment env, RootModuleFileValue root, ExtendedEventHandler eventHandler) + throws BazelModuleResolutionFunctionException, InterruptedException { ImmutableMap initialDepGraph; try (SilentCloseable c = Profiler.instance().profile(ProfilerTask.BZLMOD, "discovery")) { initialDepGraph = Discovery.run(env, root); - if (initialDepGraph == null) { - return null; - } + } + if (initialDepGraph == null) { + return null; } Selection.Result selectionResult; @@ -86,7 +139,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) initialDepGraph.get(ModuleKey.ROOT), resolvedDepGraph.get(ModuleKey.ROOT), Objects.requireNonNull(CHECK_DIRECT_DEPENDENCIES.get(env)), - env.getListener()); + eventHandler); } try (SilentCloseable c = @@ -94,7 +147,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) checkBazelCompatibility( resolvedDepGraph.values(), Objects.requireNonNull(BAZEL_COMPATIBILITY_MODE.get(env)), - env.getListener()); + eventHandler); } try (SilentCloseable c = @@ -102,16 +155,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) checkNoYankedVersions(resolvedDepGraph); } - ImmutableMap finalDepGraph; - try (SilentCloseable c = - Profiler.instance().profile(ProfilerTask.BZLMOD, "compute final dep graph")) { - finalDepGraph = - computeFinalDepGraph(resolvedDepGraph, root.getOverrides(), env.getListener()); - } - - Profiler.instance().profile(ProfilerTask.BZLMOD, "module resolution completed").close(); - - return BazelModuleResolutionValue.create(finalDepGraph, selectionResult.getUnprunedDepGraph()); + return selectionResult; } private static void verifyRootModuleDirectDepsAreAccurate( @@ -210,7 +254,8 @@ private static void checkNoYankedVersions(ImmutableMap } } - private static RepoSpec maybeAppendAdditionalPatches(RepoSpec repoSpec, ModuleOverride override) { + private static RepoSpec maybeAppendAdditionalPatches( + @Nullable RepoSpec repoSpec, @Nullable ModuleOverride override) { if (!(override instanceof SingleVersionOverride)) { return repoSpec; } @@ -230,44 +275,15 @@ private static RepoSpec maybeAppendAdditionalPatches(RepoSpec repoSpec, ModuleOv .build(); } - @Nullable - private static RepoSpec computeRepoSpec( - InterimModule interimModule, ModuleOverride override, ExtendedEventHandler eventHandler) - throws BazelModuleResolutionFunctionException, InterruptedException { - if (interimModule.getRegistry() == null) { - // This module has a non-registry override. We don't need to store the repo spec in this case. - return null; - } - try { - RepoSpec moduleRepoSpec = - interimModule - .getRegistry() - .getRepoSpec( - interimModule.getKey(), interimModule.getCanonicalRepoName(), eventHandler); - return maybeAppendAdditionalPatches(moduleRepoSpec, override); - } catch (IOException e) { - throw new BazelModuleResolutionFunctionException( - ExternalDepsException.withMessage( - Code.ERROR_ACCESSING_REGISTRY, - "Unable to get module repo spec from registry: %s", - e.getMessage()), - Transience.PERSISTENT); - } - } - /** * Builds a {@link Module} from an {@link InterimModule}, discarding unnecessary fields and adding * extra necessary ones (such as the repo spec). + * + * @param remoteRepoSpec the {@link RepoSpec} for the module obtained from a registry or null if + * the module has a non-registry override */ static Module moduleFromInterimModule( - InterimModule interim, ModuleOverride override, ExtendedEventHandler eventHandler) - throws BazelModuleResolutionFunctionException, InterruptedException { - RepoSpec repoSpec; - try (SilentCloseable c = - Profiler.instance() - .profile(ProfilerTask.BZLMOD, () -> "compute repo spec: " + interim.getKey())) { - repoSpec = computeRepoSpec(interim, override, eventHandler); - } + InterimModule interim, @Nullable ModuleOverride override, @Nullable RepoSpec remoteRepoSpec) { return Module.builder() .setName(interim.getName()) .setVersion(interim.getVersion()) @@ -276,7 +292,7 @@ static Module moduleFromInterimModule( .setExecutionPlatformsToRegister(interim.getExecutionPlatformsToRegister()) .setToolchainsToRegister(interim.getToolchainsToRegister()) .setDeps(ImmutableMap.copyOf(Maps.transformValues(interim.getDeps(), DepSpec::toModuleKey))) - .setRepoSpec(repoSpec) + .setRepoSpec(maybeAppendAdditionalPatches(remoteRepoSpec, override)) .setExtensionUsages(interim.getExtensionUsages()) .build(); } @@ -284,18 +300,24 @@ static Module moduleFromInterimModule( private static ImmutableMap computeFinalDepGraph( ImmutableMap resolvedDepGraph, ImmutableMap overrides, - ExtendedEventHandler eventHandler) - throws BazelModuleResolutionFunctionException, InterruptedException { + ImmutableMap remoteRepoSpecs) { ImmutableMap.Builder finalDepGraph = ImmutableMap.builder(); for (Map.Entry entry : resolvedDepGraph.entrySet()) { finalDepGraph.put( entry.getKey(), moduleFromInterimModule( - entry.getValue(), overrides.get(entry.getKey().getName()), eventHandler)); + entry.getValue(), + overrides.get(entry.getKey().getName()), + remoteRepoSpecs.get(entry.getKey()))); } return finalDepGraph.buildOrThrow(); } + private static class ModuleResolutionComputeState implements Environment.SkyKeyComputeState { + Selection.Result selectionResult; + StoredEventHandler storedEventHandler; + } + static class BazelModuleResolutionFunctionException extends SkyFunctionException { BazelModuleResolutionFunctionException(ExternalDepsException e, Transience transience) { super(e, transience); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpec.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpec.java index f5f2e6f851c8b7..41fcf284f52423 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpec.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpec.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.bazel.bzlmod; import com.google.auto.value.AutoValue; +import com.google.devtools.build.skyframe.SkyValue; import com.ryanharter.auto.value.gson.GenerateTypeAdapter; import javax.annotation.Nullable; @@ -24,7 +25,7 @@ */ @AutoValue @GenerateTypeAdapter -public abstract class RepoSpec { +public abstract class RepoSpec implements SkyValue { /** * The label string for the bzl file this repository rule is defined in, empty for native rule. diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpecFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpecFunction.java new file mode 100644 index 00000000000000..0ac65cfb432008 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpecFunction.java @@ -0,0 +1,73 @@ +// Copyright 2021 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package com.google.devtools.build.lib.bazel.bzlmod; + +import com.google.devtools.build.lib.profiler.Profiler; +import com.google.devtools.build.lib.profiler.ProfilerTask; +import com.google.devtools.build.lib.profiler.SilentCloseable; +import com.google.devtools.build.lib.server.FailureDetails; +import com.google.devtools.build.skyframe.SkyFunction; +import com.google.devtools.build.skyframe.SkyFunctionException; +import com.google.devtools.build.skyframe.SkyKey; +import com.google.devtools.build.skyframe.SkyValue; +import java.io.IOException; +import java.net.URISyntaxException; +import javax.annotation.Nullable; + +/** + * A simple SkyFunction that computes a {@link RepoSpec} for the given {@link InterimModule} by + * fetching required information from its {@link Registry}. + */ +public class RepoSpecFunction implements SkyFunction { + private final RegistryFactory registryFactory; + + public RepoSpecFunction(RegistryFactory registryFactory) { + this.registryFactory = registryFactory; + } + + @Override + @Nullable + public SkyValue compute(SkyKey skyKey, Environment env) + throws InterruptedException, RepoSpecException { + RepoSpecKey key = (RepoSpecKey) skyKey.argument(); + try (SilentCloseable c = + Profiler.instance() + .profile(ProfilerTask.BZLMOD, () -> "compute repo spec: " + key.getModuleKey())) { + return registryFactory + .getRegistryWithUrl(key.getRegistryUrl()) + .getRepoSpec( + key.getModuleKey(), key.getModuleKey().getCanonicalRepoName(), env.getListener()); + } catch (IOException e) { + throw new RepoSpecException( + ExternalDepsException.withCauseAndMessage( + FailureDetails.ExternalDeps.Code.ERROR_ACCESSING_REGISTRY, + e, + "Unable to get module repo spec for %s from registry", + key.getModuleKey())); + } catch (URISyntaxException e) { + // This should never happen since we obtain the registry URL from an already constructed + // registry. + throw new IllegalStateException(e); + } + } + + static final class RepoSpecException extends SkyFunctionException { + + RepoSpecException(ExternalDepsException cause) { + super(cause, Transience.TRANSIENT); + } + } +} diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpecKey.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpecKey.java new file mode 100644 index 00000000000000..fb39e3b3df9b30 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/RepoSpecKey.java @@ -0,0 +1,52 @@ +// Copyright 2021 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package com.google.devtools.build.lib.bazel.bzlmod; + +import com.google.auto.value.AutoValue; +import com.google.common.base.Preconditions; +import com.google.common.collect.Interner; +import com.google.devtools.build.lib.concurrent.BlazeInterners; +import com.google.devtools.build.lib.skyframe.SkyFunctions; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; +import com.google.devtools.build.skyframe.SkyFunctionName; +import com.google.devtools.build.skyframe.SkyKey; + +/** The key for {@link RepoSpecFunction}. */ +@AutoCodec +@AutoValue +abstract class RepoSpecKey implements SkyKey { + private static final Interner interner = BlazeInterners.newWeakInterner(); + + static RepoSpecKey of(InterimModule module) { + Preconditions.checkNotNull( + module.getRegistry(), "module must not have a non-registry override"); + return create(module.getKey(), module.getRegistry().getUrl()); + } + + abstract ModuleKey getModuleKey(); + + abstract String getRegistryUrl(); + + @AutoCodec.Instantiator + static RepoSpecKey create(ModuleKey moduleKey, String registryUrl) { + return interner.intern(new AutoValue_RepoSpecKey(moduleKey, registryUrl)); + } + + @Override + public SkyFunctionName functionName() { + return SkyFunctions.REPO_SPEC; + } +} diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java index 9eb8b4f11577e3..29f68bfa2c510d 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyFunctions.java @@ -155,6 +155,7 @@ public final class SkyFunctions { SkyFunctionName.createHermetic("BAZEL_DEP_GRAPH"); public static final SkyFunctionName BAZEL_LOCK_FILE = SkyFunctionName.createHermetic("BAZEL_LOCK_FILE"); + public static final SkyFunctionName REPO_SPEC = SkyFunctionName.createNonHermetic("REPO_SPEC"); public static Predicate isSkyFunction(SkyFunctionName functionName) { return key -> key.functionName().equals(functionName); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java index 047c2aa1741b70..28e2f54c77743f 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.bazel.bzlmod.FakeRegistry; import com.google.devtools.build.lib.bazel.bzlmod.ModuleFileFunction; import com.google.devtools.build.lib.bazel.bzlmod.NonRegistryOverride; +import com.google.devtools.build.lib.bazel.bzlmod.RepoSpecFunction; import com.google.devtools.build.lib.bazel.rules.android.AndroidNdkRepositoryFunction; import com.google.devtools.build.lib.bazel.rules.android.AndroidNdkRepositoryRule; import com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryFunction; @@ -148,6 +149,8 @@ public ImmutableMap getSkyFunctions(BlazeDirectori new BazelLockFileFunction(directories.getWorkspace()), SkyFunctions.BAZEL_MODULE_RESOLUTION, new BazelModuleResolutionFunction(), + SkyFunctions.REPO_SPEC, + new RepoSpecFunction(FakeRegistry.DEFAULT_FACTORY), SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of())), CcSkyframeFdoSupportValue.SKYFUNCTION, diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunctionTest.java index b8602dba90d16e..8228dcac739c0b 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelDepGraphFunctionTest.java @@ -129,6 +129,7 @@ public void setup() throws Exception { .put(SkyFunctions.BAZEL_LOCK_FILE, new BazelLockFileFunction(rootDirectory)) .put(SkyFunctions.BAZEL_DEP_GRAPH, new BazelDepGraphFunction()) .put(SkyFunctions.BAZEL_MODULE_RESOLUTION, resolutionFunctionMock) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction( diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunctionTest.java index 8956b9795dd4a5..2b7a308b4a5a20 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileFunctionTest.java @@ -156,6 +156,7 @@ public void setup() throws Exception { SkyFunctions.MODULE_FILE, new ModuleFileFunction(registryFactory, rootDirectory, ImmutableMap.of())) .put(SkyFunctions.BAZEL_LOCK_FILE, new BazelLockFileFunction(rootDirectory)) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction( diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunctionTest.java index 088943ef9a47e9..11041182aa9c00 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionFunctionTest.java @@ -115,6 +115,7 @@ public void setup() throws Exception { .put(SkyFunctions.BAZEL_DEP_GRAPH, new BazelDepGraphFunction()) .put(SkyFunctions.BAZEL_LOCK_FILE, new BazelLockFileFunction(rootDirectory)) .put(SkyFunctions.BAZEL_MODULE_RESOLUTION, new BazelModuleResolutionFunction()) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of()))) diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BzlmodRepoRuleFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BzlmodRepoRuleFunctionTest.java index 46b9ae30be2aa2..adba54c010611c 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BzlmodRepoRuleFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/BzlmodRepoRuleFunctionTest.java @@ -130,6 +130,7 @@ public void setup() throws Exception { .put( SkyFunctions.MODULE_FILE, new ModuleFileFunction(registryFactory, workspaceRoot, ImmutableMap.of())) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of()))) diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/DiscoveryTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/DiscoveryTest.java index 37ed209fa7e41b..d8d885cd5c465b 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/DiscoveryTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/DiscoveryTest.java @@ -179,6 +179,7 @@ private void setUpWithBuiltinModules(ImmutableMap b .put( BzlmodRepoRuleValue.BZLMOD_REPO_RULE, new BzlmodRepoRuleFunction(ruleClassProvider, directories)) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of()))) diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java index 9d9faa84b4e904..009f78efa1c555 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionTest.java @@ -255,6 +255,7 @@ public void setup() throws Exception { .put(SkyFunctions.BAZEL_MODULE_RESOLUTION, new BazelModuleResolutionFunction()) .put(SkyFunctions.SINGLE_EXTENSION_USAGES, new SingleExtensionUsagesFunction()) .put(SkyFunctions.SINGLE_EXTENSION_EVAL, singleExtensionEvalFunction) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of()))) diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunctionTest.java index 761f9142ed9022..b86b0b43a55822 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileFunctionTest.java @@ -153,6 +153,7 @@ private void setUpWithBuiltinModules(ImmutableMap b .put( BzlmodRepoRuleValue.BZLMOD_REPO_RULE, new BzlmodRepoRuleFunction(ruleClassProvider, directories)) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of()))) diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java index d75121b3964689..873d79b915a4a0 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java @@ -36,6 +36,7 @@ import com.google.devtools.build.lib.bazel.bzlmod.BzlmodRepoRuleValue; import com.google.devtools.build.lib.bazel.bzlmod.FakeRegistry; import com.google.devtools.build.lib.bazel.bzlmod.ModuleFileFunction; +import com.google.devtools.build.lib.bazel.bzlmod.RepoSpecFunction; import com.google.devtools.build.lib.bazel.bzlmod.YankedVersionsUtil; import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.BazelCompatibilityMode; import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.CheckDirectDepsMode; @@ -245,6 +246,7 @@ public void setupDelegator() throws Exception { .put( BzlmodRepoRuleValue.BZLMOD_REPO_RULE, new BzlmodRepoRuleFunction(ruleClassProvider, directories)) + .put(SkyFunctions.REPO_SPEC, new RepoSpecFunction(registryFactory)) .put( SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(new AtomicReference<>(ImmutableMap.of())))