aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2019-04-22 23:26:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-22 23:26:55 +0000
commitefcdd3b4bd676dcdffa3f926c8434c213726b749 (patch)
tree6212cf0bf848702a8a39e425e6c0736a7b377250
parenta3f279bd1bb062755cdc6406fd43d7fd781ddb91 (diff)
parent5c87791a78fc31620b165300c7976d8cf5674f9c (diff)
downloadbuild_soong-efcdd3b4bd676dcdffa3f926c8434c213726b749.tar.gz
build_soong-efcdd3b4bd676dcdffa3f926c8434c213726b749.tar.bz2
build_soong-efcdd3b4bd676dcdffa3f926c8434c213726b749.zip
Merge changes from topic "framework.aidl" into qt-dev
* changes: Allow codename.fingerprint format for targetSdkVersion Build framework.aidl in Soong Get default sdk_test.go values from config
-rw-r--r--android/config.go2
-rw-r--r--java/aar.go2
-rw-r--r--java/android_manifest.go20
-rw-r--r--java/builder.go1
-rw-r--r--java/droiddoc.go18
-rw-r--r--java/gen.go5
-rw-r--r--java/java.go38
-rw-r--r--java/java_test.go3
-rw-r--r--java/sdk.go188
-rw-r--r--java/sdk_library.go6
-rw-r--r--java/sdk_test.go400
-rw-r--r--java/testing.go12
-rw-r--r--sysprop/sysprop_test.go1
13 files changed, 450 insertions, 246 deletions
diff --git a/android/config.go b/android/config.go
index 39aaa6df..43eeb975 100644
--- a/android/config.go
+++ b/android/config.go
@@ -618,7 +618,7 @@ func (c *config) UnbundledBuild() bool {
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)
}
diff --git a/java/aar.go b/java/aar.go
index a993bf6a..c6212766 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -511,7 +511,7 @@ func (a *AARImport) Name() string {
}
func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
- if !ctx.Config().UnbundledBuildPrebuiltSdks() {
+ if !ctx.Config().UnbundledBuildUsePrebuiltSdks() {
sdkDep := decodeSdkDep(ctx, sdkContext(a))
if sdkDep.useModule && sdkDep.frameworkResModule != "" {
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
diff --git a/java/android_manifest.go b/java/android_manifest.go
index d72476d8..39cf4712 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -68,15 +68,27 @@ func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext
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
fixedManifest := android.PathForModuleOut(ctx, "manifest_fixer", "AndroidManifest.xml")
ctx.Build(pctx, android.BuildParams{
- Rule: manifestFixerRule,
- Input: manifest,
- Output: fixedManifest,
+ Rule: manifestFixerRule,
+ Input: manifest,
+ Implicits: deps,
+ Output: fixedManifest,
Args: map[string]string{
"minSdkVersion": sdkVersionOrDefault(ctx, sdkContext.minSdkVersion()),
- "targetSdkVersion": sdkVersionOrDefault(ctx, sdkContext.targetSdkVersion()),
+ "targetSdkVersion": targetSdkVersion,
"args": strings.Join(args, " "),
},
})
diff --git a/java/builder.go b/java/builder.go
index 338cd52e..d257d1da 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -154,6 +154,7 @@ type javaBuilderFlags struct {
processor string
systemModules classpath
aidlFlags string
+ aidlDeps android.Paths
javaVersion string
errorProneExtraJavacFlags string
diff --git a/java/droiddoc.go b/java/droiddoc.go
index e163617e..fd7e2a48 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -404,6 +404,7 @@ type droiddocBuilderFlags struct {
sourcepathArgs string
dokkaClasspathArgs string
aidlFlags string
+ aidlDeps android.Paths
doclavaStubsFlags string
doclavaDocsFlags string
@@ -574,26 +575,23 @@ func (j *Javadoc) genWhitelistPathPrefixes(whitelistPathPrefixes map[string]bool
func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags {
var flags droiddocBuilderFlags
- // aidl flags.
- aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
- if len(aidlFlags) > 0 {
- // optimization.
- ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
- flags.aidlFlags = "$aidlFlags"
- }
+ flags.aidlFlags, flags.aidlDeps = j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
return flags
}
func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
- aidlIncludeDirs android.Paths) []string {
+ aidlIncludeDirs android.Paths) (string, android.Paths) {
aidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl.Local_include_dirs)
aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...)
var flags []string
+ var deps android.Paths
+
if aidlPreprocess.Valid() {
flags = append(flags, "-p"+aidlPreprocess.String())
+ deps = append(deps, aidlPreprocess.Path())
} else {
flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
}
@@ -604,7 +602,7 @@ func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Op
flags = append(flags, "-I"+src.String())
}
- return flags
+ return strings.Join(flags, " "), deps
}
func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
@@ -615,7 +613,7 @@ func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
for _, srcFile := range srcFiles {
switch srcFile.Ext() {
case ".aidl":
- javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
+ javaFile := genAidl(ctx, srcFile, flags.aidlFlags, flags.aidlDeps)
outSrcFiles = append(outSrcFiles, javaFile)
case ".sysprop":
javaFile := genSysprop(ctx, srcFile)
diff --git a/java/gen.go b/java/gen.go
index 500d887e..09776283 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -59,7 +59,7 @@ var (
})
)
-func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string) android.Path {
+func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string, deps android.Paths) android.Path {
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
depFile := javaFile.String() + ".d"
@@ -68,6 +68,7 @@ func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string)
Description: "aidl " + aidlFile.Rel(),
Output: javaFile,
Input: aidlFile,
+ Implicits: deps,
Args: map[string]string{
"depFile": depFile,
"aidlFlags": aidlFlags,
@@ -111,7 +112,7 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
for _, srcFile := range srcFiles {
switch srcFile.Ext() {
case ".aidl":
- javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
+ javaFile := genAidl(ctx, srcFile, flags.aidlFlags, flags.aidlDeps)
outSrcFiles = append(outSrcFiles, javaFile)
case ".logtags":
j.logtagsSrcs = append(j.logtagsSrcs, srcFile)
diff --git a/java/java.go b/java/java.go
index bf62578f..793e40b5 100644
--- a/java/java.go
+++ b/java/java.go
@@ -410,7 +410,7 @@ type sdkDep struct {
frameworkResModule string
jars android.Paths
- aidl android.Path
+ aidl android.OptionalPath
}
type jniLib struct {
@@ -534,7 +534,7 @@ func (j *Module) hasSrcExt(ext string) bool {
}
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
- aidlIncludeDirs android.Paths) []string {
+ aidlIncludeDirs android.Paths) (string, android.Paths) {
aidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Local_include_dirs)
aidlIncludes = append(aidlIncludes,
@@ -542,16 +542,24 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
aidlIncludes = append(aidlIncludes,
android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...)
- flags := []string{}
+ var flags []string
+ var deps android.Paths
if aidlPreprocess.Valid() {
flags = append(flags, "-p"+aidlPreprocess.String())
- } else {
+ deps = append(deps, aidlPreprocess.Path())
+ } else if len(aidlIncludeDirs) > 0 {
flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
}
- flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
- flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
+ if len(j.exportAidlIncludeDirs) > 0 {
+ flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
+ }
+
+ if len(aidlIncludes) > 0 {
+ flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
+ }
+
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
flags = append(flags, "-I"+src.String())
@@ -565,7 +573,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
flags = append(flags, "--transaction_names")
}
- return flags
+ return strings.Join(flags, " "), deps
}
type deps struct {
@@ -683,7 +691,9 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
} else if sdkDep.useFiles {
// sdkDep.jar is actually equivalent to turbine header.jar.
deps.classpath = append(deps.classpath, sdkDep.jars...)
- deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
+ deps.aidlPreprocess = sdkDep.aidl
+ } else {
+ deps.aidlPreprocess = sdkDep.aidl
}
}
@@ -724,6 +734,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
// sdk lib names from dependencies are re-exported
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
+ deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
case staticLibTag:
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
@@ -731,6 +742,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
// sdk lib names from dependencies are re-exported
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
+ deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
case pluginTag:
if plugin, ok := dep.(*Plugin); ok {
deps.processorPath = append(deps.processorPath, dep.ImplementationAndResourcesJars()...)
@@ -765,7 +777,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.kotlinAnnotations = dep.HeaderJars()
}
- deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
case android.SourceFileProducer:
switch tag {
case libTag:
@@ -806,7 +817,7 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
v := sdkContext.sdkVersion()
// For PDK builds, use the latest SDK version instead of "current"
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
- sdkVersions := ctx.Config().Get(sdkSingletonKey).([]int)
+ sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
latestSdkVersion := 0
if len(sdkVersions) > 0 {
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
@@ -919,12 +930,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
}
// aidl flags.
- aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
- if len(aidlFlags) > 0 {
- // optimization.
- ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
- flags.aidlFlags = "$aidlFlags"
- }
+ flags.aidlFlags, flags.aidlDeps = j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
if len(javacFlags) > 0 {
// optimization.
diff --git a/java/java_test.go b/java/java_test.go
index 41586217..c1488075 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -97,7 +97,7 @@ func testContext(config android.Config, bp string,
ctx.TopDown("java_sdk_library", SdkLibraryMutator).Parallel()
})
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(OverlaySingletonFactory))
- ctx.RegisterPreSingletonType("sdk", android.SingletonFactoryAdaptor(sdkSingletonFactory))
+ ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))
// Register module types and mutators from cc needed for JNI testing
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
@@ -131,6 +131,7 @@ func testContext(config android.Config, bp string,
"api/system-removed.txt": nil,
"api/test-current.txt": nil,
"api/test-removed.txt": nil,
+ "framework/aidl/a.aidl": nil,
"prebuilts/sdk/14/public/android.jar": nil,
"prebuilts/sdk/14/public/framework.aidl": nil,
diff --git a/java/sdk.go b/java/sdk.go
index 48e77465..36010b6f 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -19,16 +19,23 @@ import (
"android/soong/java/config"
"fmt"
"path/filepath"
+ "runtime"
"sort"
"strconv"
"strings"
+
+ "github.com/google/blueprint/pathtools"
)
func init() {
- android.RegisterPreSingletonType("sdk", sdkSingletonFactory)
+ android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
+ android.RegisterSingletonType("sdk", sdkSingletonFactory)
+ android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
}
-var sdkSingletonKey = android.NewOnceKey("sdkSingletonKey")
+var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey")
+var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
+var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
type sdkContext interface {
// sdkVersion eturns the sdk_version property of the current module, or an empty string if it is not set.
@@ -76,7 +83,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
v := sdkContext.sdkVersion()
// For PDK builds, use the latest SDK version instead of "current"
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
- sdkVersions := ctx.Config().Get(sdkSingletonKey).([]int)
+ sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
latestSdkVersion := 0
if len(sdkVersions) > 0 {
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
@@ -130,17 +137,19 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
return sdkDep{
useFiles: true,
jars: android.Paths{jarPath.Path(), lambdaStubsPath},
- aidl: aidlPath.Path(),
+ aidl: android.OptionalPathForPath(aidlPath.Path()),
}
}
- toModule := func(m, r string) sdkDep {
+ toModule := func(m, r string, aidl android.Path) sdkDep {
ret := sdkDep{
useModule: true,
modules: []string{m, config.DefaultLambdaStubsLibrary},
systemModules: m + "_system_modules",
frameworkResModule: r,
+ aidl: android.OptionalPathForPath(aidl),
}
+
if m == "core.current.stubs" {
ret.systemModules = "core-system-modules"
} else if m == "core.platform.api.stubs" {
@@ -164,7 +173,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
}
}
- if ctx.Config().UnbundledBuildPrebuiltSdks() && v != "" {
+ if ctx.Config().UnbundledBuildUsePrebuiltSdks() && v != "" {
return toPrebuilt(v)
}
@@ -175,25 +184,25 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
frameworkResModule: "framework-res",
}
case "current":
- return toModule("android_stubs_current", "framework-res")
+ return toModule("android_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
case "system_current":
- return toModule("android_system_stubs_current", "framework-res")
+ return toModule("android_system_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
case "test_current":
- return toModule("android_test_stubs_current", "framework-res")
+ return toModule("android_test_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
case "core_current":
- return toModule("core.current.stubs", "")
+ return toModule("core.current.stubs", "", nil)
default:
return toPrebuilt(v)
}
}
-func sdkSingletonFactory() android.Singleton {
- return sdkSingleton{}
+func sdkPreSingletonFactory() android.Singleton {
+ return sdkPreSingleton{}
}
-type sdkSingleton struct{}
+type sdkPreSingleton struct{}
-func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+func (sdkPreSingleton) GenerateBuildActions(ctx android.SingletonContext) {
sdkJars, err := ctx.GlobWithDeps("prebuilts/sdk/*/public/android.jar", nil)
if err != nil {
ctx.Errorf("failed to glob prebuilts/sdk/*/public/android.jar: %s", err.Error())
@@ -213,5 +222,154 @@ func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
sort.Ints(sdkVersions)
- ctx.Config().Once(sdkSingletonKey, func() interface{} { return sdkVersions })
+ ctx.Config().Once(sdkVersionsKey, func() interface{} { return sdkVersions })
+}
+
+func sdkSingletonFactory() android.Singleton {
+ return sdkSingleton{}
+}
+
+type sdkSingleton struct{}
+
+func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+ if ctx.Config().UnbundledBuildUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
+ return
+ }
+
+ 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{
+ "android_stubs_current",
+ "android_test_stubs_current",
+ "android_system_stubs_current",
+ }
+
+ stubsJars := make([]android.Paths, len(stubsModules))
+
+ ctx.VisitAllModules(func(module android.Module) {
+ // Collect dex jar paths for the modules listed above.
+ if j, ok := module.(Dependency); ok {
+ name := ctx.ModuleName(module)
+ if i := android.IndexList(name, stubsModules); i != -1 {
+ stubsJars[i] = j.HeaderJars()
+ }
+ }
+ })
+
+ var missingDeps []string
+
+ for i := range stubsJars {
+ if stubsJars[i] == nil {
+ if ctx.Config().AllowMissingDependencies() {
+ missingDeps = append(missingDeps, stubsModules[i])
+ } else {
+ ctx.Errorf("failed to find dex jar path for module %q",
+ stubsModules[i])
+ }
+ }
+ }
+
+ rule := android.NewRuleBuilder()
+ rule.MissingDeps(missingDeps)
+
+ var aidls android.Paths
+ for _, jars := range stubsJars {
+ for _, jar := range jars {
+ aidl := android.PathForOutput(ctx, "aidl", pathtools.ReplaceExtension(jar.Base(), "aidl"))
+
+ rule.Command().
+ Text("rm -f").Output(aidl)
+ rule.Command().
+ Tool(ctx.Config().HostToolPath(ctx, "sdkparcelables")).
+ Input(jar).
+ Output(aidl)
+
+ aidls = append(aidls, aidl)
+ }
+ }
+
+ combinedAidl := sdkFrameworkAidlPath(ctx)
+ tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp")
+
+ rule.Command().
+ Text("rm -f").Output(tempPath)
+ rule.Command().
+ Text("cat").
+ Inputs(aidls).
+ Text("| sort -u >").
+ Output(tempPath)
+
+ commitChangeForRestat(rule, tempPath, combinedAidl)
+
+ rule.Build(pctx, ctx, "framework_aidl", "generate framework.aidl")
+}
+
+func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath {
+ return ctx.Config().Once(sdkFrameworkAidlPathKey, func() interface{} {
+ return android.PathForOutput(ctx, "framework.aidl")
+ }).(android.OutputPath)
+}
+
+// Create api_fingerprint.txt
+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
+ }
+
+ ctx.Strict("FRAMEWORK_AIDL", sdkFrameworkAidlPath(ctx).String())
+ ctx.Strict("API_FINGERPRINT", apiFingerprintPath(ctx).String())
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 72cce579..dc7da334 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -409,7 +409,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.TopDownMutatorContext,
props.Sdk_version = proptools.StringPtr(module.sdkVersion(apiScope))
props.Libs = module.sdkLibraryProperties.Stub_only_libs
// 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.Pdk.Enabled = proptools.BoolPtr(false)
@@ -619,7 +619,7 @@ func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion strin
// to satisfy SdkLibraryDependency interface
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
// This module is just a wrapper for the stubs.
- if ctx.Config().UnbundledBuildPrebuiltSdks() {
+ if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
return module.PrebuiltJars(ctx, sdkVersion)
} else {
if strings.HasPrefix(sdkVersion, "system_") {
@@ -635,7 +635,7 @@ func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion stri
// to satisfy SdkLibraryDependency interface
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
// This module is just a wrapper for the stubs.
- if ctx.Config().UnbundledBuildPrebuiltSdks() {
+ if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
return module.PrebuiltJars(ctx, sdkVersion)
} else {
if strings.HasPrefix(sdkVersion, "system_") {
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 8ac10baa..e446129a 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -15,174 +15,189 @@
package java
import (
- "android/soong/android"
"path/filepath"
"reflect"
"strings"
"testing"
"github.com/google/blueprint/proptools"
-)
-var classpathTestcases = []struct {
- name string
- unbundled bool
- pdk bool
- moduleType string
- host android.OsClass
- properties string
- bootclasspath []string
- system string
- classpath []string
-}{
- {
- name: "default",
- bootclasspath: []string{"core.platform.api.stubs", "core-lambda-stubs"},
- system: "core-platform-api-stubs-system-modules",
- classpath: []string{"ext", "framework", "updatable_media_stubs"},
- },
- {
- name: "blank sdk version",
- properties: `sdk_version: "",`,
- bootclasspath: []string{"core.platform.api.stubs", "core-lambda-stubs"},
- system: "core-platform-api-stubs-system-modules",
- classpath: []string{"ext", "framework", "updatable_media_stubs"},
- },
- {
-
- name: "sdk v25",
- properties: `sdk_version: "25",`,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
- {
-
- name: "current",
- properties: `sdk_version: "current",`,
- bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- },
- {
-
- name: "system_current",
- properties: `sdk_version: "system_current",`,
- bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- },
- {
-
- name: "system_25",
- properties: `sdk_version: "system_25",`,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
- {
-
- name: "test_current",
- properties: `sdk_version: "test_current",`,
- bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- },
- {
-
- name: "core_current",
- properties: `sdk_version: "core_current",`,
- bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- },
- {
-
- name: "nostdlib",
- properties: `no_standard_libs: true, system_modules: "none"`,
- system: "none",
- bootclasspath: []string{`""`},
- classpath: []string{},
- },
- {
-
- name: "nostdlib system_modules",
- properties: `no_standard_libs: true, system_modules: "core-platform-api-stubs-system-modules"`,
- system: "core-platform-api-stubs-system-modules",
- bootclasspath: []string{`""`},
- classpath: []string{},
- },
- {
-
- name: "host default",
- moduleType: "java_library_host",
- properties: ``,
- host: android.Host,
- bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
- classpath: []string{},
- },
- {
- name: "host nostdlib",
- moduleType: "java_library_host",
- host: android.Host,
- properties: `no_standard_libs: true`,
- classpath: []string{},
- },
- {
-
- name: "host supported default",
- host: android.Host,
- properties: `host_supported: true,`,
- classpath: []string{},
- bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
- },
- {
- name: "host supported nostdlib",
- host: android.Host,
- properties: `host_supported: true, no_standard_libs: true, system_modules: "none"`,
- classpath: []string{},
- },
- {
-
- name: "unbundled sdk v25",
- unbundled: true,
- properties: `sdk_version: "25",`,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
- {
-
- name: "unbundled current",
- unbundled: true,
- properties: `sdk_version: "current",`,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
-
- {
- name: "pdk default",
- pdk: true,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
- {
- name: "pdk current",
- pdk: true,
- properties: `sdk_version: "current",`,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
- {
- name: "pdk 25",
- pdk: true,
- properties: `sdk_version: "25",`,
- bootclasspath: []string{`""`},
- system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
- classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
- },
-}
+ "android/soong/android"
+ "android/soong/java/config"
+)
func TestClasspath(t *testing.T) {
+ var classpathTestcases = []struct {
+ name string
+ unbundled bool
+ pdk bool
+ moduleType string
+ host android.OsClass
+ properties string
+ bootclasspath []string
+ system string
+ classpath []string
+ aidl string
+ }{
+ {
+ name: "default",
+ bootclasspath: config.DefaultBootclasspathLibraries,
+ system: config.DefaultSystemModules,
+ classpath: config.DefaultLibraries,
+ aidl: "-Iframework/aidl",
+ },
+ {
+ name: "blank sdk version",
+ properties: `sdk_version: "",`,
+ bootclasspath: config.DefaultBootclasspathLibraries,
+ system: config.DefaultSystemModules,
+ classpath: config.DefaultLibraries,
+ aidl: "-Iframework/aidl",
+ },
+ {
+
+ name: "sdk v25",
+ properties: `sdk_version: "25",`,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/25/public/framework.aidl",
+ },
+ {
+
+ name: "current",
+ properties: `sdk_version: "current",`,
+ bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ aidl: "-p" + buildDir + "/framework.aidl",
+ },
+ {
+
+ name: "system_current",
+ properties: `sdk_version: "system_current",`,
+ bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ aidl: "-p" + buildDir + "/framework.aidl",
+ },
+ {
+
+ name: "system_25",
+ properties: `sdk_version: "system_25",`,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/25/public/framework.aidl",
+ },
+ {
+
+ name: "test_current",
+ properties: `sdk_version: "test_current",`,
+ bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ aidl: "-p" + buildDir + "/framework.aidl",
+ },
+ {
+
+ name: "core_current",
+ properties: `sdk_version: "core_current",`,
+ bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ },
+ {
+
+ name: "nostdlib",
+ properties: `no_standard_libs: true, system_modules: "none"`,
+ system: "none",
+ bootclasspath: []string{`""`},
+ classpath: []string{},
+ },
+ {
+
+ name: "nostdlib system_modules",
+ properties: `no_standard_libs: true, system_modules: "core-platform-api-stubs-system-modules"`,
+ system: "core-platform-api-stubs-system-modules",
+ bootclasspath: []string{`""`},
+ classpath: []string{},
+ },
+ {
+
+ name: "host default",
+ moduleType: "java_library_host",
+ properties: ``,
+ host: android.Host,
+ bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
+ classpath: []string{},
+ },
+ {
+ name: "host nostdlib",
+ moduleType: "java_library_host",
+ host: android.Host,
+ properties: `no_standard_libs: true`,
+ classpath: []string{},
+ },
+ {
+
+ name: "host supported default",
+ host: android.Host,
+ properties: `host_supported: true,`,
+ classpath: []string{},
+ bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
+ },
+ {
+ name: "host supported nostdlib",
+ host: android.Host,
+ properties: `host_supported: true, no_standard_libs: true, system_modules: "none"`,
+ classpath: []string{},
+ },
+ {
+
+ name: "unbundled sdk v25",
+ unbundled: true,
+ properties: `sdk_version: "25",`,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/25/public/framework.aidl",
+ },
+ {
+
+ name: "unbundled current",
+ unbundled: true,
+ properties: `sdk_version: "current",`,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/current/public/framework.aidl",
+ },
+
+ {
+ name: "pdk default",
+ pdk: true,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/25/public/framework.aidl",
+ },
+ {
+ name: "pdk current",
+ pdk: true,
+ properties: `sdk_version: "current",`,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/25/public/framework.aidl",
+ },
+ {
+ name: "pdk 25",
+ pdk: true,
+ properties: `sdk_version: "25",`,
+ bootclasspath: []string{`""`},
+ system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
+ classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
+ aidl: "-pprebuilts/sdk/25/public/framework.aidl",
+ },
+ }
+
for _, testcase := range classpathTestcases {
t.Run(testcase.name, func(t *testing.T) {
moduleType := "java_library"
@@ -193,6 +208,11 @@ func TestClasspath(t *testing.T) {
bp := moduleType + ` {
name: "foo",
srcs: ["a.java"],
+ target: {
+ android: {
+ srcs: ["bar-doc/IFoo.aidl"],
+ },
+ },
` + testcase.properties + `
}`
@@ -228,18 +248,7 @@ func TestClasspath(t *testing.T) {
system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system") + "/"
}
- t.Run("1.8", func(t *testing.T) {
- // Test default javac 1.8
- config := testConfig(nil)
- if testcase.unbundled {
- config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
- }
- if testcase.pdk {
- config.TestProductVariables.Pdk = proptools.BoolPtr(true)
- }
- ctx := testContext(config, bp, nil)
- run(t, ctx, config)
-
+ checkClasspath := func(t *testing.T, ctx *android.TestContext) {
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
got := javac.Args["bootClasspath"]
@@ -261,6 +270,33 @@ func TestClasspath(t *testing.T) {
if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
}
+ }
+
+ t.Run("1.8", func(t *testing.T) {
+ // Test default javac 1.8
+ config := testConfig(nil)
+ if testcase.unbundled {
+ config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
+ }
+ if testcase.pdk {
+ config.TestProductVariables.Pdk = proptools.BoolPtr(true)
+ }
+ ctx := testContext(config, bp, nil)
+ run(t, ctx, config)
+
+ checkClasspath(t, ctx)
+
+ if testcase.host != android.Host {
+ aidl := ctx.ModuleForTests("foo", variant).Rule("aidl")
+
+ aidlFlags := aidl.Args["aidlFlags"]
+ // Trim trailing "-I." to avoid having to specify it in every test
+ aidlFlags = strings.TrimSpace(strings.TrimSuffix(aidlFlags, "-I."))
+
+ if g, w := aidlFlags, testcase.aidl; g != w {
+ t.Errorf("want aidl flags %q, got %q", w, g)
+ }
+ }
})
// Test again with javac 1.9
@@ -301,27 +337,7 @@ func TestClasspath(t *testing.T) {
ctx := testContext(config, bp, nil)
run(t, ctx, config)
- javac := ctx.ModuleForTests("foo", variant).Rule("javac")
-
- got := javac.Args["bootClasspath"]
- if got != bc {
- t.Errorf("bootclasspath expected %q != got %q", bc, got)
- }
-
- got = javac.Args["classpath"]
- if got != c {
- t.Errorf("classpath expected %q != got %q", c, got)
- }
-
- var deps []string
- if len(bootclasspath) > 0 && bootclasspath[0] != `""` {
- deps = append(deps, bootclasspath...)
- }
- deps = append(deps, classpath...)
-
- if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
- t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
- }
+ checkClasspath(t, ctx)
})
})
}
diff --git a/java/testing.go b/java/testing.go
index db06ae16..6b35bd04 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -37,7 +37,6 @@ func GatherRequiredDepsForTest() string {
extraModules := []string{
"core-lambda-stubs",
- "framework",
"ext",
"updatable_media_stubs",
"android_stubs_current",
@@ -62,6 +61,17 @@ func GatherRequiredDepsForTest() string {
}
bp += `
+ java_library {
+ name: "framework",
+ srcs: ["a.java"],
+ no_standard_libs: true,
+ sdk_version: "core_current",
+ system_modules: "core-platform-api-stubs-system-modules",
+ aidl: {
+ export_include_dirs: ["framework/aidl"],
+ },
+ }
+
android_app {
name: "framework-res",
no_framework_libs: true,
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index a7aff59e..07406b3c 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -106,6 +106,7 @@ func testContext(config android.Config, bp string,
"api/system-removed.txt": nil,
"api/test-current.txt": nil,
"api/test-removed.txt": nil,
+ "framework/aidl/a.aidl": nil,
"prebuilts/sdk/current/core/android.jar": nil,
"prebuilts/sdk/current/public/android.jar": nil,