Skip to content

Commit

Permalink
Automated rollback of commit 3774f00.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Performance regression, b/294105788

*** Original change description ***

Implement REPO.bazel

- REPO.bazel is a new file at the root of repos that can only contain a `repo()` call with a bunch of package default arguments (similar to `package()`)
- A new SkyFunction, RepoFileFunction, evaluates a REPO.bazel file and returns the `PackageArgs` object containing those arguments
- PackageFunction for packages in repo `@foo` now depends on RepoFileFunction for `@foo`

Fixes bazelbuild#18077

PiperOrigin-RevId: 553500673
Change-Id: I866e73262ab75635c8927f8c77eb5412c01e16a9
  • Loading branch information
brandjon authored and copybara-github committed Aug 3, 2023
1 parent a6d04d8 commit 28715de
Show file tree
Hide file tree
Showing 17 changed files with 4 additions and 578 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.devtools.build.lib.collect.nestedset.Depset;
import com.google.devtools.build.lib.packages.BuildGlobals;
import com.google.devtools.build.lib.packages.Proto;
import com.google.devtools.build.lib.packages.RepoCallable;
import com.google.devtools.build.lib.packages.SelectorList;
import com.google.devtools.build.lib.packages.StarlarkGlobals;
import com.google.devtools.build.lib.packages.StarlarkNativeModule;
Expand Down Expand Up @@ -121,11 +120,4 @@ public ImmutableMap<String, Object> getSclToplevels() {
env.put("struct", StructProvider.STRUCT);
return env.buildOrThrow();
}

@Override
public ImmutableMap<String, Object> getRepoToplevels() {
ImmutableMap.Builder<String, Object> env = ImmutableMap.builder();
Starlark.addMethods(env, RepoCallable.INSTANCE);
return env.buildOrThrow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class LabelConstants {
public static final PathFragment WORKSPACE_DOT_BAZEL_FILE_NAME =
PathFragment.create("WORKSPACE.bazel");
public static final PathFragment MODULE_DOT_BAZEL_FILE_NAME = PathFragment.create("MODULE.bazel");
public static final PathFragment REPO_FILE_NAME = PathFragment.create("REPO.bazel");

public static final PathFragment MODULE_LOCKFILE_NAME = PathFragment.create("MODULE.bazel.lock");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
*/
@AutoValue
public abstract class PackageArgs {
public static final PackageArgs EMPTY = PackageArgs.builder().build();

public static final PackageArgs DEFAULT =
PackageArgs.builder()
.setDefaultVisibility(RuleVisibility.PRIVATE)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,4 @@ public interface StarlarkGlobals {

/** Returns the top-levels for .scl files. */
ImmutableMap<String, Object> getSclToplevels();

/** Returns the top-levels for REPO.bazel files. */
ImmutableMap<String, Object> getRepoToplevels();
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import net.starlark.java.syntax.Location;

/** The Starlark native module. */
// TODO(cparsons): Move the definition of native.package() to this class.
public class StarlarkNativeModule implements StarlarkNativeModuleApi {
private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

Expand Down
36 changes: 0 additions & 36 deletions src/main/java/com/google/devtools/build/lib/skyframe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ java_library(
":recursive_package_provider_backed_target_pattern_resolver",
":recursive_pkg_function",
":recursive_pkg_value",
":repo_file_function",
":repo_file_value",
":repository_mapping_function",
":repository_mapping_value",
":rule_configured_target_value",
Expand Down Expand Up @@ -2195,40 +2193,6 @@ java_library(
],
)

java_library(
name = "repo_file_function",
srcs = ["RepoFileFunction.java"],
deps = [
":precomputed_value",
":repo_file_value",
":repository_mapping_value",
"//src/main/java/com/google/devtools/build/lib/actions:file_metadata",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/rules:repository/repository_directory_value",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/skyframe",
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
"//src/main/java/net/starlark/java/eval",
"//src/main/java/net/starlark/java/syntax",
"//third_party:jsr305",
],
)

java_library(
name = "repo_file_value",
srcs = ["RepoFileValue.java"],
deps = [
":sky_functions",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
"//third_party:auto_value",
],
)

java_library(
name = "repository_mapping_function",
srcs = ["RepositoryMappingFunction.java"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import com.google.devtools.build.lib.server.FailureDetails.PackageLoading.Code;
import com.google.devtools.build.lib.skyframe.BzlLoadFunction.BzlLoadFailedException;
import com.google.devtools.build.lib.skyframe.GlobValue.InvalidGlobPatternException;
import com.google.devtools.build.lib.skyframe.RepoFileFunction.BadRepoFileException;
import com.google.devtools.build.lib.skyframe.StarlarkBuiltinsFunction.BuiltinsFailedException;
import com.google.devtools.build.lib.util.DetailedExitCode;
import com.google.devtools.build.lib.util.Pair;
Expand Down Expand Up @@ -1241,24 +1240,6 @@ private LoadedPackage loadPackage(
IgnoredPackagePrefixesValue repositoryIgnoredPackagePrefixes =
(IgnoredPackagePrefixesValue)
env.getValue(IgnoredPackagePrefixesValue.key(packageId.getRepository()));
RepoFileValue repoFileValue;
try {
repoFileValue =
(RepoFileValue)
env.getValueOrThrow(
RepoFileValue.key(packageId.getRepository()),
IOException.class,
BadRepoFileException.class);
} catch (IOException | BadRepoFileException e) {
throw PackageFunctionException.builder()
.setType(PackageFunctionException.Type.BUILD_FILE_CONTAINS_ERRORS)
.setPackageIdentifier(packageId)
.setTransience(Transience.PERSISTENT)
.setException(e)
.setMessage("bad REPO.bazel file")
.setPackageLoadingCode(PackageLoading.Code.BAD_REPO_FILE)
.build();
}
if (env.valuesMissing()) {
return null;
}
Expand Down Expand Up @@ -1394,9 +1375,8 @@ private LoadedPackage loadPackage(
.setFilename(buildFileRootedPath)
.setConfigSettingVisibilityPolicy(configSettingVisibilityPolicy);

pkgBuilder
.mergePackageArgsFrom(PackageArgs.builder().setDefaultVisibility(defaultVisibility))
.mergePackageArgsFrom(repoFileValue.packageArgs());
pkgBuilder.mergePackageArgsFrom(
PackageArgs.builder().setDefaultVisibility(defaultVisibility));

Set<SkyKey> globDepKeys = ImmutableSet.of();

Expand Down
Loading

0 comments on commit 28715de

Please sign in to comment.