aboutsummaryrefslogtreecommitdiffstats
path: root/apex
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-04-18 17:25:49 +0900
committerJiyong Park <jiyong@google.com>2019-04-23 14:26:06 +0900
commitd37a882ad462111f6b99bdecbd2771e7f3c3ad07 (patch)
tree23610d647d9a4bd33988039b41917757a463f8ba /apex
parentefcdd3b4bd676dcdffa3f926c8434c213726b749 (diff)
downloadbuild_soong-d37a882ad462111f6b99bdecbd2771e7f3c3ad07.tar.gz
build_soong-d37a882ad462111f6b99bdecbd2771e7f3c3ad07.tar.bz2
build_soong-d37a882ad462111f6b99bdecbd2771e7f3c3ad07.zip
Set default target SDK version for APEX
Target SDK version is used for targeting an APEX to a specific set of platform builds. Usually, the targeting is unrestricted (in case the APEX can run on all platforms), or based on platform SDK version (e.g. 28 for P). However, when the platform is under development and SDK is not finalized, the targeting should be much more fine-grained; the APEX should be targeted to a very specific build that supports the same set of APIs that the APEX was built against. To support that, target sdk version is automatically set by the build system. When the platform is released or SDK is finalized, the target sdk version set to the SDK version number. If not, it is set to <version_code>.<fingerprint> (e.g., Q.123456). Note that the target sdk version set by the build system is used only when the target sdk version is not explicitly set in AndroidManifest.xml. Bug: 130541924 Test: UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true \ UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true \ TARGET_BUILD_APPS=com.android.tzdata m build.ninja has --target_sdk_version Q.$$(cat out/soong/api_fingerprint.txt) Test: aapt dump badging out/dist/com.android.tzdata.apex | grep \ targetSdkVersion shows: targetSdkVersion:'Q.6ee443d9ad5f0cca7a43cfa97b7fc62a' Merged-In: I086230d787f01075c28fc3f0163550300fa00212 Change-Id: I086230d787f01075c28fc3f0163550300fa00212 (cherry picked from commit 71b519d6ce98fc0313019d84777bfc04f3799efc)
Diffstat (limited to 'apex')
-rw-r--r--apex/apex.go11
-rw-r--r--apex/apex_test.go3
2 files changed, 14 insertions, 0 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 004de86c..509e0f2e 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -977,6 +977,17 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType ap
optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String())
}
+ targetSdkVersion := ctx.Config().DefaultAppTargetSdk()
+ if targetSdkVersion == ctx.Config().PlatformSdkCodename() &&
+ ctx.Config().UnbundledBuild() &&
+ !ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
+ ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
+ apiFingerprint := java.ApiFingerprintPath(ctx)
+ targetSdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
+ implicitInputs = append(implicitInputs, apiFingerprint)
+ }
+ optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
+
ctx.Build(pctx, android.BuildParams{
Rule: apexRule,
Implicits: implicitInputs,
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 3c80376d..c771ae45 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -171,6 +171,7 @@ func testApex(t *testing.T, bp string) *android.TestContext {
"testkey2.pem": nil,
"myapex-arm64.apex": nil,
"myapex-arm.apex": nil,
+ "frameworks/base/api/current.txt": nil,
})
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -190,6 +191,8 @@ func setup(t *testing.T) (config android.Config, buildDir string) {
config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test")
config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"}
+ config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q")
+ config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false)
return
}