Skip to content

Commit

Permalink
Add a PackageArgs class in preparation for REPO.bazel
Browse files Browse the repository at this point in the history
- Created a PackageArgs class that stores the values passed to the attrs of the `package()` function, so that they can be applied to a package builder in one go
  - These attr values used to be applied as soon as each attr is processed (i.e. evaluated). We can't do that anymore for repo(), since at the time of REPO.bazel evaluation, the package hasn't started being built yet.
  - Instead of storing the individual fields, Package now just holds on to a PackageArgs object.
  - In a follow-up CL, we store all the repo() values in a PackageArgs class, and apply those before the package() ones.
- Also removed `Package#isDefaultVisibilitySet` as nobody calls it anymore.

Work towards #18077

PiperOrigin-RevId: 539728608
Change-Id: Ie4a081fa0e52e833ac2a6be50033f95728da3a9b
  • Loading branch information
Wyverald authored and Copybara-Service committed Jun 12, 2023
1 parent 343ab03 commit 1f18b19
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 286 deletions.
Expand Up @@ -121,7 +121,7 @@ public NoneType licenses(
PackageContext context = PackageFactory.getContext(thread);
try {
License license = BuildType.LICENSE.convert(licensesList, "'licenses' operand");
context.pkgBuilder.setDefaultLicense(license);
context.pkgBuilder.mergePackageArgsFrom(PackageArgs.builder().setLicense(license));
} catch (ConversionException e) {
context.eventHandler.handle(
Package.error(thread.getCallerLocation(), e.getMessage(), Code.LICENSE_PARSE_FAILURE));
Expand All @@ -144,7 +144,7 @@ public NoneType distribs(Object object, StarlarkThread thread) throws EvalExcept
try {
Set<DistributionType> distribs =
BuildType.DISTRIBUTIONS.convert(object, "'distribs' operand");
context.pkgBuilder.setDefaultDistribs(distribs);
context.pkgBuilder.mergePackageArgsFrom(PackageArgs.builder().setDistribs(distribs));
} catch (ConversionException e) {
context.eventHandler.handle(
Package.error(
Expand Down

0 comments on commit 1f18b19

Please sign in to comment.