summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/aar.go4
-rwxr-xr-xjava/app.go28
-rw-r--r--java/app_test.go9
-rw-r--r--java/device_host_converter.go8
-rw-r--r--java/dexpreopt.go4
-rw-r--r--java/dexpreopt_bootjars.go20
-rw-r--r--java/dexpreopt_bootjars_test.go2
-rw-r--r--java/droiddoc.go2
-rw-r--r--java/java.go21
-rw-r--r--java/java_test.go46
-rw-r--r--java/testing.go62
11 files changed, 89 insertions, 117 deletions
diff --git a/java/aar.go b/java/aar.go
index 7413c8082..28e388aaf 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -734,6 +734,10 @@ func (a *AARImport) DexJarBuildPath() android.Path {
return nil
}
+func (a *AARImport) DexJarInstallPath() android.Path {
+ return nil
+}
+
func (a *AARImport) AidlIncludeDirs() android.Paths {
return nil
}
diff --git a/java/app.go b/java/app.go
index 24dde79f4..0fdede13a 100755
--- a/java/app.go
+++ b/java/app.go
@@ -691,9 +691,9 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates []
systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
if strings.HasPrefix(certPath, systemCertPath) {
enforceSystemCert := ctx.Config().EnforceSystemCertificate()
- whitelist := ctx.Config().EnforceSystemCertificateWhitelist()
+ allowed := ctx.Config().EnforceSystemCertificateAllowList()
- if enforceSystemCert && !inList(m.Name(), whitelist) {
+ if enforceSystemCert && !inList(m.Name(), allowed) {
ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
}
}
@@ -973,10 +973,6 @@ func AndroidAppFactory() android.Module {
&module.overridableAppProperties,
&module.usesLibrary.usesLibraryProperties)
- module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
- return class == android.Device && ctx.Config().DevicePrefer32BitApps()
- })
-
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
android.InitOverridableModule(module, &module.appProperties.Overrides)
@@ -1887,16 +1883,22 @@ func (u *usesLibrary) usesLibraryPaths(ctx android.ModuleContext) dexpreopt.Libr
ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) {
dep := ctx.OtherModuleName(m)
if lib, ok := m.(Dependency); ok {
- if dexJar := lib.DexJarBuildPath(); dexJar != nil {
- usesLibPaths[dep] = &dexpreopt.LibraryPath{
- dexJar,
- // TODO(b/132357300): propagate actual install paths here.
- filepath.Join("/system/framework", dep+".jar"),
- }
- } else {
+ buildPath := lib.DexJarBuildPath()
+ if buildPath == nil {
ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must"+
" produce a dex jar, does it have installable: true?", dep)
+ return
}
+
+ var devicePath string
+ installPath := lib.DexJarInstallPath()
+ if installPath == nil {
+ devicePath = filepath.Join("/system/framework", dep+".jar")
+ } else {
+ devicePath = android.InstallPathToOnDevicePath(ctx, installPath.(android.InstallPath))
+ }
+
+ usesLibPaths[dep] = &dexpreopt.LibraryPath{buildPath, devicePath}
} else if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{dep})
} else {
diff --git a/java/app_test.go b/java/app_test.go
index eeba161b3..e45ba70d5 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2657,7 +2657,7 @@ func TestCodelessApp(t *testing.T) {
}
func TestEmbedNotice(t *testing.T) {
- ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
+ ctx, _ := testJavaWithFS(t, cc.GatherRequiredDepsForTest(android.Android)+`
android_app {
name: "foo",
srcs: ["a.java"],
@@ -2713,7 +2713,12 @@ func TestEmbedNotice(t *testing.T) {
srcs: ["b.java"],
notice: "TOOL_NOTICE",
}
- `)
+ `, map[string][]byte{
+ "APP_NOTICE": nil,
+ "GENRULE_NOTICE": nil,
+ "LIB_NOTICE": nil,
+ "TOOL_NOTICE": nil,
+ })
// foo has NOTICE files to process, and embed_notices is true.
foo := ctx.ModuleForTests("foo", "android_common")
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index 1ffb13f94..9191a8321 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -51,7 +51,7 @@ type DeviceForHost struct {
// java_device_for_host makes the classes.jar output of a device java_library module available to host
// java_library modules.
//
-// It is rarely necessary, and its usage is restricted to a few whitelisted projects.
+// It is rarely necessary, and its usage is restricted to a few allowed projects.
func DeviceForHostFactory() android.Module {
module := &DeviceForHost{}
@@ -68,7 +68,7 @@ type HostForDevice struct {
// java_host_for_device makes the classes.jar output of a host java_library module available to device
// java_library modules.
//
-// It is rarely necessary, and its usage is restricted to a few whitelisted projects.
+// It is rarely necessary, and its usage is restricted to a few allowed projects.
func HostForDeviceFactory() android.Module {
module := &HostForDevice{}
@@ -154,6 +154,10 @@ func (d *DeviceHostConverter) DexJarBuildPath() android.Path {
return nil
}
+func (d *DeviceHostConverter) DexJarInstallPath() android.Path {
+ return nil
+}
+
func (d *DeviceHostConverter) AidlIncludeDirs() android.Paths {
return nil
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 2911fd9b9..c33415ef6 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -77,10 +77,6 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
return true
}
- if ctx.Config().UnbundledBuild() {
- return true
- }
-
if d.isTest {
return true
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 9d9383814..41205598e 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -179,15 +179,7 @@ func RegisterDexpreoptBootJarsComponents(ctx android.RegistrationContext) {
}
func skipDexpreoptBootJars(ctx android.PathContext) bool {
- if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
- return true
- }
-
- if ctx.Config().UnbundledBuild() {
- return true
- }
-
- return false
+ return dexpreopt.GetGlobalConfig(ctx).DisablePreopt
}
type dexpreoptBootJars struct {
@@ -340,10 +332,12 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI
bootFrameworkProfileRule(ctx, image, missingDeps)
updatableBcpPackagesRule(ctx, image, missingDeps)
- var allFiles android.Paths
+ var zipFiles android.Paths
for _, variant := range image.variants {
files := buildBootImageVariant(ctx, variant, profile, missingDeps)
- allFiles = append(allFiles, files.Paths()...)
+ if variant.target.Os == android.Android {
+ zipFiles = append(zipFiles, files.Paths()...)
+ }
}
if image.zip != nil {
@@ -351,8 +345,8 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI
rule.Command().
BuiltTool(ctx, "soong_zip").
FlagWithOutput("-o ", image.zip).
- FlagWithArg("-C ", image.dir.String()).
- FlagWithInputList("-f ", allFiles, " -f ")
+ FlagWithArg("-C ", image.dir.Join(ctx, android.Android.String()).String()).
+ FlagWithInputList("-f ", zipFiles, " -f ")
rule.Build(pctx, ctx, "zip_"+image.name, "zip "+image.name+" image")
}
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go
index e9704dc2a..9670c7f4b 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -118,7 +118,7 @@ func TestDexpreoptBootZip(t *testing.T) {
ctx := android.PathContextForTesting(testConfig(nil, "", nil))
expectedInputs := []string{}
- for _, target := range dexpreoptTargets(ctx) {
+ for _, target := range ctx.Config().Targets[android.Android] {
for _, ext := range []string{".art", ".oat", ".vdex"} {
for _, jar := range []string{"foo", "bar", "baz"} {
expectedInputs = append(expectedInputs,
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 4c3e11236..68cfe9fde 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -1470,7 +1470,7 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
FlagWithInput("@", srcJarList).
FlagWithOutput("--strict-input-files:warn ", android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"violations.txt"))
- if implicitsRsp.String() != "" {
+ if implicitsRsp != nil {
cmd.FlagWithArg("--strict-input-files-exempt ", "@"+implicitsRsp.String())
}
diff --git a/java/java.go b/java/java.go
index af68e56b7..1cdfbf187 100644
--- a/java/java.go
+++ b/java/java.go
@@ -502,6 +502,7 @@ type Dependency interface {
ResourceJars() android.Paths
ImplementationAndResourcesJars() android.Paths
DexJarBuildPath() android.Path
+ DexJarInstallPath() android.Path
AidlIncludeDirs() android.Paths
ExportedSdkLibs() []string
ExportedPlugins() (android.Paths, []string)
@@ -1749,6 +1750,10 @@ func (j *Module) DexJarBuildPath() android.Path {
return j.dexJarFile
}
+func (j *Module) DexJarInstallPath() android.Path {
+ return j.installFile
+}
+
func (j *Module) ResourceJars() android.Paths {
if j.resourceJar == nil {
return nil
@@ -2575,6 +2580,10 @@ func (j *Import) DexJarBuildPath() android.Path {
return nil
}
+func (j *Import) DexJarInstallPath() android.Path {
+ return nil
+}
+
func (j *Import) AidlIncludeDirs() android.Paths {
return j.exportAidlIncludeDirs
}
@@ -2754,8 +2763,10 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.maybeStrippedDexJarFile = dexOutputFile
- ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
- j.Stem()+".jar", dexOutputFile)
+ if j.IsForPlatform() {
+ ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
+ j.Stem()+".jar", dexOutputFile)
+ }
}
func (j *DexImport) DexJarBuildPath() android.Path {
@@ -2863,11 +2874,7 @@ func (ks *kytheExtractJavaSingleton) GenerateBuildActions(ctx android.SingletonC
})
// TODO(asmundak): perhaps emit a rule to output a warning if there were no xrefTargets
if len(xrefTargets) > 0 {
- ctx.Build(pctx, android.BuildParams{
- Rule: blueprint.Phony,
- Output: android.PathForPhony(ctx, "xref_java"),
- Inputs: xrefTargets,
- })
+ ctx.Phony("xref_java", xrefTargets...)
}
}
diff --git a/java/java_test.go b/java/java_test.go
index 8ea34d975..215070e6f 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -142,9 +142,14 @@ func testJavaErrorWithConfig(t *testing.T, pattern string, config android.Config
return ctx, config
}
+func testJavaWithFS(t *testing.T, bp string, fs map[string][]byte) (*android.TestContext, android.Config) {
+ t.Helper()
+ return testJavaWithConfig(t, testConfig(nil, bp, fs))
+}
+
func testJava(t *testing.T, bp string) (*android.TestContext, android.Config) {
t.Helper()
- return testJavaWithConfig(t, testConfig(nil, bp, nil))
+ return testJavaWithFS(t, bp, nil)
}
func testJavaWithConfig(t *testing.T, config android.Config) (*android.TestContext, android.Config) {
@@ -740,7 +745,7 @@ func TestResources(t *testing.T) {
for _, test := range table {
t.Run(test.name, func(t *testing.T) {
- ctx, _ := testJava(t, `
+ ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
srcs: [
@@ -750,7 +755,13 @@ func TestResources(t *testing.T) {
],
`+test.prop+`,
}
- `+test.extra)
+ `+test.extra,
+ map[string][]byte{
+ "java-res/a/a": nil,
+ "java-res/b/b": nil,
+ "java-res2/a": nil,
+ },
+ )
foo := ctx.ModuleForTests("foo", "android_common").Output("withres/foo.jar")
fooRes := ctx.ModuleForTests("foo", "android_common").Output("res/foo.jar")
@@ -769,7 +780,7 @@ func TestResources(t *testing.T) {
}
func TestIncludeSrcs(t *testing.T) {
- ctx, _ := testJava(t, `
+ ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
srcs: [
@@ -790,7 +801,11 @@ func TestIncludeSrcs(t *testing.T) {
java_resource_dirs: ["java-res"],
include_srcs: true,
}
- `)
+ `, map[string][]byte{
+ "java-res/a/a": nil,
+ "java-res/b/b": nil,
+ "java-res2/a": nil,
+ })
// Test a library with include_srcs: true
foo := ctx.ModuleForTests("foo", "android_common").Output("withres/foo.jar")
@@ -832,7 +847,7 @@ func TestIncludeSrcs(t *testing.T) {
}
func TestGeneratedSources(t *testing.T) {
- ctx, _ := testJava(t, `
+ ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
srcs: [
@@ -847,7 +862,10 @@ func TestGeneratedSources(t *testing.T) {
tool_files: ["java-res/a"],
out: ["gen.java"],
}
- `)
+ `, map[string][]byte{
+ "a.java": nil,
+ "b.java": nil,
+ })
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
genrule := ctx.ModuleForTests("gen", "").Rule("generator")
@@ -932,7 +950,7 @@ func TestSharding(t *testing.T) {
}
func TestDroiddoc(t *testing.T) {
- ctx, _ := testJava(t, `
+ ctx, _ := testJavaWithFS(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
path: ".",
@@ -945,7 +963,7 @@ func TestDroiddoc(t *testing.T) {
droiddoc {
name: "bar-doc",
srcs: [
- "bar-doc/*.java",
+ "bar-doc/a.java",
"bar-doc/IFoo.aidl",
":bar-doc-aidl-srcs",
],
@@ -963,7 +981,11 @@ func TestDroiddoc(t *testing.T) {
todo_file: "libcore-docs-todo.html",
args: "-offlinemode -title \"libcore\"",
}
- `)
+ `,
+ map[string][]byte{
+ "bar-doc/a.java": nil,
+ "bar-doc/b.java": nil,
+ })
barDoc := ctx.ModuleForTests("bar-doc", "android_common").Rule("javadoc")
var javaSrcs []string
@@ -989,7 +1011,7 @@ func TestDroidstubsWithSystemModules(t *testing.T) {
droidstubs {
name: "stubs-source-system-modules",
srcs: [
- "bar-doc/*.java",
+ "bar-doc/a.java",
],
sdk_version: "none",
system_modules: "source-system-modules",
@@ -1010,7 +1032,7 @@ func TestDroidstubsWithSystemModules(t *testing.T) {
droidstubs {
name: "stubs-prebuilt-system-modules",
srcs: [
- "bar-doc/*.java",
+ "bar-doc/a.java",
],
sdk_version: "none",
system_modules: "prebuilt-system-modules",
diff --git a/java/testing.go b/java/testing.go
index f993f56b3..f34c64af6 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -25,35 +25,12 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
bp += GatherRequiredDepsForTest()
mockFS := map[string][]byte{
- "a.java": nil,
- "b.java": nil,
- "c.java": nil,
- "b.kt": nil,
- "a.jar": nil,
- "b.jar": nil,
- "c.jar": nil,
- "APP_NOTICE": nil,
- "GENRULE_NOTICE": nil,
- "LIB_NOTICE": nil,
- "TOOL_NOTICE": nil,
- "AndroidTest.xml": nil,
- "java-res/a/a": nil,
- "java-res/b/b": nil,
- "java-res2/a": nil,
- "java-fg/a.java": nil,
- "java-fg/b.java": nil,
- "java-fg/c.java": nil,
"api/current.txt": nil,
"api/removed.txt": nil,
"api/system-current.txt": nil,
"api/system-removed.txt": nil,
"api/test-current.txt": nil,
"api/test-removed.txt": nil,
- "framework/aidl/a.aidl": nil,
- "aidl/foo/IFoo.aidl": nil,
- "aidl/bar/IBar.aidl": nil,
- "assets_a/a": nil,
- "assets_b/b": nil,
"prebuilts/sdk/14/public/android.jar": nil,
"prebuilts/sdk/14/public/framework.aidl": nil,
@@ -103,45 +80,6 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
"prebuilts/sdk/30/test/api/bar-removed.txt": nil,
"prebuilts/sdk/tools/core-lambda-stubs.jar": nil,
"prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "sdk", api_dirs: ["14", "28", "30", "current"],}`),
-
- "prebuilts/apk/app.apk": nil,
- "prebuilts/apk/app_arm.apk": nil,
- "prebuilts/apk/app_arm64.apk": nil,
- "prebuilts/apk/app_xhdpi.apk": nil,
- "prebuilts/apk/app_xxhdpi.apk": nil,
-
- "prebuilts/apks/app.apks": nil,
-
- // For framework-res, which is an implicit dependency for framework
- "AndroidManifest.xml": nil,
- "build/make/target/product/security/testkey": nil,
-
- "build/soong/scripts/jar-wrapper.sh": nil,
-
- "build/make/core/verify_uses_libraries.sh": nil,
-
- "build/make/core/proguard.flags": nil,
- "build/make/core/proguard_basic_keeps.flags": nil,
-
- "jdk8/jre/lib/jce.jar": nil,
- "jdk8/jre/lib/rt.jar": nil,
- "jdk8/lib/tools.jar": nil,
-
- "bar-doc/a.java": nil,
- "bar-doc/b.java": nil,
- "bar-doc/IFoo.aidl": nil,
- "bar-doc/IBar.aidl": nil,
- "bar-doc/known_oj_tags.txt": nil,
- "external/doclava/templates-sdk": nil,
-
- "cert/new_cert.x509.pem": nil,
- "cert/new_cert.pk8": nil,
- "lineage.bin": nil,
-
- "testdata/data": nil,
-
- "stubs-sources/foo/Foo.java": nil,
- "stubs/sources/foo/Foo.java": nil,
}
cc.GatherRequiredFilesForTest(mockFS)