Refactor install paths

Explicitly allow installation into the data partition instead of using
"../data" for tests. At the same time, pipe through the information
required for vendor modules.

Change-Id: I6baf9d828c285e1080e43074beef8aebdbb38875
This commit is contained in:
Dan Willemsen 2015-12-21 14:55:28 -08:00
parent 7b310eefb7
commit 782a2d116a
5 changed files with 71 additions and 23 deletions

View File

@ -1359,7 +1359,7 @@ func (c *CCLibrary) installSharedLibrary(ctx common.AndroidModuleContext, flags
installDir = "lib64" installDir = "lib64"
} }
ctx.InstallFile(filepath.Join(installDir, c.Properties.Relative_install_path), c.out) ctx.InstallFile(common.PathForModuleInstall(ctx, installDir, c.Properties.Relative_install_path), c.out)
} }
func (c *CCLibrary) installModule(ctx common.AndroidModuleContext, flags CCFlags) { func (c *CCLibrary) installModule(ctx common.AndroidModuleContext, flags CCFlags) {
@ -1611,7 +1611,7 @@ func (c *CCBinary) compileModule(ctx common.AndroidModuleContext,
} }
func (c *CCBinary) installModule(ctx common.AndroidModuleContext, flags CCFlags) { func (c *CCBinary) installModule(ctx common.AndroidModuleContext, flags CCFlags) {
c.installFile = ctx.InstallFile(filepath.Join("bin", c.Properties.Relative_install_path), c.out) c.installFile = ctx.InstallFile(common.PathForModuleInstall(ctx, "bin", c.Properties.Relative_install_path), c.out)
} }
func (c *CCBinary) HostToolPath() common.OptionalPath { func (c *CCBinary) HostToolPath() common.OptionalPath {
@ -1678,9 +1678,17 @@ func (c *CCTest) depNames(ctx common.AndroidBaseContext, depNames CCDeps) CCDeps
return depNames return depNames
} }
func (c *CCTest) InstallInData() bool {
return true
}
func (c *CCTest) installModule(ctx common.AndroidModuleContext, flags CCFlags) { func (c *CCTest) installModule(ctx common.AndroidModuleContext, flags CCFlags) {
if ctx.Device() { if ctx.Device() {
ctx.InstallFile("../data/nativetest"+ctx.Arch().ArchType.Multilib[3:]+"/"+ctx.ModuleName(), c.out) installDir := "nativetest"
if flags.Toolchain.Is64Bit() {
installDir = "nativetest64"
}
ctx.InstallFile(common.PathForModuleInstall(ctx, installDir, ctx.ModuleName()), c.out)
} else { } else {
c.CCBinary.installModule(ctx, flags) c.CCBinary.installModule(ctx, flags)
} }
@ -1708,9 +1716,17 @@ func (c *CCBenchmark) depNames(ctx common.AndroidBaseContext, depNames CCDeps) C
return depNames return depNames
} }
func (c *CCBenchmark) InstallInData() bool {
return true
}
func (c *CCBenchmark) installModule(ctx common.AndroidModuleContext, flags CCFlags) { func (c *CCBenchmark) installModule(ctx common.AndroidModuleContext, flags CCFlags) {
if ctx.Device() { if ctx.Device() {
ctx.InstallFile("../data/nativetest"+ctx.Arch().ArchType.Multilib[3:]+"/"+ctx.ModuleName(), c.out) installDir := "nativetest"
if flags.Toolchain.Is64Bit() {
installDir = "nativetest64"
}
ctx.InstallFile(common.PathForModuleInstall(ctx, installDir, ctx.ModuleName()), c.out)
} else { } else {
c.CCBinary.installModule(ctx, flags) c.CCBinary.installModule(ctx, flags)
} }

View File

@ -56,6 +56,8 @@ type androidBaseContext interface {
Darwin() bool Darwin() bool
Debug() bool Debug() bool
AConfig() Config AConfig() Config
Proprietary() bool
InstallInData() bool
} }
type AndroidBaseContext interface { type AndroidBaseContext interface {
@ -74,8 +76,8 @@ type AndroidModuleContext interface {
ExpandSources(srcFiles, excludes []string) Paths ExpandSources(srcFiles, excludes []string) Paths
Glob(outDir, globPattern string, excludes []string) Paths Glob(outDir, globPattern string, excludes []string) Paths
InstallFile(installPath string, srcPath Path, deps ...Path) Path InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path
InstallFileName(installPath, name string, srcPath Path, deps ...Path) Path InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) Path
CheckbuildFile(srcPath Path) CheckbuildFile(srcPath Path)
} }
@ -87,6 +89,7 @@ type AndroidModule interface {
base() *AndroidModuleBase base() *AndroidModuleBase
Enabled() bool Enabled() bool
HostOrDevice() HostOrDevice HostOrDevice() HostOrDevice
InstallInData() bool
} }
type commonProperties struct { type commonProperties struct {
@ -103,6 +106,9 @@ type commonProperties struct {
// platform // platform
Compile_multilib string Compile_multilib string
// whether this is a proprietary vendor module, and should be installed into /vendor
Proprietary bool
// Set by HostOrDeviceMutator // Set by HostOrDeviceMutator
CompileHostOrDevice HostOrDevice `blueprint:"mutated"` CompileHostOrDevice HostOrDevice `blueprint:"mutated"`
@ -294,6 +300,10 @@ func (p *AndroidModuleBase) NoAddressSanitizer() bool {
return p.noAddressSanitizer return p.noAddressSanitizer
} }
func (p *AndroidModuleBase) InstallInData() bool {
return false
}
func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) { func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
if a != ctx.FinalModule().(AndroidModule).base() { if a != ctx.FinalModule().(AndroidModule).base() {
return return
@ -355,7 +365,9 @@ func (a *AndroidModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleCo
arch: a.commonProperties.CompileArch, arch: a.commonProperties.CompileArch,
hod: a.commonProperties.CompileHostOrDevice, hod: a.commonProperties.CompileHostOrDevice,
ht: a.commonProperties.CompileHostType, ht: a.commonProperties.CompileHostType,
proprietary: a.commonProperties.Proprietary,
config: ctx.Config().(Config), config: ctx.Config().(Config),
installInData: a.module.InstallInData(),
} }
} }
@ -392,6 +404,8 @@ type androidBaseContextImpl struct {
ht HostType ht HostType
debug bool debug bool
config Config config Config
proprietary bool
installInData bool
} }
type androidModuleContext struct { type androidModuleContext struct {
@ -492,10 +506,18 @@ func (a *androidBaseContextImpl) AConfig() Config {
return a.config return a.config
} }
func (a *androidModuleContext) InstallFileName(installPath, name string, srcPath Path, func (a *androidBaseContextImpl) Proprietary() bool {
return a.proprietary
}
func (a *androidBaseContextImpl) InstallInData() bool {
return a.installInData
}
func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path,
deps ...Path) Path { deps ...Path) Path {
fullInstallPath := PathForModuleInstall(a, installPath, name) fullInstallPath := installPath.Join(a, name)
deps = append(deps, a.installDeps...) deps = append(deps, a.installDeps...)
@ -512,7 +534,7 @@ func (a *androidModuleContext) InstallFileName(installPath, name string, srcPath
return fullInstallPath return fullInstallPath
} }
func (a *androidModuleContext) InstallFile(installPath string, srcPath Path, deps ...Path) Path { func (a *androidModuleContext) InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path {
return a.InstallFileName(installPath, filepath.Base(srcPath.String()), srcPath, deps...) return a.InstallFileName(installPath, filepath.Base(srcPath.String()), srcPath, deps...)
} }

View File

@ -601,10 +601,20 @@ func PathForModuleRes(ctx AndroidModuleContext, paths ...string) ModuleResPath {
func PathForModuleInstall(ctx AndroidModuleContext, paths ...string) OutputPath { func PathForModuleInstall(ctx AndroidModuleContext, paths ...string) OutputPath {
var outPaths []string var outPaths []string
if ctx.Device() { if ctx.Device() {
outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), "system"} partition := "system"
if ctx.Proprietary() {
partition = "vendor"
}
if ctx.InstallInData() {
partition = "data"
}
outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition}
} else { } else {
outPaths = []string{"host", ctx.HostType().String() + "-x86"} outPaths = []string{"host", ctx.HostType().String() + "-x86"}
} }
if ctx.Debug() {
outPaths = append([]string{"debug"}, outPaths...)
}
outPaths = append(outPaths, paths...) outPaths = append(outPaths, paths...)
return PathForOutput(ctx, outPaths...) return PathForOutput(ctx, outPaths...)
} }

