Rename common to android
Rename the "common" package to "android", because common is too generic. Also removes all android.Android naming stutter. Ran: gomvpkg -from 'android/soong/common' -to 'android/soong/android' gorename -from '"android/soong/android".AndroidModuleContext' -to 'ModuleContext' gorename -from '"android/soong/android".AndroidBaseContext' -to 'BaseContext' gorename -from '"android/soong/android".AndroidModuleBase' -to 'ModuleBase' gorename -from '"android/soong/android".AndroidBottomUpMutatorContext' -to 'BottomUpMutatorContext' gorename -from '"android/soong/android".AndroidTopDownMutatorContext' -to 'TopDownMutatorContext' gorename -from '"android/soong/android".AndroidModule' -to 'Module' Change-Id: I3b23590b8ce7c8a1ea1139411d84a53163288da7
This commit is contained in:
@@ -17,17 +17,17 @@ package java
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
func (*JavaLibrary) AndroidMk() (ret common.AndroidMkData, err error) {
|
||||
func (*JavaLibrary) AndroidMk() (ret android.AndroidMkData, err error) {
|
||||
ret.Class = "JAVA_LIBRARIES"
|
||||
// TODO
|
||||
err = fmt.Errorf("Not yet implemented")
|
||||
return
|
||||
}
|
||||
|
||||
func (*JavaPrebuilt) AndroidMk() (ret common.AndroidMkData, err error) {
|
||||
func (*JavaPrebuilt) AndroidMk() (ret android.AndroidMkData, err error) {
|
||||
ret.Class = "JAVA_LIBRARIES"
|
||||
// TODO
|
||||
err = fmt.Errorf("Not yet implemented")
|
||||
|
38
java/app.go
38
java/app.go
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
// AAR prebuilts
|
||||
@@ -61,8 +61,8 @@ type AndroidApp struct {
|
||||
|
||||
appProperties androidAppProperties
|
||||
|
||||
aaptJavaFileList common.Path
|
||||
exportPackage common.Path
|
||||
aaptJavaFileList android.Path
|
||||
exportPackage android.Path
|
||||
}
|
||||
|
||||
func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string {
|
||||
@@ -80,7 +80,7 @@ func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string {
|
||||
return deps
|
||||
}
|
||||
|
||||
func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (a *AndroidApp) GenerateJavaBuildActions(ctx android.ModuleContext) {
|
||||
aaptFlags, aaptDeps, hasResources := a.aaptFlags(ctx)
|
||||
|
||||
if hasResources {
|
||||
@@ -143,16 +143,16 @@ func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
} else if dir, _ := filepath.Split(certificate); dir == "" {
|
||||
certificate = filepath.Join(ctx.AConfig().DefaultAppCertificateDir(ctx).String(), certificate)
|
||||
} else {
|
||||
certificate = filepath.Join(common.PathForSource(ctx).String(), certificate)
|
||||
certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
|
||||
}
|
||||
|
||||
certificates := []string{certificate}
|
||||
for _, c := range a.appProperties.Additional_certificates {
|
||||
certificates = append(certificates, filepath.Join(common.PathForSource(ctx).String(), c))
|
||||
certificates = append(certificates, filepath.Join(android.PathForSource(ctx).String(), c))
|
||||
}
|
||||
|
||||
a.outputFile = CreateAppPackage(ctx, aaptPackageFlags, a.outputFile, certificates)
|
||||
ctx.InstallFileName(common.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
|
||||
ctx.InstallFileName(android.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
|
||||
}
|
||||
|
||||
var aaptIgnoreFilenames = []string{
|
||||
@@ -167,7 +167,7 @@ var aaptIgnoreFilenames = []string{
|
||||
"*~",
|
||||
}
|
||||
|
||||
func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, common.Paths, bool) {
|
||||
func (a *AndroidApp) aaptFlags(ctx android.ModuleContext) ([]string, android.Paths, bool) {
|
||||
aaptFlags := a.appProperties.Aaptflags
|
||||
hasVersionCode := false
|
||||
hasVersionName := false
|
||||
@@ -183,10 +183,10 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
|
||||
aaptFlags = append(aaptFlags, "-z")
|
||||
}
|
||||
|
||||
assetDirs := common.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets")
|
||||
resourceDirs := common.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Android_resource_dirs, "res")
|
||||
assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets")
|
||||
resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Android_resource_dirs, "res")
|
||||
|
||||
var overlayResourceDirs common.Paths
|
||||
var overlayResourceDirs android.Paths
|
||||
// For every resource directory, check if there is an overlay directory with the same path.
|
||||
// If found, it will be prepended to the list of resource directories.
|
||||
for _, overlayDir := range ctx.AConfig().ResourceOverlays() {
|
||||
@@ -204,7 +204,7 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
|
||||
|
||||
// aapt needs to rerun if any files are added or modified in the assets or resource directories,
|
||||
// use glob to create a filelist.
|
||||
var aaptDeps common.Paths
|
||||
var aaptDeps android.Paths
|
||||
var hasResources bool
|
||||
for _, d := range resourceDirs {
|
||||
newDeps := ctx.Glob("app_resources", filepath.Join(d.String(), "**/*"), aaptIgnoreFilenames)
|
||||
@@ -225,20 +225,20 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
|
||||
manifestFile = *a.properties.Manifest
|
||||
}
|
||||
|
||||
manifestPath := common.PathForModuleSrc(ctx, manifestFile)
|
||||
manifestPath := android.PathForModuleSrc(ctx, manifestFile)
|
||||
aaptDeps = append(aaptDeps, manifestPath)
|
||||
|
||||
aaptFlags = append(aaptFlags, "-M "+manifestPath.String())
|
||||
aaptFlags = append(aaptFlags, common.JoinWithPrefix(assetDirs.Strings(), "-A "))
|
||||
aaptFlags = append(aaptFlags, common.JoinWithPrefix(resourceDirs.Strings(), "-S "))
|
||||
aaptFlags = append(aaptFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
|
||||
aaptFlags = append(aaptFlags, android.JoinWithPrefix(resourceDirs.Strings(), "-S "))
|
||||
|
||||
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
||||
var depFile common.OptionalPath
|
||||
var depFile android.OptionalPath
|
||||
if sdkDep, ok := module.(sdkDependency); ok {
|
||||
depFile = common.OptionalPathForPath(sdkDep.ClasspathFile())
|
||||
depFile = android.OptionalPathForPath(sdkDep.ClasspathFile())
|
||||
} else if javaDep, ok := module.(JavaDependency); ok {
|
||||
if ctx.OtherModuleName(module) == "framework-res" {
|
||||
depFile = common.OptionalPathForPath(javaDep.(*javaBase).module.(*AndroidApp).exportPackage)
|
||||
depFile = android.OptionalPathForPath(javaDep.(*javaBase).module.(*AndroidApp).exportPackage)
|
||||
}
|
||||
}
|
||||
if depFile.Valid() {
|
||||
@@ -278,5 +278,5 @@ func AndroidAppFactory() (blueprint.Module, []interface{}) {
|
||||
|
||||
module.properties.Dex = true
|
||||
|
||||
return NewJavaBase(&module.javaBase, module, common.DeviceSupported, &module.appProperties)
|
||||
return NewJavaBase(&module.javaBase, module, android.DeviceSupported, &module.appProperties)
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -79,16 +79,16 @@ func init() {
|
||||
pctx.HostJavaToolVariable("signapkCmd", "signapk.jar")
|
||||
}
|
||||
|
||||
func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
|
||||
deps common.Paths) (common.Path, common.Path, common.Path) {
|
||||
javaDir := common.PathForModuleGen(ctx, "R")
|
||||
javaFileList := common.PathForModuleOut(ctx, "R.filelist")
|
||||
publicResourcesFile := common.PathForModuleOut(ctx, "public_resources.xml")
|
||||
proguardOptionsFile := common.PathForModuleOut(ctx, "proguard.options")
|
||||
func CreateResourceJavaFiles(ctx android.ModuleContext, flags []string,
|
||||
deps android.Paths) (android.Path, android.Path, android.Path) {
|
||||
javaDir := android.PathForModuleGen(ctx, "R")
|
||||
javaFileList := android.PathForModuleOut(ctx, "R.filelist")
|
||||
publicResourcesFile := android.PathForModuleOut(ctx, "public_resources.xml")
|
||||
proguardOptionsFile := android.PathForModuleOut(ctx, "proguard.options")
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: aaptCreateResourceJavaFile,
|
||||
Outputs: common.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
|
||||
Outputs: android.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"aaptFlags": strings.Join(flags, " "),
|
||||
@@ -102,10 +102,10 @@ func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
|
||||
return publicResourcesFile, proguardOptionsFile, javaFileList
|
||||
}
|
||||
|
||||
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps common.Paths) common.ModuleOutPath {
|
||||
outputFile := common.PathForModuleOut(ctx, "package-export.apk")
|
||||
func CreateExportPackage(ctx android.ModuleContext, flags []string, deps android.Paths) android.ModuleOutPath {
|
||||
outputFile := android.PathForModuleOut(ctx, "package-export.apk")
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: aaptCreateAssetsPackage,
|
||||
Output: outputFile,
|
||||
Implicits: deps,
|
||||
@@ -117,12 +117,12 @@ func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps c
|
||||
return outputFile
|
||||
}
|
||||
|
||||
func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile common.Path,
|
||||
certificates []string) common.Path {
|
||||
func CreateAppPackage(ctx android.ModuleContext, flags []string, jarFile android.Path,
|
||||
certificates []string) android.Path {
|
||||
|
||||
resourceApk := common.PathForModuleOut(ctx, "resources.apk")
|
||||
resourceApk := android.PathForModuleOut(ctx, "resources.apk")
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: aaptAddResources,
|
||||
Output: resourceApk,
|
||||
Input: jarFile,
|
||||
@@ -131,14 +131,14 @@ func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile c
|
||||
},
|
||||
})
|
||||
|
||||
outputFile := common.PathForModuleOut(ctx, "package.apk")
|
||||
outputFile := android.PathForModuleOut(ctx, "package.apk")
|
||||
|
||||
var certificateArgs []string
|
||||
for _, c := range certificates {
|
||||
certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
|
||||
}
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: signapk,
|
||||
Output: outputFile,
|
||||
Input: resourceApk,
|
||||
|
@@ -22,14 +22,14 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
_ "github.com/google/blueprint/bootstrap"
|
||||
)
|
||||
|
||||
var (
|
||||
pctx = common.NewPackageContext("android/soong/java")
|
||||
pctx = android.NewPackageContext("android/soong/java")
|
||||
|
||||
// Compiling java is not conducive to proper dependency tracking. The path-matches-class-name
|
||||
// requirement leads to unpredictable generated source file names, and a single .java file
|
||||
@@ -104,24 +104,24 @@ type javaBuilderFlags struct {
|
||||
}
|
||||
|
||||
type jarSpec struct {
|
||||
fileList, dir common.Path
|
||||
fileList, dir android.Path
|
||||
}
|
||||
|
||||
func (j jarSpec) soongJarArgs() string {
|
||||
return "-C " + j.dir.String() + " -l " + j.fileList.String()
|
||||
}
|
||||
|
||||
func TransformJavaToClasses(ctx common.AndroidModuleContext, srcFiles common.Paths, srcFileLists common.Paths,
|
||||
flags javaBuilderFlags, deps common.Paths) jarSpec {
|
||||
func TransformJavaToClasses(ctx android.ModuleContext, srcFiles android.Paths, srcFileLists android.Paths,
|
||||
flags javaBuilderFlags, deps android.Paths) jarSpec {
|
||||
|
||||
classDir := common.PathForModuleOut(ctx, "classes")
|
||||
classFileList := common.PathForModuleOut(ctx, "classes.list")
|
||||
classDir := android.PathForModuleOut(ctx, "classes")
|
||||
classFileList := android.PathForModuleOut(ctx, "classes.list")
|
||||
|
||||
javacFlags := flags.javacFlags + common.JoinWithPrefix(srcFileLists.Strings(), "@")
|
||||
javacFlags := flags.javacFlags + android.JoinWithPrefix(srcFileLists.Strings(), "@")
|
||||
|
||||
deps = append(deps, srcFileLists...)
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: javac,
|
||||
Output: classFileList,
|
||||
Inputs: srcFiles,
|
||||
@@ -137,12 +137,12 @@ func TransformJavaToClasses(ctx common.AndroidModuleContext, srcFiles common.Pat
|
||||
return jarSpec{classFileList, classDir}
|
||||
}
|
||||
|
||||
func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
|
||||
manifest common.OptionalPath) common.Path {
|
||||
func TransformClassesToJar(ctx android.ModuleContext, classes []jarSpec,
|
||||
manifest android.OptionalPath) android.Path {
|
||||
|
||||
outputFile := common.PathForModuleOut(ctx, "classes-full-debug.jar")
|
||||
outputFile := android.PathForModuleOut(ctx, "classes-full-debug.jar")
|
||||
|
||||
deps := common.Paths{}
|
||||
deps := android.Paths{}
|
||||
jarArgs := []string{}
|
||||
|
||||
for _, j := range classes {
|
||||
@@ -155,7 +155,7 @@ func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
|
||||
jarArgs = append(jarArgs, "-m "+manifest.String())
|
||||
}
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: jar,
|
||||
Output: outputFile,
|
||||
Implicits: deps,
|
||||
@@ -167,13 +167,13 @@ func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
|
||||
return outputFile
|
||||
}
|
||||
|
||||
func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar common.Path,
|
||||
func TransformClassesJarToDex(ctx android.ModuleContext, classesJar android.Path,
|
||||
flags javaBuilderFlags) jarSpec {
|
||||
|
||||
outDir := common.PathForModuleOut(ctx, "dex")
|
||||
outputFile := common.PathForModuleOut(ctx, "dex.filelist")
|
||||
outDir := android.PathForModuleOut(ctx, "dex")
|
||||
outputFile := android.PathForModuleOut(ctx, "dex.filelist")
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: dx,
|
||||
Output: outputFile,
|
||||
Input: classesJar,
|
||||
@@ -186,11 +186,11 @@ func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar common
|
||||
return jarSpec{outputFile, outDir}
|
||||
}
|
||||
|
||||
func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
|
||||
dexJarSpec jarSpec) common.Path {
|
||||
func TransformDexToJavaLib(ctx android.ModuleContext, resources []jarSpec,
|
||||
dexJarSpec jarSpec) android.Path {
|
||||
|
||||
outputFile := common.PathForModuleOut(ctx, "javalib.jar")
|
||||
var deps common.Paths
|
||||
outputFile := android.PathForModuleOut(ctx, "javalib.jar")
|
||||
var deps android.Paths
|
||||
var jarArgs []string
|
||||
|
||||
for _, j := range resources {
|
||||
@@ -201,7 +201,7 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
|
||||
deps = append(deps, dexJarSpec.fileList)
|
||||
jarArgs = append(jarArgs, dexJarSpec.soongJarArgs())
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: jar,
|
||||
Output: outputFile,
|
||||
Implicits: deps,
|
||||
@@ -213,9 +213,9 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
|
||||
return outputFile
|
||||
}
|
||||
|
||||
func TransformJarJar(ctx common.AndroidModuleContext, classesJar common.Path, rulesFile common.Path) common.Path {
|
||||
outputFile := common.PathForModuleOut(ctx, "classes-jarjar.jar")
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
func TransformJarJar(ctx android.ModuleContext, classesJar android.Path, rulesFile android.Path) android.Path {
|
||||
outputFile := android.PathForModuleOut(ctx, "classes-jarjar.jar")
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: jarjar,
|
||||
Output: outputFile,
|
||||
Input: classesJar,
|
||||
@@ -228,16 +228,16 @@ func TransformJarJar(ctx common.AndroidModuleContext, classesJar common.Path, ru
|
||||
return outputFile
|
||||
}
|
||||
|
||||
func TransformPrebuiltJarToClasses(ctx common.AndroidModuleContext,
|
||||
prebuilt common.Path) (classJarSpec, resourceJarSpec jarSpec) {
|
||||
func TransformPrebuiltJarToClasses(ctx android.ModuleContext,
|
||||
prebuilt android.Path) (classJarSpec, resourceJarSpec jarSpec) {
|
||||
|
||||
classDir := common.PathForModuleOut(ctx, "extracted/classes")
|
||||
classFileList := common.PathForModuleOut(ctx, "extracted/classes.list")
|
||||
resourceFileList := common.PathForModuleOut(ctx, "extracted/resources.list")
|
||||
classDir := android.PathForModuleOut(ctx, "extracted/classes")
|
||||
classFileList := android.PathForModuleOut(ctx, "extracted/classes.list")
|
||||
resourceFileList := android.PathForModuleOut(ctx, "extracted/resources.list")
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: extractPrebuilt,
|
||||
Outputs: common.WritablePaths{classFileList, resourceFileList},
|
||||
Outputs: android.WritablePaths{classFileList, resourceFileList},
|
||||
Input: prebuilt,
|
||||
Args: map[string]string{
|
||||
"outDir": classDir.String(),
|
||||
|
22
java/gen.go
22
java/gen.go
@@ -21,7 +21,7 @@ package java
|
||||
import (
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -56,11 +56,11 @@ var (
|
||||
})
|
||||
)
|
||||
|
||||
func genAidl(ctx common.AndroidModuleContext, aidlFile common.Path, aidlFlags string) common.Path {
|
||||
javaFile := common.GenPathWithExt(ctx, aidlFile, "java")
|
||||
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string) android.Path {
|
||||
javaFile := android.GenPathWithExt(ctx, aidlFile, "java")
|
||||
depFile := javaFile.String() + ".d"
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: aidl,
|
||||
Output: javaFile,
|
||||
Input: aidlFile,
|
||||
@@ -73,10 +73,10 @@ func genAidl(ctx common.AndroidModuleContext, aidlFile common.Path, aidlFlags st
|
||||
return javaFile
|
||||
}
|
||||
|
||||
func genLogtags(ctx common.AndroidModuleContext, logtagsFile common.Path) common.Path {
|
||||
javaFile := common.GenPathWithExt(ctx, logtagsFile, "java")
|
||||
func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Path {
|
||||
javaFile := android.GenPathWithExt(ctx, logtagsFile, "java")
|
||||
|
||||
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: logtags,
|
||||
Output: javaFile,
|
||||
Input: logtagsFile,
|
||||
@@ -85,8 +85,8 @@ func genLogtags(ctx common.AndroidModuleContext, logtagsFile common.Path) common
|
||||
return javaFile
|
||||
}
|
||||
|
||||
func (j *javaBase) genSources(ctx common.AndroidModuleContext, srcFiles common.Paths,
|
||||
flags javaBuilderFlags) common.Paths {
|
||||
func (j *javaBase) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
flags javaBuilderFlags) android.Paths {
|
||||
|
||||
for i, srcFile := range srcFiles {
|
||||
switch srcFile.Ext() {
|
||||
@@ -108,13 +108,13 @@ func LogtagsSingleton() blueprint.Singleton {
|
||||
}
|
||||
|
||||
type logtagsProducer interface {
|
||||
logtags() common.Paths
|
||||
logtags() android.Paths
|
||||
}
|
||||
|
||||
type logtagsSingleton struct{}
|
||||
|
||||
func (l *logtagsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||
var allLogtags common.Paths
|
||||
var allLogtags android.Paths
|
||||
ctx.VisitAllModules(func(module blueprint.Module) {
|
||||
if logtags, ok := module.(logtagsProducer); ok {
|
||||
allLogtags = append(allLogtags, logtags.logtags()...)
|
||||
|
124
java/java.go
124
java/java.go
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong"
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
"android/soong/genrule"
|
||||
)
|
||||
|
||||
@@ -114,16 +114,16 @@ type javaBaseProperties struct {
|
||||
// javaBase contains the properties and members used by all java module types, and implements
|
||||
// the blueprint.Module interface.
|
||||
type javaBase struct {
|
||||
common.AndroidModuleBase
|
||||
android.ModuleBase
|
||||
module JavaModuleType
|
||||
|
||||
properties javaBaseProperties
|
||||
|
||||
// output file suitable for inserting into the classpath of another compile
|
||||
classpathFile common.Path
|
||||
classpathFile android.Path
|
||||
|
||||
// output file suitable for installing or running
|
||||
outputFile common.Path
|
||||
outputFile android.Path
|
||||
|
||||
// jarSpecs suitable for inserting classes from a static library into another jar
|
||||
classJarSpecs []jarSpec
|
||||
@@ -131,43 +131,43 @@ type javaBase struct {
|
||||
// jarSpecs suitable for inserting resources from a static library into another jar
|
||||
resourceJarSpecs []jarSpec
|
||||
|
||||
exportAidlIncludeDirs common.Paths
|
||||
exportAidlIncludeDirs android.Paths
|
||||
|
||||
logtagsSrcs common.Paths
|
||||
logtagsSrcs android.Paths
|
||||
|
||||
// filelists of extra source files that should be included in the javac command line,
|
||||
// for example R.java generated by aapt for android apps
|
||||
ExtraSrcLists common.Paths
|
||||
ExtraSrcLists android.Paths
|
||||
|
||||
// installed file for binary dependency
|
||||
installFile common.Path
|
||||
installFile android.Path
|
||||
}
|
||||
|
||||
type AndroidJavaModuleContext common.AndroidBaseContext
|
||||
type AndroidJavaModuleContext android.BaseContext
|
||||
|
||||
type JavaModuleType interface {
|
||||
GenerateJavaBuildActions(ctx common.AndroidModuleContext)
|
||||
GenerateJavaBuildActions(ctx android.ModuleContext)
|
||||
JavaDependencies(ctx AndroidJavaModuleContext) []string
|
||||
}
|
||||
|
||||
type JavaDependency interface {
|
||||
ClasspathFile() common.Path
|
||||
ClasspathFile() android.Path
|
||||
ClassJarSpecs() []jarSpec
|
||||
ResourceJarSpecs() []jarSpec
|
||||
AidlIncludeDirs() common.Paths
|
||||
AidlIncludeDirs() android.Paths
|
||||
}
|
||||
|
||||
func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported,
|
||||
func NewJavaBase(base *javaBase, module JavaModuleType, hod android.HostOrDeviceSupported,
|
||||
props ...interface{}) (blueprint.Module, []interface{}) {
|
||||
|
||||
base.module = module
|
||||
|
||||
props = append(props, &base.properties)
|
||||
|
||||
return common.InitAndroidArchModule(base, hod, common.MultilibCommon, props...)
|
||||
return android.InitAndroidArchModule(base, hod, android.MultilibCommon, props...)
|
||||
}
|
||||
|
||||
func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
|
||||
func (j *javaBase) BootClasspath(ctx android.BaseContext) string {
|
||||
if ctx.Device() {
|
||||
if j.properties.Sdk_version == "" {
|
||||
return "core-libart"
|
||||
@@ -191,7 +191,7 @@ func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
|
||||
|
||||
var defaultJavaLibraries = []string{"core-libart", "core-junit", "ext", "framework"}
|
||||
|
||||
func javaDepsMutator(ctx common.AndroidBottomUpMutatorContext) {
|
||||
func javaDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
if j, ok := ctx.Module().(JavaModuleType); ok {
|
||||
ctx.AddDependency(ctx.Module(), nil, j.JavaDependencies(ctx)...)
|
||||
}
|
||||
@@ -215,35 +215,35 @@ func (j *javaBase) JavaDependencies(ctx AndroidJavaModuleContext) []string {
|
||||
return deps
|
||||
}
|
||||
|
||||
func (j *javaBase) aidlFlags(ctx common.AndroidModuleContext, aidlPreprocess common.OptionalPath,
|
||||
aidlIncludeDirs common.Paths) []string {
|
||||
func (j *javaBase) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
||||
aidlIncludeDirs android.Paths) []string {
|
||||
|
||||
localAidlIncludes := common.PathsForModuleSrc(ctx, j.properties.Aidl_includes)
|
||||
localAidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl_includes)
|
||||
|
||||
var flags []string
|
||||
if aidlPreprocess.Valid() {
|
||||
flags = append(flags, "-p"+aidlPreprocess.String())
|
||||
} else {
|
||||
flags = append(flags, common.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
|
||||
flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
|
||||
}
|
||||
|
||||
flags = append(flags, common.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
||||
flags = append(flags, common.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
|
||||
flags = append(flags, "-I"+common.PathForModuleSrc(ctx).String())
|
||||
flags = append(flags, "-I"+common.PathForModuleSrc(ctx, "src").String())
|
||||
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
||||
flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
|
||||
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
||||
flags = append(flags, "-I"+android.PathForModuleSrc(ctx, "src").String())
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath common.Paths,
|
||||
bootClasspath common.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess common.OptionalPath,
|
||||
aidlIncludeDirs common.Paths, srcFileLists common.Paths) {
|
||||
func (j *javaBase) collectDeps(ctx android.ModuleContext) (classpath android.Paths,
|
||||
bootClasspath android.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess android.OptionalPath,
|
||||
aidlIncludeDirs android.Paths, srcFileLists android.Paths) {
|
||||
|
||||
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
||||
otherName := ctx.OtherModuleName(module)
|
||||
if javaDep, ok := module.(JavaDependency); ok {
|
||||
if otherName == j.BootClasspath(ctx) {
|
||||
bootClasspath = common.OptionalPathForPath(javaDep.ClasspathFile())
|
||||
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
|
||||
} else if inList(otherName, defaultJavaLibraries) {
|
||||
classpath = append(classpath, javaDep.ClasspathFile())
|
||||
} else if inList(otherName, j.properties.Java_libs) {
|
||||
@@ -279,13 +279,13 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath commo
|
||||
aidlIncludeDirs, srcFileLists
|
||||
}
|
||||
|
||||
func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (j *javaBase) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.module.GenerateJavaBuildActions(ctx)
|
||||
}
|
||||
|
||||
func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (j *javaBase) GenerateJavaBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
j.exportAidlIncludeDirs = common.PathsForModuleSrc(ctx, j.properties.Export_aidl_include_dirs)
|
||||
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Export_aidl_include_dirs)
|
||||
|
||||
classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
|
||||
aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
|
||||
@@ -304,7 +304,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
flags.aidlFlags = "$aidlFlags"
|
||||
}
|
||||
|
||||
var javacDeps common.Paths
|
||||
var javacDeps android.Paths
|
||||
|
||||
if bootClasspath.Valid() {
|
||||
flags.bootClasspath = "-bootclasspath " + bootClasspath.String()
|
||||
@@ -341,7 +341,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
resourceJarSpecs = append(ResourceDirsToJarSpecs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs),
|
||||
resourceJarSpecs...)
|
||||
|
||||
manifest := common.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
|
||||
manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
|
||||
|
||||
allJarSpecs := append([]jarSpec(nil), classJarSpecs...)
|
||||
allJarSpecs = append(allJarSpecs, resourceJarSpecs...)
|
||||
@@ -353,7 +353,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
}
|
||||
|
||||
if j.properties.Jarjar_rules != nil {
|
||||
jarjar_rules := common.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
||||
jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
||||
// Transform classes-full-debug.jar into classes-jarjar.jar
|
||||
outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
|
||||
if ctx.Failed() {
|
||||
@@ -388,7 +388,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
dxFlags = append(dxFlags,
|
||||
"--debug",
|
||||
"--verbose",
|
||||
"--dump-to="+common.PathForModuleOut(ctx, "classes.lst").String(),
|
||||
"--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(),
|
||||
"--dump-width=1000")
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
|
||||
var _ JavaDependency = (*JavaLibrary)(nil)
|
||||
|
||||
func (j *javaBase) ClasspathFile() common.Path {
|
||||
func (j *javaBase) ClasspathFile() android.Path {
|
||||
return j.classpathFile
|
||||
}
|
||||
|
||||
@@ -421,13 +421,13 @@ func (j *javaBase) ResourceJarSpecs() []jarSpec {
|
||||
return j.resourceJarSpecs
|
||||
}
|
||||
|
||||
func (j *javaBase) AidlIncludeDirs() common.Paths {
|
||||
func (j *javaBase) AidlIncludeDirs() android.Paths {
|
||||
return j.exportAidlIncludeDirs
|
||||
}
|
||||
|
||||
var _ logtagsProducer = (*javaBase)(nil)
|
||||
|
||||
func (j *javaBase) logtags() common.Paths {
|
||||
func (j *javaBase) logtags() android.Paths {
|
||||
return j.logtagsSrcs
|
||||
}
|
||||
|
||||
@@ -439,10 +439,10 @@ type JavaLibrary struct {
|
||||
javaBase
|
||||
}
|
||||
|
||||
func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (j *JavaLibrary) GenerateJavaBuildActions(ctx android.ModuleContext) {
|
||||
j.javaBase.GenerateJavaBuildActions(ctx)
|
||||
|
||||
j.installFile = ctx.InstallFileName(common.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
|
||||
j.installFile = ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
|
||||
}
|
||||
|
||||
func JavaLibraryFactory() (blueprint.Module, []interface{}) {
|
||||
@@ -450,13 +450,13 @@ func JavaLibraryFactory() (blueprint.Module, []interface{}) {
|
||||
|
||||
module.properties.Dex = true
|
||||
|
||||
return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported)
|
||||
return NewJavaBase(&module.javaBase, module, android.HostAndDeviceSupported)
|
||||
}
|
||||
|
||||
func JavaLibraryHostFactory() (blueprint.Module, []interface{}) {
|
||||
module := &JavaLibrary{}
|
||||
|
||||
return NewJavaBase(&module.javaBase, module, common.HostSupported)
|
||||
return NewJavaBase(&module.javaBase, module, android.HostSupported)
|
||||
}
|
||||
|
||||
//
|
||||
@@ -474,12 +474,12 @@ type JavaBinary struct {
|
||||
binaryProperties javaBinaryProperties
|
||||
}
|
||||
|
||||
func (j *JavaBinary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (j *JavaBinary) GenerateJavaBuildActions(ctx android.ModuleContext) {
|
||||
j.JavaLibrary.GenerateJavaBuildActions(ctx)
|
||||
|
||||
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
|
||||
// another build rule before the jar has been installed.
|
||||
ctx.InstallFile(common.PathForModuleInstall(ctx, "bin"), common.PathForModuleSrc(ctx, j.binaryProperties.Wrapper),
|
||||
ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper),
|
||||
j.installFile)
|
||||
}
|
||||
|
||||
@@ -488,13 +488,13 @@ func JavaBinaryFactory() (blueprint.Module, []interface{}) {
|
||||
|
||||
module.properties.Dex = true
|
||||
|
||||
return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported, &module.binaryProperties)
|
||||
return NewJavaBase(&module.javaBase, module, android.HostAndDeviceSupported, &module.binaryProperties)
|
||||
}
|
||||
|
||||
func JavaBinaryHostFactory() (blueprint.Module, []interface{}) {
|
||||
module := &JavaBinary{}
|
||||
|
||||
return NewJavaBase(&module.javaBase, module, common.HostSupported, &module.binaryProperties)
|
||||
return NewJavaBase(&module.javaBase, module, android.HostSupported, &module.binaryProperties)
|
||||
}
|
||||
|
||||
//
|
||||
@@ -506,32 +506,32 @@ type javaPrebuiltProperties struct {
|
||||
}
|
||||
|
||||
type JavaPrebuilt struct {
|
||||
common.AndroidModuleBase
|
||||
android.ModuleBase
|
||||
|
||||
properties javaPrebuiltProperties
|
||||
|
||||
classpathFile common.Path
|
||||
classpathFile android.Path
|
||||
classJarSpecs, resourceJarSpecs []jarSpec
|
||||
}
|
||||
|
||||
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if len(j.properties.Srcs) != 1 {
|
||||
ctx.ModuleErrorf("expected exactly one jar in srcs")
|
||||
return
|
||||
}
|
||||
prebuilt := common.PathForModuleSrc(ctx, j.properties.Srcs[0])
|
||||
prebuilt := android.PathForModuleSrc(ctx, j.properties.Srcs[0])
|
||||
|
||||
classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
|
||||
|
||||
j.classpathFile = prebuilt
|
||||
j.classJarSpecs = []jarSpec{classJarSpec}
|
||||
j.resourceJarSpecs = []jarSpec{resourceJarSpec}
|
||||
ctx.InstallFileName(common.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile)
|
||||
ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile)
|
||||
}
|
||||
|
||||
var _ JavaDependency = (*JavaPrebuilt)(nil)
|
||||
|
||||
func (j *JavaPrebuilt) ClasspathFile() common.Path {
|
||||
func (j *JavaPrebuilt) ClasspathFile() android.Path {
|
||||
return j.classpathFile
|
||||
}
|
||||
|
||||
@@ -543,15 +543,15 @@ func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec {
|
||||
return j.resourceJarSpecs
|
||||
}
|
||||
|
||||
func (j *JavaPrebuilt) AidlIncludeDirs() common.Paths {
|
||||
func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths {
|
||||
return nil
|
||||
}
|
||||
|
||||
func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
|
||||
module := &JavaPrebuilt{}
|
||||
|
||||
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
|
||||
common.MultilibCommon, &module.properties)
|
||||
return android.InitAndroidArchModule(module, android.HostAndDeviceSupported,
|
||||
android.MultilibCommon, &module.properties)
|
||||
}
|
||||
|
||||
//
|
||||
@@ -560,7 +560,7 @@ func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
|
||||
|
||||
type sdkDependency interface {
|
||||
JavaDependency
|
||||
AidlPreprocessed() common.OptionalPath
|
||||
AidlPreprocessed() android.OptionalPath
|
||||
}
|
||||
|
||||
var _ sdkDependency = (*sdkPrebuilt)(nil)
|
||||
@@ -574,24 +574,24 @@ type sdkPrebuilt struct {
|
||||
|
||||
sdkProperties sdkPrebuiltProperties
|
||||
|
||||
aidlPreprocessed common.OptionalPath
|
||||
aidlPreprocessed android.OptionalPath
|
||||
}
|
||||
|
||||
func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
|
||||
func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.JavaPrebuilt.GenerateAndroidBuildActions(ctx)
|
||||
|
||||
j.aidlPreprocessed = common.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed)
|
||||
j.aidlPreprocessed = android.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed)
|
||||
}
|
||||
|
||||
func (j *sdkPrebuilt) AidlPreprocessed() common.OptionalPath {
|
||||
func (j *sdkPrebuilt) AidlPreprocessed() android.OptionalPath {
|
||||
return j.aidlPreprocessed
|
||||
}
|
||||
|
||||
func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
|
||||
module := &sdkPrebuilt{}
|
||||
|
||||
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
|
||||
common.MultilibCommon, &module.properties, &module.sdkProperties)
|
||||
return android.InitAndroidArchModule(module, android.HostAndDeviceSupported,
|
||||
android.MultilibCommon, &module.properties, &module.sdkProperties)
|
||||
}
|
||||
|
||||
func inList(s string, l []string) bool {
|
||||
|
@@ -17,7 +17,7 @@ package java
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"android/soong/common"
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
var resourceExcludes = []string{
|
||||
@@ -38,11 +38,11 @@ func isStringInSlice(str string, slice []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs, excludeDirs []string) []jarSpec {
|
||||
func ResourceDirsToJarSpecs(ctx android.ModuleContext, resourceDirs, excludeDirs []string) []jarSpec {
|
||||
var excludes []string
|
||||
|
||||
for _, exclude := range excludeDirs {
|
||||
excludes = append(excludes, common.PathForModuleSrc(ctx, exclude, "**/*").String())
|
||||
excludes = append(excludes, android.PathForModuleSrc(ctx, exclude, "**/*").String())
|
||||
}
|
||||
|
||||
excludes = append(excludes, resourceExcludes...)
|
||||
@@ -53,14 +53,14 @@ func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs, exclu
|
||||
if isStringInSlice(resourceDir, excludeDirs) {
|
||||
continue
|
||||
}
|
||||
resourceDir := common.PathForModuleSrc(ctx, resourceDir)
|
||||
resourceDir := android.PathForModuleSrc(ctx, resourceDir)
|
||||
dirs := ctx.Glob("java_resources", resourceDir.String(), nil)
|
||||
for _, dir := range dirs {
|
||||
fileListFile := common.ResPathWithName(ctx, dir, "resources.list")
|
||||
fileListFile := android.ResPathWithName(ctx, dir, "resources.list")
|
||||
depFile := fileListFile.String() + ".d"
|
||||
|
||||
glob := filepath.Join(dir.String(), "**/*")
|
||||
common.GlobRule(ctx, glob, excludes, fileListFile.String(), depFile)
|
||||
android.GlobRule(ctx, glob, excludes, fileListFile.String(), depFile)
|
||||
jarSpecs = append(jarSpecs, jarSpec{fileListFile, dir})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user