Skip to content

Commit

Permalink
Rollforward of e96507b: Enable Starlark java_binary
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 476136813
Change-Id: I1b778832ed52fb732bae1ed4cd1b32ebd72720f8
  • Loading branch information
hvadehra authored and copybara-github committed Sep 22, 2022
1 parent a2177dc commit bc1e9d8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ private static BuildLanguageOptions parseBuildLanguageOptions(String... options)
throws Exception {
OptionsParser parser =
OptionsParser.builder().optionsClasses(BuildLanguageOptions.class).build();
parser.parse("--experimental_google_legacy_api"); // For starlark java_binary;
parser.parse(options);
return parser.getOptions(BuildLanguageOptions.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void useConfiguration(ImmutableMap<String, Object> starlarkOptions, St
ImmutableList.Builder<String> fullArgs = ImmutableList.builder();
fullArgs.add("--incompatible_enable_android_toolchain_resolution");
// Uncomment the below to get more info when tests fail because of toolchain resolution.
// fullArgs.add("--toolchain_resolution_debug=tools/android:.*toolchain_type");
// fullArgs.add("--toolchain_resolution_debug=tools/android:.*toolchain_type");
boolean hasPlatform = false;
for (String arg : args) {
if (arg.startsWith("--android_sdk=")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1615,12 +1615,14 @@ public void starlarkJavaToJavaBinaryAttributes() throws Exception {
" deps = [':mya'], runtime_deps = [':myb'])");
assertNoEvents();

setBuildLanguageOptions("--experimental_google_legacy_api");
// Test that all bottom jars are on the runtime classpath.
ConfiguredTarget binary = getConfiguredTarget("//foo:binary");
assertThat(
prettyArtifactNames(
binary
.getProvider(JavaRuntimeClasspathProvider.class)
.get(JavaInfo.PROVIDER)
.getCompilationInfoProvider()
.getRuntimeClasspath()
.getSet(Artifact.class)))
.containsAtLeast("foo/libjl_bottom_for_deps.jar", "foo/libjl_bottom_for_runtime_deps.jar");
Expand Down Expand Up @@ -1971,6 +1973,7 @@ public void javaBinary_propagatesDirectNativeLibrariesInJavaInfo() throws Except
"my_rule(name = 'r', dep = ':jl', cc_dep = ':ccl')",
"java_binary(name = 'binary', main_class = 'C', srcs = ['java/C.java'], deps = [':r'])");

setBuildLanguageOptions("--experimental_google_legacy_api");
ConfiguredTarget testTarget = getConfiguredTarget("//foo:binary");

TemplateExpansionAction action =
Expand Down Expand Up @@ -2218,6 +2221,7 @@ public void javaCommonCompileNeverlink() throws Exception {
" fragments = ['java']",
")");

setBuildLanguageOptions("--experimental_google_legacy_api");
ConfiguredTarget target = getConfiguredTarget("//java/test:plugin");
assertThat(
actionsTestUtil()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public void splitDeps() throws Exception {
"java/a/BUILD",
"cc_library(name = 'lib', srcs = ['lib.cc'])",
"android_binary(name='a', manifest = 'AndroidManifest.xml', deps = [':lib'])");
useConfiguration("--fat_apk_cpu=k8,armeabi-v7a");
useConfiguration("--fat_apk_cpu=k8,armeabi-v7a", "--experimental_google_legacy_api");
List<ConfiguredTarget> deps = getConfiguredDeps("//java/a:a", "deps");
assertThat(deps).hasSize(2);
ConfiguredTarget dep1 = deps.get(0);
Expand Down

0 comments on commit bc1e9d8

Please sign in to comment.