Merge "Allow codename.fingerprint format for targetSdkVersion"
This commit is contained in:
@@ -622,7 +622,7 @@ func (c *config) UnbundledBuild() bool {
|
|||||||
return Bool(c.productVariables.Unbundled_build)
|
return Bool(c.productVariables.Unbundled_build)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) UnbundledBuildPrebuiltSdks() bool {
|
func (c *config) UnbundledBuildUsePrebuiltSdks() bool {
|
||||||
return Bool(c.productVariables.Unbundled_build) && !Bool(c.productVariables.Unbundled_build_sdks_from_source)
|
return Bool(c.productVariables.Unbundled_build) && !Bool(c.productVariables.Unbundled_build_sdks_from_source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -511,7 +511,7 @@ func (a *AARImport) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
if !ctx.Config().UnbundledBuildPrebuiltSdks() {
|
if !ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(a))
|
sdkDep := decodeSdkDep(ctx, sdkContext(a))
|
||||||
if sdkDep.useModule && sdkDep.frameworkResModule != "" {
|
if sdkDep.useModule && sdkDep.frameworkResModule != "" {
|
||||||
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
|
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
|
||||||
|
@@ -68,15 +68,27 @@ func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext
|
|||||||
args = append(args, "--use-embedded-dex=true")
|
args = append(args, "--use-embedded-dex=true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deps android.Paths
|
||||||
|
targetSdkVersion := sdkVersionOrDefault(ctx, sdkContext.targetSdkVersion())
|
||||||
|
if targetSdkVersion == ctx.Config().PlatformSdkCodename() &&
|
||||||
|
ctx.Config().UnbundledBuild() &&
|
||||||
|
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
|
||||||
|
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
|
||||||
|
apiFingerprint := apiFingerprintPath(ctx)
|
||||||
|
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
|
||||||
|
deps = append(deps, apiFingerprint)
|
||||||
|
}
|
||||||
|
|
||||||
// Inject minSdkVersion into the manifest
|
// Inject minSdkVersion into the manifest
|
||||||
fixedManifest := android.PathForModuleOut(ctx, "manifest_fixer", "AndroidManifest.xml")
|
fixedManifest := android.PathForModuleOut(ctx, "manifest_fixer", "AndroidManifest.xml")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: manifestFixerRule,
|
Rule: manifestFixerRule,
|
||||||
Input: manifest,
|
Input: manifest,
|
||||||
|
Implicits: deps,
|
||||||
Output: fixedManifest,
|
Output: fixedManifest,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"minSdkVersion": sdkVersionOrDefault(ctx, sdkContext.minSdkVersion()),
|
"minSdkVersion": sdkVersionOrDefault(ctx, sdkContext.minSdkVersion()),
|
||||||
"targetSdkVersion": sdkVersionOrDefault(ctx, sdkContext.targetSdkVersion()),
|
"targetSdkVersion": targetSdkVersion,
|
||||||
"args": strings.Join(args, " "),
|
"args": strings.Join(args, " "),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
70
java/sdk.go
70
java/sdk.go
@@ -19,6 +19,7 @@ import (
|
|||||||
"android/soong/java/config"
|
"android/soong/java/config"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -29,11 +30,12 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
||||||
android.RegisterSingletonType("sdk", sdkSingletonFactory)
|
android.RegisterSingletonType("sdk", sdkSingletonFactory)
|
||||||
android.RegisterMakeVarsProvider(pctx, sdkFrameworkAidlMakeVars)
|
android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
|
||||||
}
|
}
|
||||||
|
|
||||||
var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey")
|
var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey")
|
||||||
var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
||||||
|
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
||||||
|
|
||||||
type sdkContext interface {
|
type sdkContext interface {
|
||||||
// sdkVersion eturns the sdk_version property of the current module, or an empty string if it is not set.
|
// sdkVersion eturns the sdk_version property of the current module, or an empty string if it is not set.
|
||||||
@@ -171,7 +173,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Config().UnbundledBuildPrebuiltSdks() && v != "" {
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() && v != "" {
|
||||||
return toPrebuilt(v)
|
return toPrebuilt(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +232,16 @@ func sdkSingletonFactory() android.Singleton {
|
|||||||
type sdkSingleton struct{}
|
type sdkSingleton struct{}
|
||||||
|
|
||||||
func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
if ctx.Config().UnbundledBuildPrebuiltSdks() || ctx.Config().IsPdkBuild() {
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules.
|
createSdkFrameworkAidl(ctx)
|
||||||
|
createAPIFingerprint(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules.
|
||||||
|
func createSdkFrameworkAidl(ctx android.SingletonContext) {
|
||||||
stubsModules := []string{
|
stubsModules := []string{
|
||||||
"android_stubs_current",
|
"android_stubs_current",
|
||||||
"android_test_stubs_current",
|
"android_test_stubs_current",
|
||||||
@@ -308,10 +314,62 @@ func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath {
|
|||||||
}).(android.OutputPath)
|
}).(android.OutputPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkFrameworkAidlMakeVars(ctx android.MakeVarsContext) {
|
// Create api_fingerprint.txt
|
||||||
if ctx.Config().UnbundledBuildPrebuiltSdks() || ctx.Config().IsPdkBuild() {
|
func createAPIFingerprint(ctx android.SingletonContext) {
|
||||||
|
out := apiFingerprintPath(ctx)
|
||||||
|
|
||||||
|
rule := android.NewRuleBuilder()
|
||||||
|
|
||||||
|
rule.Command().
|
||||||
|
Text("rm -f").Output(out)
|
||||||
|
cmd := rule.Command()
|
||||||
|
|
||||||
|
if ctx.Config().PlatformSdkCodename() == "REL" {
|
||||||
|
cmd.Text("echo REL >").Output(out)
|
||||||
|
} else if ctx.Config().IsPdkBuild() {
|
||||||
|
// TODO: get this from the PDK artifacts?
|
||||||
|
cmd.Text("echo PDK >").Output(out)
|
||||||
|
} else if !ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
|
in, err := ctx.GlobWithDeps("frameworks/base/api/*current.txt", nil)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Errorf("error globbing API files: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Text("cat").
|
||||||
|
Inputs(android.PathsForSource(ctx, in)).
|
||||||
|
Text("|")
|
||||||
|
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
cmd.Text("md5")
|
||||||
|
} else {
|
||||||
|
cmd.Text("md5sum")
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Text("| cut -d' ' -f1 >").
|
||||||
|
Output(out)
|
||||||
|
} else {
|
||||||
|
// Unbundled build
|
||||||
|
// TODO: use a prebuilt api_fingerprint.txt from prebuilts/sdk/current.txt once we have one
|
||||||
|
cmd.Text("echo").
|
||||||
|
Flag(ctx.Config().PlatformPreviewSdkVersion()).
|
||||||
|
Text(">").
|
||||||
|
Output(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
rule.Build(pctx, ctx, "api_fingerprint", "generate api_fingerprint.txt")
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiFingerprintPath(ctx android.PathContext) android.OutputPath {
|
||||||
|
return ctx.Config().Once(apiFingerprintPathKey, func() interface{} {
|
||||||
|
return android.PathForOutput(ctx, "api_fingerprint.txt")
|
||||||
|
}).(android.OutputPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sdkMakeVars(ctx android.MakeVarsContext) {
|
||||||
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Strict("FRAMEWORK_AIDL", sdkFrameworkAidlPath(ctx).String())
|
ctx.Strict("FRAMEWORK_AIDL", sdkFrameworkAidlPath(ctx).String())
|
||||||
|
ctx.Strict("API_FINGERPRINT", apiFingerprintPath(ctx).String())
|
||||||
}
|
}
|
||||||
|
@@ -402,7 +402,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc
|
|||||||
props.Sdk_version = proptools.StringPtr(module.sdkVersion(apiScope))
|
props.Sdk_version = proptools.StringPtr(module.sdkVersion(apiScope))
|
||||||
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
||||||
// Unbundled apps will use the prebult one from /prebuilts/sdk
|
// Unbundled apps will use the prebult one from /prebuilts/sdk
|
||||||
if mctx.Config().UnbundledBuildPrebuiltSdks() {
|
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false)
|
props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false)
|
||||||
}
|
}
|
||||||
props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
|
props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
|
||||||
@@ -612,7 +612,7 @@ func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion strin
|
|||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
||||||
// This module is just a wrapper for the stubs.
|
// This module is just a wrapper for the stubs.
|
||||||
if ctx.Config().UnbundledBuildPrebuiltSdks() {
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
return module.PrebuiltJars(ctx, sdkVersion)
|
return module.PrebuiltJars(ctx, sdkVersion)
|
||||||
} else {
|
} else {
|
||||||
if strings.HasPrefix(sdkVersion, "system_") {
|
if strings.HasPrefix(sdkVersion, "system_") {
|
||||||
@@ -628,7 +628,7 @@ func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion stri
|
|||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
||||||
// This module is just a wrapper for the stubs.
|
// This module is just a wrapper for the stubs.
|
||||||
if ctx.Config().UnbundledBuildPrebuiltSdks() {
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
return module.PrebuiltJars(ctx, sdkVersion)
|
return module.PrebuiltJars(ctx, sdkVersion)
|
||||||
} else {
|
} else {
|
||||||
if strings.HasPrefix(sdkVersion, "system_") {
|
if strings.HasPrefix(sdkVersion, "system_") {
|
||||||
|
Reference in New Issue
Block a user