Merge changes I9170c7e2,I058201b2,Icf37bb3d
* changes: Make filesToInstall return InstallPaths and add it to Module Add pathForInstall and InstallPaths Add InstallForceOS, fix testcases for host
This commit is contained in:
@@ -172,6 +172,7 @@ type ModuleContext interface {
|
|||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
InstallInRoot() bool
|
InstallInRoot() bool
|
||||||
InstallBypassMake() bool
|
InstallBypassMake() bool
|
||||||
|
InstallForceOS() *OsType
|
||||||
|
|
||||||
RequiredModuleNames() []string
|
RequiredModuleNames() []string
|
||||||
HostRequiredModuleNames() []string
|
HostRequiredModuleNames() []string
|
||||||
@@ -214,6 +215,7 @@ type Module interface {
|
|||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
InstallInRoot() bool
|
InstallInRoot() bool
|
||||||
InstallBypassMake() bool
|
InstallBypassMake() bool
|
||||||
|
InstallForceOS() *OsType
|
||||||
SkipInstall()
|
SkipInstall()
|
||||||
ExportedToMake() bool
|
ExportedToMake() bool
|
||||||
InitRc() Paths
|
InitRc() Paths
|
||||||
@@ -242,6 +244,8 @@ type Module interface {
|
|||||||
RequiredModuleNames() []string
|
RequiredModuleNames() []string
|
||||||
HostRequiredModuleNames() []string
|
HostRequiredModuleNames() []string
|
||||||
TargetRequiredModuleNames() []string
|
TargetRequiredModuleNames() []string
|
||||||
|
|
||||||
|
filesToInstall() InstallPaths
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qualified id for a module
|
// Qualified id for a module
|
||||||
@@ -643,7 +647,7 @@ type ModuleBase struct {
|
|||||||
primaryVisibilityProperty visibilityProperty
|
primaryVisibilityProperty visibilityProperty
|
||||||
|
|
||||||
noAddressSanitizer bool
|
noAddressSanitizer bool
|
||||||
installFiles Paths
|
installFiles InstallPaths
|
||||||
checkbuildFiles Paths
|
checkbuildFiles Paths
|
||||||
noticeFiles Paths
|
noticeFiles Paths
|
||||||
|
|
||||||
@@ -849,22 +853,20 @@ func (m *ModuleBase) ExportedToMake() bool {
|
|||||||
return m.commonProperties.NamespaceExportedToMake
|
return m.commonProperties.NamespaceExportedToMake
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) computeInstallDeps(
|
func (m *ModuleBase) computeInstallDeps(ctx blueprint.ModuleContext) InstallPaths {
|
||||||
ctx blueprint.ModuleContext) Paths {
|
|
||||||
|
|
||||||
result := Paths{}
|
var result InstallPaths
|
||||||
// TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
|
// TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
|
||||||
ctx.VisitDepsDepthFirstIf(isFileInstaller,
|
ctx.VisitDepsDepthFirst(func(m blueprint.Module) {
|
||||||
func(m blueprint.Module) {
|
if a, ok := m.(Module); ok {
|
||||||
fileInstaller := m.(fileInstaller)
|
result = append(result, a.filesToInstall()...)
|
||||||
files := fileInstaller.filesToInstall()
|
}
|
||||||
result = append(result, files...)
|
})
|
||||||
})
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) filesToInstall() Paths {
|
func (m *ModuleBase) filesToInstall() InstallPaths {
|
||||||
return m.installFiles
|
return m.installFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,6 +902,10 @@ func (m *ModuleBase) InstallBypassMake() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ModuleBase) InstallForceOS() *OsType {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) Owner() string {
|
func (m *ModuleBase) Owner() string {
|
||||||
return String(m.commonProperties.Owner)
|
return String(m.commonProperties.Owner)
|
||||||
}
|
}
|
||||||
@@ -948,8 +954,8 @@ func (m *ModuleBase) VintfFragments() Paths {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
||||||
allInstalledFiles := Paths{}
|
var allInstalledFiles InstallPaths
|
||||||
allCheckbuildFiles := Paths{}
|
var allCheckbuildFiles Paths
|
||||||
ctx.VisitAllModuleVariants(func(module Module) {
|
ctx.VisitAllModuleVariants(func(module Module) {
|
||||||
a := module.base()
|
a := module.base()
|
||||||
allInstalledFiles = append(allInstalledFiles, a.installFiles...)
|
allInstalledFiles = append(allInstalledFiles, a.installFiles...)
|
||||||
@@ -968,7 +974,7 @@ func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
|||||||
ctx.Build(pctx, BuildParams{
|
ctx.Build(pctx, BuildParams{
|
||||||
Rule: blueprint.Phony,
|
Rule: blueprint.Phony,
|
||||||
Output: name,
|
Output: name,
|
||||||
Implicits: allInstalledFiles,
|
Implicits: allInstalledFiles.Paths(),
|
||||||
Default: !ctx.Config().EmbeddedInMake(),
|
Default: !ctx.Config().EmbeddedInMake(),
|
||||||
})
|
})
|
||||||
deps = append(deps, name)
|
deps = append(deps, name)
|
||||||
@@ -1309,8 +1315,8 @@ func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.Depen
|
|||||||
type moduleContext struct {
|
type moduleContext struct {
|
||||||
bp blueprint.ModuleContext
|
bp blueprint.ModuleContext
|
||||||
baseModuleContext
|
baseModuleContext
|
||||||
installDeps Paths
|
installDeps InstallPaths
|
||||||
installFiles Paths
|
installFiles InstallPaths
|
||||||
checkbuildFiles Paths
|
checkbuildFiles Paths
|
||||||
module Module
|
module Module
|
||||||
|
|
||||||
@@ -1716,6 +1722,10 @@ func (m *moduleContext) InstallBypassMake() bool {
|
|||||||
return m.module.InstallBypassMake()
|
return m.module.InstallBypassMake()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *moduleContext) InstallForceOS() *OsType {
|
||||||
|
return m.module.InstallForceOS()
|
||||||
|
}
|
||||||
|
|
||||||
func (m *moduleContext) skipInstall(fullInstallPath InstallPath) bool {
|
func (m *moduleContext) skipInstall(fullInstallPath InstallPath) bool {
|
||||||
if m.module.base().commonProperties.SkipInstall {
|
if m.module.base().commonProperties.SkipInstall {
|
||||||
return true
|
return true
|
||||||
@@ -1759,7 +1769,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
|
|||||||
|
|
||||||
if !m.skipInstall(fullInstallPath) {
|
if !m.skipInstall(fullInstallPath) {
|
||||||
|
|
||||||
deps = append(deps, m.installDeps...)
|
deps = append(deps, m.installDeps.Paths()...)
|
||||||
|
|
||||||
var implicitDeps, orderOnlyDeps Paths
|
var implicitDeps, orderOnlyDeps Paths
|
||||||
|
|
||||||
@@ -1840,20 +1850,6 @@ func (m *moduleContext) CheckbuildFile(srcPath Path) {
|
|||||||
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
type fileInstaller interface {
|
|
||||||
filesToInstall() Paths
|
|
||||||
}
|
|
||||||
|
|
||||||
func isFileInstaller(m blueprint.Module) bool {
|
|
||||||
_, ok := m.(fileInstaller)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func isAndroidModule(m blueprint.Module) bool {
|
|
||||||
_, ok := m.(Module)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func findStringInSlice(str string, slice []string) int {
|
func findStringInSlice(str string, slice []string) int {
|
||||||
for i, s := range slice {
|
for i, s := range slice {
|
||||||
if s == str {
|
if s == str {
|
||||||
|
129
android/paths.go
129
android/paths.go
@@ -53,6 +53,7 @@ type ModuleInstallPathContext interface {
|
|||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
InstallInRoot() bool
|
InstallInRoot() bool
|
||||||
InstallBypassMake() bool
|
InstallBypassMake() bool
|
||||||
|
InstallForceOS() *OsType
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ModuleInstallPathContext = ModuleContext(nil)
|
var _ ModuleInstallPathContext = ModuleContext(nil)
|
||||||
@@ -1205,22 +1206,40 @@ func (p InstallPath) ToMakePath() InstallPath {
|
|||||||
// PathForModuleInstall returns a Path representing the install path for the
|
// PathForModuleInstall returns a Path representing the install path for the
|
||||||
// module appended with paths...
|
// module appended with paths...
|
||||||
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
|
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
|
||||||
|
os := ctx.Os()
|
||||||
|
if forceOS := ctx.InstallForceOS(); forceOS != nil {
|
||||||
|
os = *forceOS
|
||||||
|
}
|
||||||
|
partition := modulePartition(ctx, os)
|
||||||
|
|
||||||
|
ret := pathForInstall(ctx, os, partition, ctx.Debug(), pathComponents...)
|
||||||
|
|
||||||
|
if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() {
|
||||||
|
ret = ret.ToMakePath()
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func pathForInstall(ctx PathContext, os OsType, partition string, debug bool,
|
||||||
|
pathComponents ...string) InstallPath {
|
||||||
|
|
||||||
var outPaths []string
|
var outPaths []string
|
||||||
if ctx.Device() {
|
|
||||||
partition := modulePartition(ctx)
|
if os.Class == Device {
|
||||||
outPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
|
outPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
|
||||||
} else {
|
} else {
|
||||||
switch ctx.Os() {
|
switch os {
|
||||||
case Linux:
|
case Linux:
|
||||||
outPaths = []string{"host", "linux-x86"}
|
outPaths = []string{"host", "linux-x86", partition}
|
||||||
case LinuxBionic:
|
case LinuxBionic:
|
||||||
// TODO: should this be a separate top level, or shared with linux-x86?
|
// TODO: should this be a separate top level, or shared with linux-x86?
|
||||||
outPaths = []string{"host", "linux_bionic-x86"}
|
outPaths = []string{"host", "linux_bionic-x86", partition}
|
||||||
default:
|
default:
|
||||||
outPaths = []string{"host", ctx.Os().String() + "-x86"}
|
outPaths = []string{"host", os.String() + "-x86", partition}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ctx.Debug() {
|
if debug {
|
||||||
outPaths = append([]string{"debug"}, outPaths...)
|
outPaths = append([]string{"debug"}, outPaths...)
|
||||||
}
|
}
|
||||||
outPaths = append(outPaths, pathComponents...)
|
outPaths = append(outPaths, pathComponents...)
|
||||||
@@ -1231,9 +1250,6 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret := InstallPath{basePath{path, ctx.Config(), ""}, ""}
|
ret := InstallPath{basePath{path, ctx.Config(), ""}, ""}
|
||||||
if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() {
|
|
||||||
ret = ret.ToMakePath()
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -1253,47 +1269,76 @@ func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string {
|
|||||||
return "/" + rel
|
return "/" + rel
|
||||||
}
|
}
|
||||||
|
|
||||||
func modulePartition(ctx ModuleInstallPathContext) string {
|
func modulePartition(ctx ModuleInstallPathContext, os OsType) string {
|
||||||
var partition string
|
var partition string
|
||||||
if ctx.InstallInData() {
|
if ctx.InstallInTestcases() {
|
||||||
partition = "data"
|
// "testcases" install directory can be used for host or device modules.
|
||||||
} else if ctx.InstallInTestcases() {
|
|
||||||
partition = "testcases"
|
partition = "testcases"
|
||||||
} else if ctx.InstallInRamdisk() {
|
} else if os.Class == Device {
|
||||||
if ctx.DeviceConfig().BoardUsesRecoveryAsBoot() {
|
if ctx.InstallInData() {
|
||||||
partition = "recovery/root/first_stage_ramdisk"
|
partition = "data"
|
||||||
|
} else if ctx.InstallInRamdisk() {
|
||||||
|
if ctx.DeviceConfig().BoardUsesRecoveryAsBoot() {
|
||||||
|
partition = "recovery/root/first_stage_ramdisk"
|
||||||
|
} else {
|
||||||
|
partition = "ramdisk"
|
||||||
|
}
|
||||||
|
if !ctx.InstallInRoot() {
|
||||||
|
partition += "/system"
|
||||||
|
}
|
||||||
|
} else if ctx.InstallInRecovery() {
|
||||||
|
if ctx.InstallInRoot() {
|
||||||
|
partition = "recovery/root"
|
||||||
|
} else {
|
||||||
|
// the layout of recovery partion is the same as that of system partition
|
||||||
|
partition = "recovery/root/system"
|
||||||
|
}
|
||||||
|
} else if ctx.SocSpecific() {
|
||||||
|
partition = ctx.DeviceConfig().VendorPath()
|
||||||
|
} else if ctx.DeviceSpecific() {
|
||||||
|
partition = ctx.DeviceConfig().OdmPath()
|
||||||
|
} else if ctx.ProductSpecific() {
|
||||||
|
partition = ctx.DeviceConfig().ProductPath()
|
||||||
|
} else if ctx.SystemExtSpecific() {
|
||||||
|
partition = ctx.DeviceConfig().SystemExtPath()
|
||||||
|
} else if ctx.InstallInRoot() {
|
||||||
|
partition = "root"
|
||||||
} else {
|
} else {
|
||||||
partition = "ramdisk"
|
partition = "system"
|
||||||
}
|
}
|
||||||
if !ctx.InstallInRoot() {
|
if ctx.InstallInSanitizerDir() {
|
||||||
partition += "/system"
|
partition = "data/asan/" + partition
|
||||||
}
|
}
|
||||||
} else if ctx.InstallInRecovery() {
|
|
||||||
if ctx.InstallInRoot() {
|
|
||||||
partition = "recovery/root"
|
|
||||||
} else {
|
|
||||||
// the layout of recovery partion is the same as that of system partition
|
|
||||||
partition = "recovery/root/system"
|
|
||||||
}
|
|
||||||
} else if ctx.SocSpecific() {
|
|
||||||
partition = ctx.DeviceConfig().VendorPath()
|
|
||||||
} else if ctx.DeviceSpecific() {
|
|
||||||
partition = ctx.DeviceConfig().OdmPath()
|
|
||||||
} else if ctx.ProductSpecific() {
|
|
||||||
partition = ctx.DeviceConfig().ProductPath()
|
|
||||||
} else if ctx.SystemExtSpecific() {
|
|
||||||
partition = ctx.DeviceConfig().SystemExtPath()
|
|
||||||
} else if ctx.InstallInRoot() {
|
|
||||||
partition = "root"
|
|
||||||
} else {
|
|
||||||
partition = "system"
|
|
||||||
}
|
|
||||||
if ctx.InstallInSanitizerDir() {
|
|
||||||
partition = "data/asan/" + partition
|
|
||||||
}
|
}
|
||||||
return partition
|
return partition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InstallPaths []InstallPath
|
||||||
|
|
||||||
|
// Paths returns the InstallPaths as a Paths
|
||||||
|
func (p InstallPaths) Paths() Paths {
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ret := make(Paths, len(p))
|
||||||
|
for i, path := range p {
|
||||||
|
ret[i] = path
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strings returns the string forms of the install paths.
|
||||||
|
func (p InstallPaths) Strings() []string {
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ret := make([]string, len(p))
|
||||||
|
for i, path := range p {
|
||||||
|
ret[i] = path.String()
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
// validateSafePath validates a path that we trust (may contain ninja variables).
|
// validateSafePath validates a path that we trust (may contain ninja variables).
|
||||||
// Ensures that each path component does not attempt to leave its component.
|
// Ensures that each path component does not attempt to leave its component.
|
||||||
func validateSafePath(pathComponents ...string) (string, error) {
|
func validateSafePath(pathComponents ...string) (string, error) {
|
||||||
|
@@ -205,6 +205,7 @@ type moduleInstallPathContextImpl struct {
|
|||||||
inRamdisk bool
|
inRamdisk bool
|
||||||
inRecovery bool
|
inRecovery bool
|
||||||
inRoot bool
|
inRoot bool
|
||||||
|
forceOS *OsType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m moduleInstallPathContextImpl) Config() Config {
|
func (m moduleInstallPathContextImpl) Config() Config {
|
||||||
@@ -241,6 +242,10 @@ func (m moduleInstallPathContextImpl) InstallBypassMake() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m moduleInstallPathContextImpl) InstallForceOS() *OsType {
|
||||||
|
return m.forceOS
|
||||||
|
}
|
||||||
|
|
||||||
func pathTestConfig(buildDir string) Config {
|
func pathTestConfig(buildDir string) Config {
|
||||||
return TestConfig(buildDir, nil, "", nil)
|
return TestConfig(buildDir, nil, "", nil)
|
||||||
}
|
}
|
||||||
@@ -598,6 +603,40 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
},
|
},
|
||||||
in: []string{"nativetest", "my_test"},
|
in: []string{"nativetest", "my_test"},
|
||||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||||
|
}, {
|
||||||
|
name: "device testcases",
|
||||||
|
ctx: &moduleInstallPathContextImpl{
|
||||||
|
baseModuleContext: baseModuleContext{
|
||||||
|
os: deviceTarget.Os,
|
||||||
|
target: deviceTarget,
|
||||||
|
},
|
||||||
|
inTestcases: true,
|
||||||
|
},
|
||||||
|
in: []string{"my_test", "my_test_bin"},
|
||||||
|
out: "target/product/test_device/testcases/my_test/my_test_bin",
|
||||||
|
}, {
|
||||||
|
name: "host testcases",
|
||||||
|
ctx: &moduleInstallPathContextImpl{
|
||||||
|
baseModuleContext: baseModuleContext{
|
||||||
|
os: hostTarget.Os,
|
||||||
|
target: hostTarget,
|
||||||
|
},
|
||||||
|
inTestcases: true,
|
||||||
|
},
|
||||||
|
in: []string{"my_test", "my_test_bin"},
|
||||||
|
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||||
|
}, {
|
||||||
|
name: "forced host testcases",
|
||||||
|
ctx: &moduleInstallPathContextImpl{
|
||||||
|
baseModuleContext: baseModuleContext{
|
||||||
|
os: deviceTarget.Os,
|
||||||
|
target: deviceTarget,
|
||||||
|
},
|
||||||
|
inTestcases: true,
|
||||||
|
forceOS: &Linux,
|
||||||
|
},
|
||||||
|
in: []string{"my_test", "my_test_bin"},
|
||||||
|
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user