View File

@ -152,7 +152,7 @@ func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
} }
a.outputFile = CreateAppPackage(ctx, aaptPackageFlags, a.outputFile, certificates) a.outputFile = CreateAppPackage(ctx, aaptPackageFlags, a.outputFile, certificates)
ctx.InstallFileName("app", ctx.ModuleName()+".apk", a.outputFile) ctx.InstallFileName(common.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
} }
var aaptIgnoreFilenames = []string{ var aaptIgnoreFilenames = []string{

View File

@ -442,7 +442,7 @@ type JavaLibrary struct {
func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) { func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
j.javaBase.GenerateJavaBuildActions(ctx) j.javaBase.GenerateJavaBuildActions(ctx)
j.installFile = ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.outputFile) j.installFile = ctx.InstallFileName(common.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
} }
func JavaLibraryFactory() (blueprint.Module, []interface{}) { func JavaLibraryFactory() (blueprint.Module, []interface{}) {
@ -479,7 +479,7 @@ func (j *JavaBinary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by // 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. // another build rule before the jar has been installed.
ctx.InstallFile("bin", common.PathForModuleSrc(ctx, j.binaryProperties.Wrapper), ctx.InstallFile(common.PathForModuleInstall(ctx, "bin"), common.PathForModuleSrc(ctx, j.binaryProperties.Wrapper),
j.installFile) j.installFile)
} }
@ -526,7 +526,7 @@ func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleConte
j.classpathFile = prebuilt j.classpathFile = prebuilt
j.classJarSpecs = []jarSpec{classJarSpec} j.classJarSpecs = []jarSpec{classJarSpec}
j.resourceJarSpecs = []jarSpec{resourceJarSpec} j.resourceJarSpecs = []jarSpec{resourceJarSpec}
ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.classpathFile) ctx.InstallFileName(common.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile)
} }
var _ JavaDependency = (*JavaPrebuilt)(nil) var _ JavaDependency = (*JavaPrebuilt)(nil)