diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-09-11 10:25:18 -0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:32 +0200 |
commit | 02d7ebe400de1291bba716f48fc11fc350d724d0 (patch) | |
tree | 9304f7d27f1b40899b5115e67a387383fbfd987f | |
parent | e5dd6accd3cfa98b70322db8304351b1b5839b67 (diff) | |
download | build_soong-02d7ebe400de1291bba716f48fc11fc350d724d0.tar.gz build_soong-02d7ebe400de1291bba716f48fc11fc350d724d0.tar.bz2 build_soong-02d7ebe400de1291bba716f48fc11fc350d724d0.zip |
Fix android_test install path.
Test: m nothing + diff soong mk and ninja files.
Bug: 140795853
Change-Id: I3667eac951dea7e447cf73219ff89199fca9ed63
-rw-r--r-- | android/module.go | 10 | ||||
-rw-r--r-- | android/paths.go | 3 | ||||
-rw-r--r-- | android/paths_test.go | 5 | ||||
-rw-r--r-- | java/app.go | 27 |
4 files changed, 35 insertions, 10 deletions
diff --git a/android/module.go b/android/module.go index 6a796227..495efbe1 100644 --- a/android/module.go +++ b/android/module.go @@ -129,6 +129,7 @@ type ModuleContext interface { AddMissingDependencies(deps []string) InstallInData() bool + InstallInTestcases() bool InstallInSanitizerDir() bool InstallInRecovery() bool @@ -185,6 +186,7 @@ type Module interface { Enabled() bool Target() Target InstallInData() bool + InstallInTestcases() bool InstallInSanitizerDir() bool InstallInRecovery() bool SkipInstall() @@ -656,6 +658,10 @@ func (p *ModuleBase) InstallInData() bool { return false } +func (p *ModuleBase) InstallInTestcases() bool { + return false +} + func (p *ModuleBase) InstallInSanitizerDir() bool { return false } @@ -1252,6 +1258,10 @@ func (a *androidModuleContext) InstallInData() bool { return a.module.InstallInData() } +func (a *androidModuleContext) InstallInTestcases() bool { + return a.module.InstallInTestcases() +} + func (a *androidModuleContext) InstallInSanitizerDir() bool { return a.module.InstallInSanitizerDir() } diff --git a/android/paths.go b/android/paths.go index 8d0573d5..8583daa5 100644 --- a/android/paths.go +++ b/android/paths.go @@ -46,6 +46,7 @@ type ModuleInstallPathContext interface { androidBaseContext InstallInData() bool + InstallInTestcases() bool InstallInSanitizerDir() bool InstallInRecovery() bool } @@ -1167,6 +1168,8 @@ func modulePartition(ctx ModuleInstallPathContext) string { var partition string if ctx.InstallInData() { partition = "data" + } else if ctx.InstallInTestcases() { + partition = "testcases" } else if ctx.InstallInRecovery() { // the layout of recovery partion is the same as that of system partition partition = "recovery/root/system" diff --git a/android/paths_test.go b/android/paths_test.go index b52d7133..c956a795 100644 --- a/android/paths_test.go +++ b/android/paths_test.go @@ -203,6 +203,7 @@ type moduleInstallPathContextImpl struct { androidBaseContextImpl inData bool + inTestcases bool inSanitizerDir bool inRecovery bool } @@ -221,6 +222,10 @@ func (m moduleInstallPathContextImpl) InstallInData() bool { return m.inData } +func (m moduleInstallPathContextImpl) InstallInTestcases() bool { + return m.inTestcases +} + func (m moduleInstallPathContextImpl) InstallInSanitizerDir() bool { return m.inSanitizerDir } diff --git a/java/app.go b/java/app.go index 52e103bd..f7cf8a5d 100644 --- a/java/app.go +++ b/java/app.go @@ -119,6 +119,8 @@ type AndroidApp struct { // the install APK name is normally the same as the module name, but can be overridden with PRODUCT_PACKAGE_NAME_OVERRIDES. installApkName string + installDir android.OutputPath + additionalAaptFlags []string } @@ -339,7 +341,7 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates [] return certificates } -func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext, installDir android.OutputPath) android.OptionalPath { +func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext) android.OptionalPath { if !Bool(a.appProperties.Embed_notices) && !ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") { return android.OptionalPath{} } @@ -386,7 +388,7 @@ func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext, installDir an sort.Slice(noticePaths, func(i, j int) bool { return noticePaths[i].String() < noticePaths[j].String() }) - noticeFile := android.BuildNoticeOutput(ctx, installDir, a.installApkName+".apk", noticePaths) + noticeFile := android.BuildNoticeOutput(ctx, a.installDir, a.installApkName+".apk", noticePaths) return android.OptionalPathForPath(noticeFile) } @@ -395,20 +397,21 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { // Check if the install APK name needs to be overridden. a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(a.Name()) - var installDir android.OutputPath if ctx.ModuleName() == "framework-res" { // framework-res.apk is installed as system/framework/framework-res.apk - installDir = android.PathForModuleInstall(ctx, "framework") + a.installDir = android.PathForModuleInstall(ctx, "framework") } else if ctx.ModuleName() == "org.lineageos.platform-res" { // org.lineageos.platform-res.apk needs to be in system/framework - installDir = android.PathForModuleInstall(ctx, "framework") + a.installDir = android.PathForModuleInstall(ctx, "framework") } else if Bool(a.appProperties.Privileged) { - installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName) + a.installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName) + } else if ctx.InstallInTestcases() { + a.installDir = android.PathForModuleInstall(ctx, a.installApkName) } else { - installDir = android.PathForModuleInstall(ctx, "app", a.installApkName) + a.installDir = android.PathForModuleInstall(ctx, "app", a.installApkName) } - a.aapt.noticeFile = a.noticeBuildActions(ctx, installDir) + a.aapt.noticeFile = a.noticeBuildActions(ctx) // Process all building blocks, from AAPT to certificates. a.aaptBuildActions(ctx) @@ -446,9 +449,9 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { a.bundleFile = bundleFile // Install the app package. - ctx.InstallFile(installDir, a.installApkName+".apk", a.outputFile) + ctx.InstallFile(a.installDir, a.installApkName+".apk", a.outputFile) for _, split := range a.aapt.splits { - ctx.InstallFile(installDir, a.installApkName+"_"+split.suffix+".apk", split.path) + ctx.InstallFile(a.installDir, a.installApkName+"_"+split.suffix+".apk", split.path) } } @@ -540,6 +543,10 @@ type AndroidTest struct { data android.Paths } +func (a *AndroidTest) InstallInTestcases() bool { + return true +} + func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Check if the instrumentation target package is overridden before generating build actions. if a.appTestProperties.Instrumentation_for != nil { |