Skip to content

Commit

Permalink
Fix rolling release (#24513)
Browse files Browse the repository at this point in the history
Co-authored-by: Googler <[email protected]>
  • Loading branch information
Wyverald and pzembrod authored Nov 27, 2024
1 parent 4754de2 commit 94fb35b
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import com.google.devtools.build.lib.starlarkbuildapi.core.Bootstrap;
import com.google.devtools.build.lib.starlarkbuildapi.core.ContextGuardedValue;
import com.google.devtools.build.lib.starlarkbuildapi.core.ContextAndFlagGuardedValue;
import net.starlark.java.eval.Starlark;

/** {@link Bootstrap} for Starlark objects related to apple rules. */
Expand All @@ -27,22 +28,17 @@ public class AppleBootstrap implements Bootstrap {
private static final ImmutableSet<PackageIdentifier> allowedRepositories =
ImmutableSet.of(
PackageIdentifier.createUnchecked("_builtins", ""),
PackageIdentifier.createUnchecked("apple_support", ""),
PackageIdentifier.createUnchecked("bazel_tools", ""),
PackageIdentifier.createUnchecked("local_config_cc", ""),
PackageIdentifier.createUnchecked("rules_apple", ""),
PackageIdentifier.createUnchecked("rules_cc", ""),
PackageIdentifier.createUnchecked("rules_go", ""),
PackageIdentifier.createUnchecked("rules_ios", ""),
PackageIdentifier.createUnchecked("rules_swift", ""),
PackageIdentifier.createUnchecked("stardoc", ""),
PackageIdentifier.createUnchecked("tulsi", ""),
PackageIdentifier.createUnchecked("", "test_starlark"),
PackageIdentifier.createUnchecked("", "tools/osx"));
PackageIdentifier.createUnchecked("", "tools/build_defs/apple"));

@Override
public void addBindingsToBuilder(ImmutableMap.Builder<String, Object> builder) {
builder.put(
"apple_common", ContextGuardedValue.onlyInAllowedRepos(Starlark.NONE, allowedRepositories));
"apple_common",
ContextAndFlagGuardedValue.onlyInAllowedReposOrWhenIncompatibleFlagIsFalse(
BuildLanguageOptions.INCOMPATIBLE_STOP_EXPORTING_LANGUAGE_MODULES,
Starlark.NONE,
allowedRepositories));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public final class XcodeVersionTest extends BuildViewTestCase {

@Test
public void testXcodeVersionCanBeReadFromStarlark() throws Exception {
scratch.file("test_starlark/rule/BUILD");
scratch.file("examples/rule/BUILD");
scratch.file(
"test_starlark/rule/apple_rules.bzl",
"examples/rule/apple_rules.bzl",
"""
MyInfo = provider()
Expand Down Expand Up @@ -72,7 +72,7 @@ def my_rule_impl(ctx):
scratch.file(
"examples/apple_starlark/BUILD",
"""
load("//test_starlark/rule:apple_rules.bzl", "my_rule")
load("//examples/rule:apple_rules.bzl", "my_rule")
package(default_visibility = ["//visibility:public"])
Expand All @@ -95,7 +95,7 @@ def my_rule_impl(ctx):
(RuleConfiguredTarget) getConfiguredTarget("//examples/apple_starlark:my_target");
Provider.Key key =
new StarlarkProvider.Key(
keyForBuild(Label.parseCanonical("//test_starlark/rule:apple_rules.bzl")), "MyInfo");
keyForBuild(Label.parseCanonical("//examples/rule:apple_rules.bzl")), "MyInfo");
StructImpl myInfo = (StructImpl) starlarkTarget.get(key);
assertThat((String) myInfo.getValue("xcode_version")).isEqualTo("8");
assertThat((String) myInfo.getValue("ios_version")).isEqualTo("9.0");
Expand Down
Loading

0 comments on commit 94fb35b

Please sign in to comment.