2021-12-10 12:14:59 +01:00
|
|
|
// Copyright 2021 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package bp2build
|
|
|
|
|
|
|
|
import (
|
2022-02-25 22:34:51 +01:00
|
|
|
"fmt"
|
2021-12-10 12:14:59 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/java"
|
|
|
|
)
|
|
|
|
|
2022-06-21 21:28:33 +02:00
|
|
|
func runJavaLibraryTestCaseWithRegistrationCtxFunc(t *testing.T, tc Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
|
2021-12-10 12:14:59 +01:00
|
|
|
t.Helper()
|
2022-06-21 21:28:33 +02:00
|
|
|
(&tc).ModuleTypeUnderTest = "java_library"
|
|
|
|
(&tc).ModuleTypeUnderTestFactory = java.LibraryFactory
|
|
|
|
RunBp2BuildTestCase(t, registrationCtxFunc, tc)
|
2022-03-18 15:11:07 +01:00
|
|
|
}
|
|
|
|
|
2022-06-21 21:28:33 +02:00
|
|
|
func runJavaLibraryTestCase(t *testing.T, tc Bp2buildTestCase) {
|
2022-03-15 22:02:09 +01:00
|
|
|
t.Helper()
|
2022-03-18 15:11:07 +01:00
|
|
|
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
|
2021-12-10 12:14:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibrary(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Description: "java_library with srcs, exclude_srcs and libs",
|
|
|
|
Blueprint: `java_library {
|
2021-12-10 12:14:59 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java", "b.java"],
|
|
|
|
exclude_srcs: ["b.java"],
|
|
|
|
libs: ["java-lib-2"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "java-lib-2",
|
|
|
|
srcs: ["b.java"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2021-12-10 12:14:59 +01:00
|
|
|
"srcs": `["a.java"]`,
|
2022-10-31 20:08:18 +01:00
|
|
|
"deps": `[":java-lib-2-neverlink"]`,
|
2021-12-10 12:14:59 +01:00
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
2021-12-10 12:14:59 +01:00
|
|
|
"srcs": `["b.java"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
|
2021-12-10 12:14:59 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2022-02-25 22:34:51 +01:00
|
|
|
|
|
|
|
func TestJavaLibraryConvertsStaticLibsToDepsAndExports(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-02-25 22:34:51 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
libs: ["java-lib-2"],
|
|
|
|
static_libs: ["java-lib-3"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "java-lib-2",
|
|
|
|
srcs: ["b.java"],
|
|
|
|
bazel_module: { bp2build_available: false },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "java-lib-3",
|
|
|
|
srcs: ["c.java"],
|
|
|
|
bazel_module: { bp2build_available: false },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-02-25 22:34:51 +01:00
|
|
|
"srcs": `["a.java"]`,
|
|
|
|
"deps": `[
|
2022-10-31 20:08:18 +01:00
|
|
|
":java-lib-2-neverlink",
|
2022-02-25 22:34:51 +01:00
|
|
|
":java-lib-3",
|
|
|
|
]`,
|
|
|
|
"exports": `[":java-lib-3"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-02-25 22:34:51 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryConvertsStaticLibsToExportsIfNoSrcs(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-02-25 22:34:51 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
static_libs: ["java-lib-2"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "java-lib-2",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
bazel_module: { bp2build_available: false },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-02-25 22:34:51 +01:00
|
|
|
"exports": `[":java-lib-2"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-02-25 22:34:51 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryFailsToConvertLibsWithNoSrcs(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
ExpectedErr: fmt.Errorf("Module has direct dependencies but no sources. Bazel will not allow this."),
|
|
|
|
Blueprint: `java_library {
|
2022-02-25 22:34:51 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
libs: ["java-lib-2"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "java-lib-2",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
bazel_module: { bp2build_available: false },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{},
|
2022-02-25 22:34:51 +01:00
|
|
|
})
|
|
|
|
}
|
2022-03-18 15:11:07 +01:00
|
|
|
|
|
|
|
func TestJavaLibraryPlugins(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-03-18 15:11:07 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
plugins: ["java-plugin-1"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_plugin {
|
|
|
|
name: "java-plugin-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
bazel_module: { bp2build_available: false },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-18 15:11:07 +01:00
|
|
|
"plugins": `[":java-plugin-1"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-18 15:11:07 +01:00
|
|
|
},
|
|
|
|
}, func(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("java_plugin", java.PluginFactory)
|
|
|
|
})
|
|
|
|
}
|
2022-03-15 22:02:09 +01:00
|
|
|
|
2022-04-23 01:09:58 +02:00
|
|
|
func TestJavaLibraryJavaVersion(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-04-23 01:09:58 +02:00
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
java_version: "11",
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2023-02-24 18:07:08 +01:00
|
|
|
"srcs": `["a.java"]`,
|
|
|
|
"java_version": `"11"`,
|
2022-04-23 01:09:58 +02:00
|
|
|
}),
|
2023-02-24 18:07:08 +01:00
|
|
|
MakeNeverlinkDuplicateTargetWithAttrs(
|
|
|
|
"java_library",
|
|
|
|
"java-lib-1",
|
|
|
|
AttrNameToString{"java_version": `"11"`}),
|
2022-04-23 01:09:58 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-03-15 22:02:09 +01:00
|
|
|
func TestJavaLibraryErrorproneJavacflagsEnabledManually(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-03-15 22:02:09 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
javacflags: ["-Xsuper-fast"],
|
|
|
|
errorprone: {
|
|
|
|
enabled: true,
|
|
|
|
javacflags: ["-Xep:SpeedLimit:OFF"],
|
|
|
|
},
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-15 22:02:09 +01:00
|
|
|
"javacopts": `[
|
|
|
|
"-Xsuper-fast",
|
|
|
|
"-Xep:SpeedLimit:OFF",
|
|
|
|
]`,
|
|
|
|
"srcs": `["a.java"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-15 22:02:09 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-03-15 22:02:09 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
javacflags: ["-Xsuper-fast"],
|
|
|
|
errorprone: {
|
|
|
|
javacflags: ["-Xep:SpeedLimit:OFF"],
|
|
|
|
},
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-15 22:02:09 +01:00
|
|
|
"javacopts": `["-Xsuper-fast"]`,
|
|
|
|
"srcs": `["a.java"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-15 22:02:09 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledManually(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Blueprint: `java_library {
|
2022-03-15 22:02:09 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
javacflags: ["-Xsuper-fast"],
|
|
|
|
errorprone: {
|
|
|
|
enabled: false,
|
|
|
|
javacflags: ["-Xep:SpeedLimit:OFF"],
|
|
|
|
},
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-15 22:02:09 +01:00
|
|
|
"javacopts": `["-Xsuper-fast"]`,
|
|
|
|
"srcs": `["a.java"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-15 22:02:09 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2022-03-16 21:36:54 +01:00
|
|
|
|
|
|
|
func TestJavaLibraryLogTags(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Description: "Java library - logtags creates separate dependency",
|
|
|
|
ModuleTypeUnderTest: "java_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
|
|
|
Blueprint: `java_library {
|
2022-03-16 21:36:54 +01:00
|
|
|
name: "example_lib",
|
|
|
|
srcs: [
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
"a.logtag",
|
|
|
|
"b.logtag",
|
|
|
|
],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("event_log_tags", "example_lib_logtags", AttrNameToString{
|
2022-03-16 21:36:54 +01:00
|
|
|
"srcs": `[
|
|
|
|
"a.logtag",
|
|
|
|
"b.logtag",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "example_lib", AttrNameToString{
|
2022-03-16 21:36:54 +01:00
|
|
|
"srcs": `[
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
":example_lib_logtags",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
2022-03-16 21:36:54 +01:00
|
|
|
}})
|
|
|
|
}
|
2022-03-23 21:20:42 +01:00
|
|
|
|
|
|
|
func TestJavaLibraryResources(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Filesystem: map[string]string{
|
2022-03-23 21:20:42 +01:00
|
|
|
"res/a.res": "",
|
|
|
|
"res/b.res": "",
|
|
|
|
"res/dir1/b.res": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `java_library {
|
2022-03-23 21:20:42 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
java_resources: ["res/a.res", "res/b.res"],
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-23 21:20:42 +01:00
|
|
|
"resources": `[
|
|
|
|
"res/a.res",
|
|
|
|
"res/b.res",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-23 21:20:42 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryResourceDirs(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Filesystem: map[string]string{
|
2022-03-23 21:20:42 +01:00
|
|
|
"res/a.res": "",
|
|
|
|
"res/b.res": "",
|
|
|
|
"res/dir1/b.res": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `java_library {
|
2022-03-23 21:20:42 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
java_resource_dirs: ["res"],
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-23 21:20:42 +01:00
|
|
|
"resource_strip_prefix": `"res"`,
|
|
|
|
"resources": `[
|
|
|
|
"res/a.res",
|
|
|
|
"res/b.res",
|
|
|
|
"res/dir1/b.res",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-23 21:20:42 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryResourcesExcludeDir(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Filesystem: map[string]string{
|
2022-03-23 21:20:42 +01:00
|
|
|
"res/a.res": "",
|
|
|
|
"res/exclude/b.res": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `java_library {
|
2022-03-23 21:20:42 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
java_resource_dirs: ["res"],
|
|
|
|
exclude_java_resource_dirs: ["res/exclude"],
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-23 21:20:42 +01:00
|
|
|
"resource_strip_prefix": `"res"`,
|
|
|
|
"resources": `["res/a.res"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-23 21:20:42 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Filesystem: map[string]string{
|
2022-03-23 21:20:42 +01:00
|
|
|
"res/a.res": "",
|
|
|
|
"res/dir1/b.res": "",
|
|
|
|
"res/dir1/exclude.res": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `java_library {
|
2022-03-23 21:20:42 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
java_resource_dirs: ["res"],
|
|
|
|
exclude_java_resources: ["res/dir1/exclude.res"],
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
2022-03-23 21:20:42 +01:00
|
|
|
"resource_strip_prefix": `"res"`,
|
|
|
|
"resources": `[
|
|
|
|
"res/a.res",
|
|
|
|
"res/dir1/b.res",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
2022-03-23 21:20:42 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryResourcesFailsWithMultipleDirs(t *testing.T) {
|
2022-06-21 21:28:33 +02:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Filesystem: map[string]string{
|
2022-03-23 21:20:42 +01:00
|
|
|
"res/a.res": "",
|
|
|
|
"res1/a.res": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `java_library {
|
2022-03-23 21:20:42 +01:00
|
|
|
name: "java-lib-1",
|
|
|
|
java_resource_dirs: ["res", "res1"],
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedErr: fmt.Errorf("bp2build does not support more than one directory in java_resource_dirs (b/226423379)"),
|
|
|
|
ExpectedBazelTargets: []string{},
|
2022-03-23 21:20:42 +01:00
|
|
|
})
|
|
|
|
}
|
2022-08-25 20:45:31 +02:00
|
|
|
|
|
|
|
func TestJavaLibraryAidl(t *testing.T) {
|
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Description: "Java library - aidl creates separate dependency",
|
|
|
|
ModuleTypeUnderTest: "java_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
|
|
|
Blueprint: `java_library {
|
|
|
|
name: "example_lib",
|
|
|
|
srcs: [
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
"a.aidl",
|
|
|
|
"b.aidl",
|
|
|
|
],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("aidl_library", "example_lib_aidl_library", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"srcs": `[
|
|
|
|
"a.aidl",
|
|
|
|
"b.aidl",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_aidl_library", "example_lib_java_aidl_library", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"deps": `[":example_lib_aidl_library"]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "example_lib", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"deps": `[":example_lib_java_aidl_library"]`,
|
|
|
|
"exports": `[":example_lib_java_aidl_library"]`,
|
|
|
|
"srcs": `[
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
2022-08-25 20:45:31 +02:00
|
|
|
}})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryAidlSrcsNoFileGroup(t *testing.T) {
|
|
|
|
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
|
|
|
Description: "Java library - aidl filegroup is parsed",
|
|
|
|
ModuleTypeUnderTest: "java_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
|
|
|
Blueprint: `
|
|
|
|
java_library {
|
|
|
|
name: "example_lib",
|
|
|
|
srcs: [
|
|
|
|
"a.java",
|
|
|
|
"b.aidl",
|
|
|
|
],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("aidl_library", "example_lib_aidl_library", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"srcs": `["b.aidl"]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_aidl_library", "example_lib_java_aidl_library", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"deps": `[":example_lib_aidl_library"]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "example_lib", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"deps": `[":example_lib_java_aidl_library"]`,
|
|
|
|
"exports": `[":example_lib_java_aidl_library"]`,
|
|
|
|
"srcs": `["a.java"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
2022-08-25 20:45:31 +02:00
|
|
|
},
|
|
|
|
}, func(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJavaLibraryAidlFilegroup(t *testing.T) {
|
|
|
|
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
|
|
|
Description: "Java library - aidl filegroup is parsed",
|
|
|
|
ModuleTypeUnderTest: "java_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
|
|
|
Blueprint: `
|
|
|
|
filegroup {
|
|
|
|
name: "random_other_files",
|
|
|
|
srcs: [
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
filegroup {
|
|
|
|
name: "aidl_files",
|
|
|
|
srcs: [
|
|
|
|
"a.aidl",
|
|
|
|
"b.aidl",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
java_library {
|
|
|
|
name: "example_lib",
|
|
|
|
srcs: [
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
":aidl_files",
|
|
|
|
":random_other_files",
|
|
|
|
],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTargetNoRestrictions("aidl_library", "aidl_files", AttrNameToString{
|
|
|
|
"srcs": `[
|
|
|
|
"a.aidl",
|
|
|
|
"b.aidl",
|
|
|
|
]`,
|
2023-03-23 16:51:49 +01:00
|
|
|
"tags": `["apex_available=//apex_available:anyapex"]`,
|
2022-08-25 20:45:31 +02:00
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_aidl_library", "example_lib_java_aidl_library", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"deps": `[":aidl_files"]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "example_lib", AttrNameToString{
|
2022-08-25 20:45:31 +02:00
|
|
|
"deps": `[":example_lib_java_aidl_library"]`,
|
|
|
|
"exports": `[":example_lib_java_aidl_library"]`,
|
|
|
|
"srcs": `[
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
":random_other_files",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
2022-08-25 20:45:31 +02:00
|
|
|
MakeBazelTargetNoRestrictions("filegroup", "random_other_files", AttrNameToString{
|
|
|
|
"srcs": `[
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
]`,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
}, func(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
|
|
|
})
|
|
|
|
}
|
2022-08-25 19:51:21 +02:00
|
|
|
|
|
|
|
func TestJavaLibraryAidlNonAdjacentAidlFilegroup(t *testing.T) {
|
|
|
|
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
|
|
|
Description: "java_library with non adjacent aidl filegroup",
|
|
|
|
ModuleTypeUnderTest: "java_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
|
|
|
Filesystem: map[string]string{
|
|
|
|
"path/to/A/Android.bp": `
|
|
|
|
filegroup {
|
|
|
|
name: "A_aidl",
|
|
|
|
srcs: ["aidl/A.aidl"],
|
|
|
|
path: "aidl",
|
|
|
|
}`,
|
|
|
|
},
|
|
|
|
Blueprint: `
|
|
|
|
java_library {
|
|
|
|
name: "foo",
|
|
|
|
srcs: [
|
|
|
|
":A_aidl",
|
|
|
|
],
|
|
|
|
}`,
|
|
|
|
ExpectedBazelTargets: []string{
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_aidl_library", "foo_java_aidl_library", AttrNameToString{
|
2022-08-25 19:51:21 +02:00
|
|
|
"deps": `["//path/to/A:A_aidl"]`,
|
|
|
|
}),
|
2022-08-31 20:28:19 +02:00
|
|
|
MakeBazelTarget("java_library", "foo", AttrNameToString{
|
2022-08-25 19:51:21 +02:00
|
|
|
"exports": `[":foo_java_aidl_library"]`,
|
|
|
|
}),
|
2022-10-31 20:08:18 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "foo"),
|
2022-08-25 19:51:21 +02:00
|
|
|
},
|
|
|
|
}, func(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
|
|
|
})
|
|
|
|
}
|
2022-08-03 03:06:50 +02:00
|
|
|
|
|
|
|
func TestConvertArmNeonVariant(t *testing.T) {
|
|
|
|
t.Helper()
|
|
|
|
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
|
|
|
|
Description: "Android Library - simple arch feature",
|
|
|
|
ModuleTypeUnderTest: "android_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
|
|
|
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
|
|
|
android_library {
|
|
|
|
name: "TestLib",
|
|
|
|
manifest: "manifest/AndroidManifest.xml",
|
|
|
|
srcs: ["lib.java"],
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
neon: {
|
|
|
|
srcs: ["arm_neon.java"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget(
|
|
|
|
"android_library",
|
|
|
|
"TestLib",
|
|
|
|
AttrNameToString{
|
|
|
|
"srcs": `["lib.java"] + select({
|
|
|
|
"//build/bazel/platforms/arch/variants:arm-neon": ["arm_neon.java"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
})`,
|
|
|
|
"manifest": `"manifest/AndroidManifest.xml"`,
|
|
|
|
"resource_files": `[]`,
|
|
|
|
}),
|
2022-10-26 22:40:18 +02:00
|
|
|
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
2022-08-03 03:06:50 +02:00
|
|
|
}})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConvertMultipleArchFeatures(t *testing.T) {
|
|
|
|
t.Helper()
|
|
|
|
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
|
|
|
|
Description: "Android Library - multiple arch features",
|
|
|
|
ModuleTypeUnderTest: "android_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
|
|
|
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
|
|
|
android_library {
|
|
|
|
name: "TestLib",
|
|
|
|
manifest: "manifest/AndroidManifest.xml",
|
|
|
|
srcs: ["lib.java"],
|
|
|
|
arch: {
|
|
|
|
x86: {
|
|
|
|
ssse3: {
|
|
|
|
srcs: ["ssse3.java"],
|
|
|
|
},
|
|
|
|
sse4_1: {
|
|
|
|
srcs: ["sse4_1.java"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget(
|
|
|
|
"android_library",
|
|
|
|
"TestLib",
|
|
|
|
AttrNameToString{
|
|
|
|
"srcs": `["lib.java"] + select({
|
|
|
|
"//build/bazel/platforms/arch/variants:x86-sse4_1": ["sse4_1.java"],
|
|
|
|
"//build/bazel/platforms/arch/variants:x86-sse4_1-ssse3": [
|
|
|
|
"sse4_1.java",
|
|
|
|
"ssse3.java",
|
|
|
|
],
|
|
|
|
"//build/bazel/platforms/arch/variants:x86-ssse3": ["ssse3.java"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
})`,
|
|
|
|
"manifest": `"manifest/AndroidManifest.xml"`,
|
|
|
|
"resource_files": `[]`,
|
|
|
|
}),
|
2022-10-26 22:40:18 +02:00
|
|
|
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
2022-08-03 03:06:50 +02:00
|
|
|
}})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConvertExcludeSrcsArchFeature(t *testing.T) {
|
|
|
|
t.Helper()
|
|
|
|
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
|
|
|
|
Description: "Android Library - exclude_srcs with arch feature",
|
|
|
|
ModuleTypeUnderTest: "android_library",
|
|
|
|
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
|
|
|
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
|
|
|
android_library {
|
|
|
|
name: "TestLib",
|
|
|
|
manifest: "manifest/AndroidManifest.xml",
|
|
|
|
srcs: ["lib.java"],
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
srcs: ["arm_non_neon.java"],
|
|
|
|
neon: {
|
|
|
|
exclude_srcs: ["arm_non_neon.java"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget(
|
|
|
|
"android_library",
|
|
|
|
"TestLib",
|
|
|
|
AttrNameToString{
|
|
|
|
"srcs": `["lib.java"] + select({
|
|
|
|
"//build/bazel/platforms/arch/variants:arm-neon": [],
|
|
|
|
"//build/bazel/platforms/arch:arm": ["arm_non_neon.java"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
})`,
|
|
|
|
"manifest": `"manifest/AndroidManifest.xml"`,
|
|
|
|
"resource_files": `[]`,
|
|
|
|
}),
|
2022-10-26 22:40:18 +02:00
|
|
|
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
2022-08-03 03:06:50 +02:00
|
|
|
}})
|
|
|
|
}
|
2022-11-14 22:38:07 +01:00
|
|
|
|
|
|
|
func TestJavaLibraryKotlinSrcs(t *testing.T) {
|
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
2023-03-06 20:43:55 +01:00
|
|
|
Description: "java_library with kotlin srcs",
|
2022-11-14 22:38:07 +01:00
|
|
|
Blueprint: `java_library {
|
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java", "b.java", "c.kt"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget("kt_jvm_library", "java-lib-1", AttrNameToString{
|
|
|
|
"srcs": `[
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
"c.kt",
|
|
|
|
]`,
|
|
|
|
}),
|
2022-12-15 07:12:46 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
|
2022-11-14 22:38:07 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-03-06 20:43:55 +01:00
|
|
|
func TestJavaLibraryKotlincflags(t *testing.T) {
|
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Description: "java_library with kotlincfalgs",
|
|
|
|
Blueprint: `java_library {
|
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: [ "a.kt"],
|
|
|
|
kotlincflags: ["-flag1", "-flag2"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget("kt_jvm_library", "java-lib-1", AttrNameToString{
|
|
|
|
"srcs": `["a.kt"]`,
|
|
|
|
"kotlincflags": `[
|
|
|
|
"-flag1",
|
|
|
|
"-flag2",
|
|
|
|
]`,
|
|
|
|
}),
|
|
|
|
MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-11-14 22:38:07 +01:00
|
|
|
func TestJavaLibraryKotlinCommonSrcs(t *testing.T) {
|
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
2023-03-06 20:43:55 +01:00
|
|
|
Description: "java_library with kotlin common_srcs",
|
2022-11-14 22:38:07 +01:00
|
|
|
Blueprint: `java_library {
|
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java", "b.java"],
|
|
|
|
common_srcs: ["c.kt"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget("kt_jvm_library", "java-lib-1", AttrNameToString{
|
|
|
|
"srcs": `[
|
|
|
|
"a.java",
|
|
|
|
"b.java",
|
|
|
|
]`,
|
|
|
|
"common_srcs": `["c.kt"]`,
|
|
|
|
}),
|
2022-12-15 07:12:46 +01:00
|
|
|
MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
|
2022-11-14 22:38:07 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2023-01-12 19:20:32 +01:00
|
|
|
|
2023-04-04 04:53:34 +02:00
|
|
|
func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
2023-01-12 19:20:32 +01:00
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Description: "java_library with arch variant libs",
|
|
|
|
Blueprint: `java_library {
|
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
libs: ["java-lib-2"],
|
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
libs: ["java-lib-3"],
|
2023-04-04 04:53:34 +02:00
|
|
|
static_libs: ["java-lib-4"],
|
2023-01-12 19:20:32 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library{
|
|
|
|
name: "java-lib-2",
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library{
|
|
|
|
name: "java-lib-3",
|
|
|
|
}
|
2023-04-04 04:53:34 +02:00
|
|
|
|
|
|
|
java_library{
|
|
|
|
name: "java-lib-4",
|
|
|
|
}
|
2023-01-12 19:20:32 +01:00
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
|
|
|
"srcs": `["a.java"]`,
|
2023-04-04 04:53:34 +02:00
|
|
|
"exports": `select({
|
|
|
|
"//build/bazel/platforms/os:android": [":java-lib-4"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
})`,
|
2023-01-12 19:20:32 +01:00
|
|
|
"deps": `[":java-lib-2-neverlink"] + select({
|
2023-04-04 04:53:34 +02:00
|
|
|
"//build/bazel/platforms/os:android": [
|
|
|
|
":java-lib-3-neverlink",
|
|
|
|
":java-lib-4",
|
|
|
|
],
|
2023-01-12 19:20:32 +01:00
|
|
|
"//conditions:default": [],
|
|
|
|
})`,
|
|
|
|
}),
|
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
|
|
|
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{}),
|
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
|
|
|
|
MakeBazelTarget("java_library", "java-lib-3", AttrNameToString{}),
|
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-3"),
|
2023-04-04 04:53:34 +02:00
|
|
|
MakeBazelTarget("java_library", "java-lib-4", AttrNameToString{}),
|
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-4"),
|
2023-01-12 19:20:32 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2023-03-08 22:34:17 +01:00
|
|
|
|
|
|
|
func TestJavaLibraryArchVariantSrcsWithExcludes(t *testing.T) {
|
|
|
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
|
|
|
Description: "java_library with arch variant libs",
|
|
|
|
Blueprint: `java_library {
|
|
|
|
name: "java-lib-1",
|
|
|
|
srcs: ["a.java", "b.java"],
|
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
exclude_srcs: ["a.java"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
ExpectedBazelTargets: []string{
|
|
|
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
|
|
|
"srcs": `["b.java"] + select({
|
|
|
|
"//build/bazel/platforms/os:android": [],
|
|
|
|
"//conditions:default": ["a.java"],
|
|
|
|
})`,
|
|
|
|
}),
|
|
|
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|