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

Flip --enable_bzlmod #19699

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e93e6cf
Flip --enable_bzlmod
meteorcloudy Sep 22, 2023
0bd2f15
Disable Bzlmod in all failing tests
meteorcloudy Oct 2, 2023
fbccb02
Only run on Linux
meteorcloudy Oct 4, 2023
38f08f4
Setup AnalysisMock for Bzlmod
meteorcloudy Oct 4, 2023
6859bed
Disable bzlmod for //src/test/java/com/google/devtools/build/lib/baze…
meteorcloudy Oct 5, 2023
a940da3
Fix //src/test/java/com/google/devtools/build/lib/bazel/repository/st…
meteorcloudy Oct 5, 2023
958d788
Fix //src/test/java/com/google/devtools/build/lib/analysis:StarlarkSu…
meteorcloudy Oct 5, 2023
fafcb90
Fixes //src/test/java/com/google/devtools/build/lib/exec:ExecTests
meteorcloudy Oct 5, 2023
a340c02
Fixes //src/test/java/com/google/devtools/build/lib/rules:rules_tests
meteorcloudy Oct 5, 2023
f98251a
Disable Bzlmod to fix //src/test/java/com/google/devtools/build/lib/r…
meteorcloudy Oct 5, 2023
0e8a2e5
Fixes //src/test/java/com/google/devtools/build/lib/rules/cpp:CcBadDe…
meteorcloudy Oct 5, 2023
52c4a99
Fixes //src/test/java/com/google/devtools/build/lib/rules/cpp:CcCommo…
meteorcloudy Oct 5, 2023
96866ff
Fixes //src/test/java/com/google/devtools/build/lib/rules/cpp:CcLibra…
meteorcloudy Oct 5, 2023
3be19fc
Setup rules_proto mock for Bzlmod to fix //src/test/java/com/google/d…
meteorcloudy Oct 5, 2023
b83508c
Fixes //src/test/java/com/google/devtools/build/lib/rules/proto:Bazel…
meteorcloudy Oct 5, 2023
46dd969
Fixes //src/test/java/com/google/devtools/build/lib/rules/proto:Bazel…
meteorcloudy Oct 5, 2023
68310f6
Fixes //src/test/java/com/google/devtools/build/lib/rules/starlarkdoc…
meteorcloudy Oct 5, 2023
b74c906
Fixes //src/test/java/com/google/devtools/build/lib/skyframe/toolchai…
meteorcloudy Oct 5, 2023
d019073
Disable bzlmod for one test case in //src/test/java/com/google/devtoo…
meteorcloudy Oct 5, 2023
1e6b6b8
Actually disable Bzlmod for Android tests
meteorcloudy Oct 5, 2023
c7032af
Make //src/test/java/com/google/devtools/build/lib/starlark:StarlarkT…
meteorcloudy Oct 5, 2023
ce84e1d
Revert change on DEFAULT_REPOSITORY_DIRECTORY
meteorcloudy Oct 5, 2023
813623b
Fix using RegistryFactoryImpl
meteorcloudy Oct 5, 2023
5ecc9e7
Fix //src/test/java/com/google/devtools/build/lib/starlark:StarlarkTests
meteorcloudy Oct 8, 2023
f7ce7f8
Fixes //src/test/java/com/google/devtools/build/lib/exec:ExecTests
meteorcloudy Oct 8, 2023
0b7b17a
Fixes //src/test/java/com/google/devtools/build/lib/rules:rules_tests
meteorcloudy Oct 8, 2023
e4d3705
Fixes //src/test/java/com/google/devtools/build/lib/query2/cquery:Tra…
meteorcloudy Oct 8, 2023
d0a5ec5
Fixes //src/test/java/com/google/devtools/build/lib/rules/android:And…
meteorcloudy Oct 8, 2023
189e365
Fixes //src/test/java/com/google/devtools/build/lib/rules/android:And…
meteorcloudy Oct 8, 2023
d2c1250
Fixes //src/test/java/com/google/devtools/build/lib/query2/engine:All…
meteorcloudy Oct 8, 2023
cf8bac7
Make both //src/test/java/com/google/devtools/build/lib/query2/engine…
meteorcloudy Oct 8, 2023
9c81069
Fixes //src/test/java/com/google/devtools/build/lib/analysis:Analysis…
meteorcloudy Oct 8, 2023
966d26f
Try enable bzlmod for python integration tests
meteorcloudy Oct 9, 2023
bbdcca9
Fixes //src/test/py/bazel:bazel_workspace_test
meteorcloudy Oct 9, 2023
66afb65
Fixes //src/test/py/bazel:runfiles_test
meteorcloudy Oct 9, 2023
dc3d017
Fixes //src/test/py/bazel:launcher_test
meteorcloudy Oct 9, 2023
c102a71
Fixes //src/test/py/bazel:py_test
meteorcloudy Oct 9, 2023
1619028
Fixes //src/test/py/bazel:runfiles_sandboxed_test
meteorcloudy Oct 9, 2023
1b1377f
Use a default lock file for python integration tests to avoid accessi…
meteorcloudy Oct 9, 2023
ada9874
Revert "Throw an error when the root module specifies overrides on no…
meteorcloudy Oct 9, 2023
dc15f5f
Check-in generated default MODULE.bazel.lock
meteorcloudy Oct 10, 2023
2aa2c19
Set up repo cache for MODULE.tools
meteorcloudy Oct 10, 2023
b79483e
Update Bazel lockfile
meteorcloudy Oct 10, 2023
8bd923b
Fixes tests
meteorcloudy Oct 10, 2023
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
374 changes: 0 additions & 374 deletions .bazelci/presubmit.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ bazel_build_deps = use_extension("//:extensions.bzl", "bazel_build_deps")
use_repo(
bazel_build_deps,
"bootstrap_repo_cache",
"bazel_tools_repo_cache",
"debian_cc_deps",
"openjdk_linux_aarch64_vanilla",
"openjdk_linux_ppc64le_vanilla",
Expand Down
32 changes: 20 additions & 12 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion distdir.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ load("//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar"
_BUILD = """
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

filegroup(
name="files",
srcs = {srcs},
visibility = ["//visibility:public"],
)

pkg_tar(
name="archives",
srcs = {srcs},
srcs = [":files"],
strip_prefix = "{strip_prefix}",
package_dir = "{dirname}",
visibility = ["//visibility:public"],
Expand Down
3 changes: 3 additions & 0 deletions extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
load("//:distdir.bzl", "dist_http_archive", "repo_cache_tar")
load("//:distdir_deps.bzl", "DIST_ARCHIVE_REPOS")
load("//:repositories.bzl", "embedded_jdk_repositories")
load("//src/tools/bzlmod:utils.bzl", "parse_bazel_module_repos")
load("//src/main/res:winsdk_configure.bzl", "winsdk_configure")
load("//src/test/shell/bazel:list_source_repository.bzl", "list_source_repository")
load("//tools/distributions/debian:deps.bzl", "debian_deps")
Expand All @@ -28,6 +29,8 @@ def _bazel_build_deps(_ctx):
embedded_jdk_repositories()
debian_deps()
repo_cache_tar(name = "bootstrap_repo_cache", repos = DIST_ARCHIVE_REPOS, dirname = "derived/repository_cache")
BAZEL_TOOLS_DEPS_REPOS = parse_bazel_module_repos(_ctx, _ctx.path(Label("//src/test/tools/bzlmod:MODULE.bazel.lock")))
repo_cache_tar(name = "bazel_tools_repo_cache", repos = BAZEL_TOOLS_DEPS_REPOS, lockfile = "//src/test/tools/bzlmod:MODULE.bazel.lock")

bazel_build_deps = module_extension(implementation = _bazel_build_deps)

Expand Down
2 changes: 1 addition & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -586,5 +586,5 @@ filegroup(
"@remotejdk%s_%s//:WORKSPACE" % (version, os)
for version in ("17", "20")
for os in ("macos", "macos_aarch64", "linux", "win")
],
] + ["@bazel_tools_repo_cache//:files"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

import static com.google.common.collect.ImmutableSet.toImmutableSet;

import com.google.common.base.Joiner;
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.common.collect.Sets;
import com.google.devtools.build.lib.analysis.BlazeVersionInfo;
import com.google.devtools.build.lib.bazel.BazelVersion;
import com.google.devtools.build.lib.bazel.bzlmod.InterimModule.DepSpec;
Expand All @@ -46,7 +44,6 @@
import com.google.devtools.build.skyframe.SkyframeLookupResult;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -122,8 +119,6 @@ private static Selection.Result discoverAndSelect(Environment env, RootModuleFil
return null;
}

verifyAllOverridesAreOnExistentModules(initialDepGraph, root.getOverrides());

Selection.Result selectionResult;
try (SilentCloseable c = Profiler.instance().profile(ProfilerTask.BZLMOD, "selection")) {
selectionResult = Selection.run(initialDepGraph, root.getOverrides());
Expand Down Expand Up @@ -157,23 +152,6 @@ private static Selection.Result discoverAndSelect(Environment env, RootModuleFil
return selectionResult;
}

private static void verifyAllOverridesAreOnExistentModules(
ImmutableMap<ModuleKey, InterimModule> initialDepGraph,
ImmutableMap<String, ModuleOverride> overrides)
throws BazelModuleResolutionFunctionException {
ImmutableSet<String> existentModules =
initialDepGraph.values().stream().map(InterimModule::getName).collect(toImmutableSet());
Set<String> nonexistentModules = Sets.difference(overrides.keySet(), existentModules);
if (!nonexistentModules.isEmpty()) {
throw new BazelModuleResolutionFunctionException(
ExternalDepsException.withMessage(
Code.BAD_MODULE,
"the root module specifies overrides on nonexistent module(s): %s",
Joiner.on(", ").join(nonexistentModules)),
Transience.PERSISTENT);
}
}

private static void verifyRootModuleDirectDepsAreAccurate(
InterimModule discoveredRootModule,
InterimModule resolvedRootModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public final class BuildLanguageOptions extends OptionsBase {
@Option(
name = "enable_bzlmod",
oldName = "experimental_enable_bzlmod",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = OptionEffectTag.LOADING_AND_ANALYSIS,
help =
Expand Down Expand Up @@ -821,7 +821,7 @@ public StarlarkSemantics toStarlarkSemantics() {
public static final String EXPERIMENTAL_ENABLE_ANDROID_MIGRATION_APIS =
"-experimental_enable_android_migration_apis";
public static final String EXPERIMENTAL_ENABLE_SCL_DIALECT = "-experimental_enable_scl_dialect";
public static final String ENABLE_BZLMOD = "-enable_bzlmod";
public static final String ENABLE_BZLMOD = "+enable_bzlmod";
public static final String EXPERIMENTAL_ISOLATED_EXTENSION_USAGES =
"-experimental_isolated_extension_usages";
public static final String INCOMPATIBLE_EXISTING_RULES_IMMUTABLE_VIEW =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ java_library(
":AbstractPackageLoader",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
"//src/main/java/com/google/devtools/build/lib/bazel:repository_module",
"//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:registry",
"//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:repo_rule_value",
"//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:resolution_impl",
"//src/main/java/com/google/devtools/build/lib/bazel/repository:repository_options",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/cache",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/downloader",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/starlark",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.bazel.BazelRepositoryModule;
import com.google.devtools.build.lib.bazel.bzlmod.*;
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions;
import com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache;
import com.google.devtools.build.lib.bazel.repository.downloader.DownloadManager;
import com.google.devtools.build.lib.bazel.repository.downloader.HttpDownloader;
Expand Down Expand Up @@ -98,7 +100,23 @@ private Builder(Root workspaceDir, Path installBase, Path outputBase, AtomicBool
RepositoryDelegatorFunction.RESOLVED_FILE_INSTEAD_OF_WORKSPACE, Optional.empty()),
PrecomputedValue.injected(
RepositoryDelegatorFunction.DEPENDENCY_FOR_UNCONDITIONAL_FETCHING,
RepositoryDelegatorFunction.DONT_FETCH_UNCONDITIONALLY));
RepositoryDelegatorFunction.DONT_FETCH_UNCONDITIONALLY),
PrecomputedValue.injected(ModuleFileFunction.MODULE_OVERRIDES, ImmutableMap.of()),
PrecomputedValue.injected(
RepositoryDelegatorFunction.DEPENDENCY_FOR_UNCONDITIONAL_CONFIGURING,
RepositoryDelegatorFunction.DONT_FETCH_UNCONDITIONALLY),
PrecomputedValue.injected(ModuleFileFunction.REGISTRIES, ImmutableList.of()),
PrecomputedValue.injected(ModuleFileFunction.IGNORE_DEV_DEPS, false),
PrecomputedValue.injected(
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES,
RepositoryOptions.CheckDirectDepsMode.OFF),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE,
RepositoryOptions.BazelCompatibilityMode.OFF),
PrecomputedValue.injected(
BazelLockFileFunction.LOCKFILE_MODE, RepositoryOptions.LockfileMode.OFF),
PrecomputedValue.injected(
YankedVersionsUtil.ALLOWED_YANKED_VERSIONS, ImmutableList.of()));
}

@Override
Expand All @@ -107,6 +125,17 @@ public BazelPackageLoader buildImpl() {
RepositoryCache repositoryCache = new RepositoryCache();
HttpDownloader httpDownloader = new HttpDownloader();
DownloadManager downloadManager = new DownloadManager(repositoryCache, httpDownloader);
RegistryFactory registryFactory =
new RegistryFactoryImpl(directories.getWorkspace(), downloadManager, Suppliers.ofInstance(ImmutableMap.of()));

// Allow tests to override SkyFunctions.MODULE_FILE to use fake registry
if (!this.extraSkyFunctions.containsKey(SkyFunctions.MODULE_FILE)) {
addExtraSkyFunctions(ImmutableMap.of(
SkyFunctions.MODULE_FILE,
new ModuleFileFunction(registryFactory, directories.getWorkspace(), ImmutableMap.of())
));
}

addExtraSkyFunctions(
ImmutableMap.<SkyFunctionName, SkyFunction>builder()
.put(
Expand All @@ -129,6 +158,8 @@ public BazelPackageLoader buildImpl() {
ImmutableMap::of,
directories,
EXTERNAL_PACKAGE_HELPER))
.put(SkyFunctions.BAZEL_DEP_GRAPH, new BazelDepGraphFunction())
.put(SkyFunctions.BAZEL_MODULE_RESOLUTION, new BazelModuleResolutionFunction())
.build());

return new BazelPackageLoader(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ public void defaultExecGroupHasBasicExecutionPlatform(String action) throws Exce
public void toolchainParameterAsLabel_correctParsingOfToolchain(String action) throws Exception {
createCustomRule(
/* action= */ action,
/* actionParameters= */ "toolchain = Label('@//rule:toolchain_type_1'),",
/* actionParameters= */ "toolchain = Label('@@//rule:toolchain_type_1'),",
/* extraAttributes= */ "",
/* toolchains= */ "['//rule:toolchain_type_1', '//rule:toolchain_type_2']",
/* execGroups= */ "",
Expand All @@ -776,7 +776,7 @@ public void toolchainParameterAsLabel_correctParsingOfToolchain(String action) t
public void toolchainParameterAsString_correctParsingOfToolchain(String action) throws Exception {
createCustomRule(
/* action= */ action,
/* actionParameters= */ "toolchain = '@//rule:toolchain_type_1',",
/* actionParameters= */ "toolchain = '@@//rule:toolchain_type_1',",
/* extraAttributes= */ "",
/* toolchains= */ "['//rule:toolchain_type_1', '//rule:toolchain_type_2']",
/* execGroups= */ "",
Expand Down Expand Up @@ -1828,8 +1828,8 @@ public void ccCommonLink_cppLTOActionExecutesOnFirstPlatform() throws Exception
mockToolsConfig,
CcToolchainConfig.builder()
.withFeatures(CppRuleClasses.THIN_LTO, CppRuleClasses.SUPPORTS_START_END_LIB)
.withToolchainTargetConstraints("@//platforms:constraint_1")
.withToolchainExecConstraints("@//platforms:constraint_1"));
.withToolchainTargetConstraints("@@//platforms:constraint_1")
.withToolchainExecConstraints("@@//platforms:constraint_1"));

ImmutableList<Action> actions = getActions("//test:custom_rule_name", CppLinkAction.class);
ImmutableList<Action> cppLTOActions =
Expand Down Expand Up @@ -2004,8 +2004,8 @@ public void ccCommonCompile_moduleActionsExecuteOnFirstPlatform() throws Excepti
mockToolsConfig,
CcToolchainConfig.builder()
.withFeatures(MockCcSupport.HEADER_MODULES_FEATURES)
.withToolchainTargetConstraints("@//platforms:constraint_1")
.withToolchainExecConstraints("@//platforms:constraint_1"));
.withToolchainTargetConstraints("@@//platforms:constraint_1")
.withToolchainExecConstraints("@@//platforms:constraint_1"));

ImmutableList<Action> cppCompileActions =
getActions("//bazel_internal/test_rules/cc:custom_rule_name", CppCompileAction.class);
Expand Down Expand Up @@ -2075,8 +2075,8 @@ public void ccCommonCompile_codeGenModuleActionExecutesOnFirstPlatform() throws
mockToolsConfig,
CcToolchainConfig.builder()
.withFeatures(MockCcSupport.HEADER_MODULES_FEATURES)
.withToolchainTargetConstraints("@//platforms:constraint_1")
.withToolchainExecConstraints("@//platforms:constraint_1"));
.withToolchainTargetConstraints("@@//platforms:constraint_1")
.withToolchainExecConstraints("@@//platforms:constraint_1"));

ImmutableList<Action> cppCompileActions =
getActions("//bazel_internal/test_rules/cc:custom_rule_name", CppCompileAction.class);
Expand Down Expand Up @@ -2141,8 +2141,8 @@ public void ccCommonCompile_compileHeaderActionExecutesOnFirstPlatform() throws
mockToolsConfig,
CcToolchainConfig.builder()
.withFeatures(CppRuleClasses.PARSE_HEADERS)
.withToolchainTargetConstraints("@//platforms:constraint_1")
.withToolchainExecConstraints("@//platforms:constraint_1"));
.withToolchainTargetConstraints("@@//platforms:constraint_1")
.withToolchainExecConstraints("@@//platforms:constraint_1"));

ImmutableList<Action> cppCompileActions =
getActions("//bazel_internal/test_rules/cc:custom_rule_name", CppCompileAction.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void locations_spaces() throws Exception {

@Test
public void otherPathExpansion() throws Exception {
setBuildLanguageOptions("--noenable_bzlmod");
scratch.file(
"expansion/BUILD",
"genrule(name='foo', outs=['foo.txt'], cmd='never executed')",
Expand Down Expand Up @@ -262,6 +263,6 @@ public void otherPathMultiExpansion() throws Exception {
assertThat(expander.expand("foo $(rlocationpaths :foo) bar"))
.isEqualTo(
"foo __main__/expansion/bar.txt __main__/expansion/foo.txt bar"
.replace("__main__", TestConstants.WORKSPACE_NAME));
.replace("__main__", TestConstants.WORKSPACE_NAME_BZLMOD));
}
}
Loading
Loading