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
This commit is contained in:
@@ -618,7 +618,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, " "),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@@ -154,6 +154,7 @@ type javaBuilderFlags struct {
|
|||||||
processor string
|
processor string
|
||||||
systemModules classpath
|
systemModules classpath
|
||||||
aidlFlags string
|
aidlFlags string
|
||||||
|
aidlDeps android.Paths
|
||||||
javaVersion string
|
javaVersion string
|
||||||
|
|
||||||
errorProneExtraJavacFlags string
|
errorProneExtraJavacFlags string
|
||||||
|
@@ -404,6 +404,7 @@ type droiddocBuilderFlags struct {
|
|||||||
sourcepathArgs string
|
sourcepathArgs string
|
||||||
dokkaClasspathArgs string
|
dokkaClasspathArgs string
|
||||||
aidlFlags string
|
aidlFlags string
|
||||||
|
aidlDeps android.Paths
|
||||||
|
|
||||||
doclavaStubsFlags string
|
doclavaStubsFlags string
|
||||||
doclavaDocsFlags 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 {
|
func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags {
|
||||||
var flags droiddocBuilderFlags
|
var flags droiddocBuilderFlags
|
||||||
|
|
||||||
// aidl flags.
|
flags.aidlFlags, flags.aidlDeps = j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
||||||
aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
|
||||||
if len(aidlFlags) > 0 {
|
|
||||||
// optimization.
|
|
||||||
ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
|
|
||||||
flags.aidlFlags = "$aidlFlags"
|
|
||||||
}
|
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
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 := android.PathsForModuleSrc(ctx, j.properties.Aidl.Local_include_dirs)
|
||||||
aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...)
|
aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...)
|
||||||
|
|
||||||
var flags []string
|
var flags []string
|
||||||
|
var deps android.Paths
|
||||||
|
|
||||||
if aidlPreprocess.Valid() {
|
if aidlPreprocess.Valid() {
|
||||||
flags = append(flags, "-p"+aidlPreprocess.String())
|
flags = append(flags, "-p"+aidlPreprocess.String())
|
||||||
|
deps = append(deps, aidlPreprocess.Path())
|
||||||
} else {
|
} else {
|
||||||
flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
|
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())
|
flags = append(flags, "-I"+src.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags
|
return strings.Join(flags, " "), deps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
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 {
|
for _, srcFile := range srcFiles {
|
||||||
switch srcFile.Ext() {
|
switch srcFile.Ext() {
|
||||||
case ".aidl":
|
case ".aidl":
|
||||||
javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
|
javaFile := genAidl(ctx, srcFile, flags.aidlFlags, flags.aidlDeps)
|
||||||
outSrcFiles = append(outSrcFiles, javaFile)
|
outSrcFiles = append(outSrcFiles, javaFile)
|
||||||
case ".sysprop":
|
case ".sysprop":
|
||||||
javaFile := genSysprop(ctx, srcFile)
|
javaFile := genSysprop(ctx, srcFile)
|
||||||
|
@@ -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")
|
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
|
||||||
depFile := javaFile.String() + ".d"
|
depFile := javaFile.String() + ".d"
|
||||||
|
|
||||||
@@ -68,6 +68,7 @@ func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string)
|
|||||||
Description: "aidl " + aidlFile.Rel(),
|
Description: "aidl " + aidlFile.Rel(),
|
||||||
Output: javaFile,
|
Output: javaFile,
|
||||||
Input: aidlFile,
|
Input: aidlFile,
|
||||||
|
Implicits: deps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"depFile": depFile,
|
"depFile": depFile,
|
||||||
"aidlFlags": aidlFlags,
|
"aidlFlags": aidlFlags,
|
||||||
@@ -111,7 +112,7 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
|||||||
for _, srcFile := range srcFiles {
|
for _, srcFile := range srcFiles {
|
||||||
switch srcFile.Ext() {
|
switch srcFile.Ext() {
|
||||||
case ".aidl":
|
case ".aidl":
|
||||||
javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
|
javaFile := genAidl(ctx, srcFile, flags.aidlFlags, flags.aidlDeps)
|
||||||
outSrcFiles = append(outSrcFiles, javaFile)
|
outSrcFiles = append(outSrcFiles, javaFile)
|
||||||
case ".logtags":
|
case ".logtags":
|
||||||
j.logtagsSrcs = append(j.logtagsSrcs, srcFile)
|
j.logtagsSrcs = append(j.logtagsSrcs, srcFile)
|
||||||
|
34
java/java.go
34
java/java.go
@@ -410,7 +410,7 @@ type sdkDep struct {
|
|||||||
frameworkResModule string
|
frameworkResModule string
|
||||||
|
|
||||||
jars android.Paths
|
jars android.Paths
|
||||||
aidl android.Path
|
aidl android.OptionalPath
|
||||||
}
|
}
|
||||||
|
|
||||||
type jniLib struct {
|
type jniLib struct {
|
||||||
@@ -534,7 +534,7 @@ func (j *Module) hasSrcExt(ext string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
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 := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Local_include_dirs)
|
||||||
aidlIncludes = append(aidlIncludes,
|
aidlIncludes = append(aidlIncludes,
|
||||||
@@ -542,16 +542,24 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
|
|||||||
aidlIncludes = append(aidlIncludes,
|
aidlIncludes = append(aidlIncludes,
|
||||||
android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...)
|
android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...)
|
||||||
|
|
||||||
flags := []string{}
|
var flags []string
|
||||||
|
var deps android.Paths
|
||||||
|
|
||||||
if aidlPreprocess.Valid() {
|
if aidlPreprocess.Valid() {
|
||||||
flags = append(flags, "-p"+aidlPreprocess.String())
|
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(aidlIncludeDirs.Strings(), "-I"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(j.exportAidlIncludeDirs) > 0 {
|
||||||
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(aidlIncludes) > 0 {
|
||||||
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
|
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
|
||||||
|
}
|
||||||
|
|
||||||
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
||||||
if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
|
if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
|
||||||
flags = append(flags, "-I"+src.String())
|
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")
|
flags = append(flags, "--transaction_names")
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags
|
return strings.Join(flags, " "), deps
|
||||||
}
|
}
|
||||||
|
|
||||||
type deps struct {
|
type deps struct {
|
||||||
@@ -683,7 +691,9 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
} else if sdkDep.useFiles {
|
} else if sdkDep.useFiles {
|
||||||
// sdkDep.jar is actually equivalent to turbine header.jar.
|
// sdkDep.jar is actually equivalent to turbine header.jar.
|
||||||
deps.classpath = append(deps.classpath, sdkDep.jars...)
|
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()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
||||||
// sdk lib names from dependencies are re-exported
|
// sdk lib names from dependencies are re-exported
|
||||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
||||||
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||||
case staticLibTag:
|
case staticLibTag:
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
||||||
deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
|
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()...)
|
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
|
||||||
// sdk lib names from dependencies are re-exported
|
// sdk lib names from dependencies are re-exported
|
||||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
||||||
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||||
case pluginTag:
|
case pluginTag:
|
||||||
if plugin, ok := dep.(*Plugin); ok {
|
if plugin, ok := dep.(*Plugin); ok {
|
||||||
deps.processorPath = append(deps.processorPath, dep.ImplementationAndResourcesJars()...)
|
deps.processorPath = append(deps.processorPath, dep.ImplementationAndResourcesJars()...)
|
||||||
@@ -765,7 +777,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
deps.kotlinAnnotations = dep.HeaderJars()
|
deps.kotlinAnnotations = dep.HeaderJars()
|
||||||
}
|
}
|
||||||
|
|
||||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
|
||||||
case android.SourceFileProducer:
|
case android.SourceFileProducer:
|
||||||
switch tag {
|
switch tag {
|
||||||
case libTag:
|
case libTag:
|
||||||
@@ -806,7 +817,7 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
|
|||||||
v := sdkContext.sdkVersion()
|
v := sdkContext.sdkVersion()
|
||||||
// For PDK builds, use the latest SDK version instead of "current"
|
// For PDK builds, use the latest SDK version instead of "current"
|
||||||
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
|
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
|
||||||
sdkVersions := ctx.Config().Get(sdkSingletonKey).([]int)
|
sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
|
||||||
latestSdkVersion := 0
|
latestSdkVersion := 0
|
||||||
if len(sdkVersions) > 0 {
|
if len(sdkVersions) > 0 {
|
||||||
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
|
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
|
||||||
@@ -919,12 +930,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// aidl flags.
|
// aidl flags.
|
||||||
aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
flags.aidlFlags, flags.aidlDeps = j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
||||||
if len(aidlFlags) > 0 {
|
|
||||||
// optimization.
|
|
||||||
ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
|
|
||||||
flags.aidlFlags = "$aidlFlags"
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(javacFlags) > 0 {
|
if len(javacFlags) > 0 {
|
||||||
// optimization.
|
// optimization.
|
||||||
|
@@ -97,7 +97,7 @@ func testContext(config android.Config, bp string,
|
|||||||
ctx.TopDown("java_sdk_library", SdkLibraryMutator).Parallel()
|
ctx.TopDown("java_sdk_library", SdkLibraryMutator).Parallel()
|
||||||
})
|
})
|
||||||
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(OverlaySingletonFactory))
|
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
|
// Register module types and mutators from cc needed for JNI testing
|
||||||
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
|
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/system-removed.txt": nil,
|
||||||
"api/test-current.txt": nil,
|
"api/test-current.txt": nil,
|
||||||
"api/test-removed.txt": nil,
|
"api/test-removed.txt": nil,
|
||||||
|
"framework/aidl/a.aidl": nil,
|
||||||
|
|
||||||
"prebuilts/sdk/14/public/android.jar": nil,
|
"prebuilts/sdk/14/public/android.jar": nil,
|
||||||
"prebuilts/sdk/14/public/framework.aidl": nil,
|
"prebuilts/sdk/14/public/framework.aidl": nil,
|
||||||
|
188
java/sdk.go
188
java/sdk.go
@@ -19,16 +19,23 @@ import (
|
|||||||
"android/soong/java/config"
|
"android/soong/java/config"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/blueprint/pathtools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
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 {
|
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.
|
||||||
@@ -76,7 +83,7 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
|
|||||||
v := sdkContext.sdkVersion()
|
v := sdkContext.sdkVersion()
|
||||||
// For PDK builds, use the latest SDK version instead of "current"
|
// For PDK builds, use the latest SDK version instead of "current"
|
||||||
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
|
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
|
||||||
sdkVersions := ctx.Config().Get(sdkSingletonKey).([]int)
|
sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
|
||||||
latestSdkVersion := 0
|
latestSdkVersion := 0
|
||||||
if len(sdkVersions) > 0 {
|
if len(sdkVersions) > 0 {
|
||||||
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
|
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
|
||||||
@@ -130,17 +137,19 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
|
|||||||
return sdkDep{
|
return sdkDep{
|
||||||
useFiles: true,
|
useFiles: true,
|
||||||
jars: android.Paths{jarPath.Path(), lambdaStubsPath},
|
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{
|
ret := sdkDep{
|
||||||
useModule: true,
|
useModule: true,
|
||||||
modules: []string{m, config.DefaultLambdaStubsLibrary},
|
modules: []string{m, config.DefaultLambdaStubsLibrary},
|
||||||
systemModules: m + "_system_modules",
|
systemModules: m + "_system_modules",
|
||||||
frameworkResModule: r,
|
frameworkResModule: r,
|
||||||
|
aidl: android.OptionalPathForPath(aidl),
|
||||||
}
|
}
|
||||||
|
|
||||||
if m == "core.current.stubs" {
|
if m == "core.current.stubs" {
|
||||||
ret.systemModules = "core-system-modules"
|
ret.systemModules = "core-system-modules"
|
||||||
} else if m == "core.platform.api.stubs" {
|
} 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)
|
return toPrebuilt(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,25 +184,25 @@ func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
|
|||||||
frameworkResModule: "framework-res",
|
frameworkResModule: "framework-res",
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
return toModule("android_stubs_current", "framework-res")
|
return toModule("android_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
|
||||||
case "system_current":
|
case "system_current":
|
||||||
return toModule("android_system_stubs_current", "framework-res")
|
return toModule("android_system_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
|
||||||
case "test_current":
|
case "test_current":
|
||||||
return toModule("android_test_stubs_current", "framework-res")
|
return toModule("android_test_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
|
||||||
case "core_current":
|
case "core_current":
|
||||||
return toModule("core.current.stubs", "")
|
return toModule("core.current.stubs", "", nil)
|
||||||
default:
|
default:
|
||||||
return toPrebuilt(v)
|
return toPrebuilt(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkSingletonFactory() android.Singleton {
|
func sdkPreSingletonFactory() android.Singleton {
|
||||||
return sdkSingleton{}
|
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)
|
sdkJars, err := ctx.GlobWithDeps("prebuilts/sdk/*/public/android.jar", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Errorf("failed to glob prebuilts/sdk/*/public/android.jar: %s", err.Error())
|
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)
|
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())
|
||||||
}
|
}
|
||||||
|
@@ -409,7 +409,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.TopDownMutatorContext,
|
|||||||
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)
|
||||||
@@ -619,7 +619,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_") {
|
||||||
@@ -635,7 +635,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_") {
|
||||||
|
104
java/sdk_test.go
104
java/sdk_test.go
@@ -15,16 +15,19 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
|
"android/soong/java/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var classpathTestcases = []struct {
|
func TestClasspath(t *testing.T) {
|
||||||
|
var classpathTestcases = []struct {
|
||||||
name string
|
name string
|
||||||
unbundled bool
|
unbundled bool
|
||||||
pdk bool
|
pdk bool
|
||||||
@@ -34,19 +37,22 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath []string
|
bootclasspath []string
|
||||||
system string
|
system string
|
||||||
classpath []string
|
classpath []string
|
||||||
}{
|
aidl string
|
||||||
|
}{
|
||||||
{
|
{
|
||||||
name: "default",
|
name: "default",
|
||||||
bootclasspath: []string{"core.platform.api.stubs", "core-lambda-stubs"},
|
bootclasspath: config.DefaultBootclasspathLibraries,
|
||||||
system: "core-platform-api-stubs-system-modules",
|
system: config.DefaultSystemModules,
|
||||||
classpath: []string{"ext", "framework", "updatable_media_stubs"},
|
classpath: config.DefaultLibraries,
|
||||||
|
aidl: "-Iframework/aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "blank sdk version",
|
name: "blank sdk version",
|
||||||
properties: `sdk_version: "",`,
|
properties: `sdk_version: "",`,
|
||||||
bootclasspath: []string{"core.platform.api.stubs", "core-lambda-stubs"},
|
bootclasspath: config.DefaultBootclasspathLibraries,
|
||||||
system: "core-platform-api-stubs-system-modules",
|
system: config.DefaultSystemModules,
|
||||||
classpath: []string{"ext", "framework", "updatable_media_stubs"},
|
classpath: config.DefaultLibraries,
|
||||||
|
aidl: "-Iframework/aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -55,6 +61,7 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -62,6 +69,7 @@ var classpathTestcases = []struct {
|
|||||||
properties: `sdk_version: "current",`,
|
properties: `sdk_version: "current",`,
|
||||||
bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
|
bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
|
aidl: "-p" + buildDir + "/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -69,6 +77,7 @@ var classpathTestcases = []struct {
|
|||||||
properties: `sdk_version: "system_current",`,
|
properties: `sdk_version: "system_current",`,
|
||||||
bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
|
bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
|
aidl: "-p" + buildDir + "/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -77,6 +86,7 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -84,6 +94,7 @@ var classpathTestcases = []struct {
|
|||||||
properties: `sdk_version: "test_current",`,
|
properties: `sdk_version: "test_current",`,
|
||||||
bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
|
bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
||||||
|
aidl: "-p" + buildDir + "/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -146,6 +157,7 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -155,6 +167,7 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -163,6 +176,7 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
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",
|
name: "pdk current",
|
||||||
@@ -171,6 +185,7 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
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",
|
name: "pdk 25",
|
||||||
@@ -179,10 +194,10 @@ var classpathTestcases = []struct {
|
|||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
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"},
|
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
|
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClasspath(t *testing.T) {
|
|
||||||
for _, testcase := range classpathTestcases {
|
for _, testcase := range classpathTestcases {
|
||||||
t.Run(testcase.name, func(t *testing.T) {
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
moduleType := "java_library"
|
moduleType := "java_library"
|
||||||
@@ -193,6 +208,11 @@ func TestClasspath(t *testing.T) {
|
|||||||
bp := moduleType + ` {
|
bp := moduleType + ` {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
srcs: ["bar-doc/IFoo.aidl"],
|
||||||
|
},
|
||||||
|
},
|
||||||
` + testcase.properties + `
|
` + testcase.properties + `
|
||||||
}`
|
}`
|
||||||
|
|
||||||
@@ -228,18 +248,7 @@ func TestClasspath(t *testing.T) {
|
|||||||
system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system") + "/"
|
system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system") + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("1.8", func(t *testing.T) {
|
checkClasspath := func(t *testing.T, ctx *android.TestContext) {
|
||||||
// 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)
|
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
||||||
|
|
||||||
got := javac.Args["bootClasspath"]
|
got := javac.Args["bootClasspath"]
|
||||||
@@ -261,6 +270,33 @@ func TestClasspath(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
|
if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
|
||||||
t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
|
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
|
// Test again with javac 1.9
|
||||||
@@ -301,27 +337,7 @@ func TestClasspath(t *testing.T) {
|
|||||||
ctx := testContext(config, bp, nil)
|
ctx := testContext(config, bp, nil)
|
||||||
run(t, ctx, config)
|
run(t, ctx, config)
|
||||||
|
|
||||||
javac := ctx.ModuleForTests("foo", variant).Rule("javac")
|
checkClasspath(t, ctx)
|
||||||
|
|
||||||
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())
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,6 @@ func GatherRequiredDepsForTest() string {
|
|||||||
|
|
||||||
extraModules := []string{
|
extraModules := []string{
|
||||||
"core-lambda-stubs",
|
"core-lambda-stubs",
|
||||||
"framework",
|
|
||||||
"ext",
|
"ext",
|
||||||
"updatable_media_stubs",
|
"updatable_media_stubs",
|
||||||
"android_stubs_current",
|
"android_stubs_current",
|
||||||
@@ -62,6 +61,17 @@ func GatherRequiredDepsForTest() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bp += `
|
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 {
|
android_app {
|
||||||
name: "framework-res",
|
name: "framework-res",
|
||||||
no_framework_libs: true,
|
no_framework_libs: true,
|
||||||
|
@@ -106,6 +106,7 @@ func testContext(config android.Config, bp string,
|
|||||||
"api/system-removed.txt": nil,
|
"api/system-removed.txt": nil,
|
||||||
"api/test-current.txt": nil,
|
"api/test-current.txt": nil,
|
||||||
"api/test-removed.txt": nil,
|
"api/test-removed.txt": nil,
|
||||||
|
"framework/aidl/a.aidl": nil,
|
||||||
|
|
||||||
"prebuilts/sdk/current/core/android.jar": nil,
|
"prebuilts/sdk/current/core/android.jar": nil,
|
||||||
"prebuilts/sdk/current/public/android.jar": nil,
|
"prebuilts/sdk/current/public/android.jar": nil,
|
||||||
|
Reference in New Issue
Block a user