Separate InstallPath from OutputPath am: 70dda7e3da

am: 21daf4e438

Change-Id: I348518cd03877d307d890d4ccf580bf0f70d060d
This commit is contained in:
Colin Cross
2019-10-03 15:14:41 -07:00
committed by android-build-merger
16 changed files with 91 additions and 53 deletions

View File

@@ -75,7 +75,7 @@ func (x *hooks) runArchHooks(ctx ArchHookContext, m *ModuleBase) {
type InstallHookContext interface { type InstallHookContext interface {
ModuleContext ModuleContext
Path() OutputPath Path() InstallPath
Symlink() bool Symlink() bool
} }
@@ -89,11 +89,11 @@ func AddInstallHook(m blueprint.Module, hook func(InstallHookContext)) {
type installHookContext struct { type installHookContext struct {
ModuleContext ModuleContext
path OutputPath path InstallPath
symlink bool symlink bool
} }
func (x *installHookContext) Path() OutputPath { func (x *installHookContext) Path() InstallPath {
return x.path return x.path
} }
@@ -101,7 +101,7 @@ func (x *installHookContext) Symlink() bool {
return x.symlink return x.symlink
} }
func (x *hooks) runInstallHooks(ctx ModuleContext, path OutputPath, symlink bool) { func (x *hooks) runInstallHooks(ctx ModuleContext, path InstallPath, symlink bool) {
if len(x.install) > 0 { if len(x.install) > 0 {
mctx := &installHookContext{ mctx := &installHookContext{
ModuleContext: ctx, ModuleContext: ctx,

View File

@@ -147,10 +147,10 @@ type ModuleContext interface {
ExpandSource(srcFile, prop string) Path ExpandSource(srcFile, prop string) Path
ExpandOptionalSource(srcFile *string, prop string) OptionalPath ExpandOptionalSource(srcFile *string, prop string) OptionalPath
InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath InstallFile(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath
InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
CheckbuildFile(srcPath Path) CheckbuildFile(srcPath Path)
InstallInData() bool InstallInData() bool
@@ -1536,7 +1536,7 @@ func (m *moduleContext) InstallBypassMake() bool {
return m.module.InstallBypassMake() return m.module.InstallBypassMake()
} }
func (m *moduleContext) skipInstall(fullInstallPath OutputPath) bool { func (m *moduleContext) skipInstall(fullInstallPath InstallPath) bool {
if m.module.base().commonProperties.SkipInstall { if m.module.base().commonProperties.SkipInstall {
return true return true
} }
@@ -1561,18 +1561,18 @@ func (m *moduleContext) skipInstall(fullInstallPath OutputPath) bool {
return false return false
} }
func (m *moduleContext) InstallFile(installPath OutputPath, name string, srcPath Path, func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
deps ...Path) OutputPath { deps ...Path) InstallPath {
return m.installFile(installPath, name, srcPath, Cp, deps) return m.installFile(installPath, name, srcPath, Cp, deps)
} }
func (m *moduleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path, func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
deps ...Path) OutputPath { deps ...Path) InstallPath {
return m.installFile(installPath, name, srcPath, CpExecutable, deps) return m.installFile(installPath, name, srcPath, CpExecutable, deps)
} }
func (m *moduleContext) installFile(installPath OutputPath, name string, srcPath Path, func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path,
rule blueprint.Rule, deps []Path) OutputPath { rule blueprint.Rule, deps []Path) InstallPath {
fullInstallPath := installPath.Join(m, name) fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, fullInstallPath, false) m.module.base().hooks.runInstallHooks(m, fullInstallPath, false)
@@ -1607,7 +1607,7 @@ func (m *moduleContext) installFile(installPath OutputPath, name string, srcPath
return fullInstallPath return fullInstallPath
} }
func (m *moduleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath { func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
fullInstallPath := installPath.Join(m, name) fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, fullInstallPath, true) m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
@@ -1636,7 +1636,7 @@ func (m *moduleContext) InstallSymlink(installPath OutputPath, name string, srcP
// installPath/name -> absPath where absPath might be a path that is available only at runtime // installPath/name -> absPath where absPath might be a path that is available only at runtime
// (e.g. /apex/...) // (e.g. /apex/...)
func (m *moduleContext) InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath { func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
fullInstallPath := installPath.Join(m, name) fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, fullInstallPath, true) m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)

View File

@@ -60,7 +60,7 @@ func MergeNotices(ctx ModuleContext, mergedNotice WritablePath, noticePaths []Pa
}) })
} }
func BuildNoticeOutput(ctx ModuleContext, installPath OutputPath, installFilename string, func BuildNoticeOutput(ctx ModuleContext, installPath InstallPath, installFilename string,
noticePaths []Path) NoticeOutputs { noticePaths []Path) NoticeOutputs {
// Merge all NOTICE files into one. // Merge all NOTICE files into one.
// TODO(jungjw): We should just produce a well-formatted NOTICE.html file in a single pass. // TODO(jungjw): We should just produce a well-formatted NOTICE.html file in a single pass.

View File

@@ -793,7 +793,7 @@ func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath {
return OptionalPathForPath(PathForSource(ctx, relPath)) return OptionalPathForPath(PathForSource(ctx, relPath))
} }
// OutputPath is a Path representing a file path rooted from the build directory // OutputPath is a Path representing an intermediates file path rooted from the build directory
type OutputPath struct { type OutputPath struct {
basePath basePath
} }
@@ -824,12 +824,12 @@ func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath {
// pathForInstallInMakeDir is used by PathForModuleInstall when the module returns true // pathForInstallInMakeDir is used by PathForModuleInstall when the module returns true
// for InstallBypassMake to produce an OutputPath that installs to $OUT_DIR instead of // for InstallBypassMake to produce an OutputPath that installs to $OUT_DIR instead of
// $OUT_DIR/soong. // $OUT_DIR/soong.
func pathForInstallInMakeDir(ctx PathContext, pathComponents ...string) OutputPath { func pathForInstallInMakeDir(ctx PathContext, pathComponents ...string) InstallPath {
path, err := validatePath(pathComponents...) path, err := validatePath(pathComponents...)
if err != nil { if err != nil {
reportPathError(ctx, err) reportPathError(ctx, err)
} }
return OutputPath{basePath{"../" + path, ctx.Config(), ""}} return InstallPath{basePath{"../" + path, ctx.Config(), ""}}
} }
// PathsForOutput returns Paths rooted from buildDir // PathsForOutput returns Paths rooted from buildDir
@@ -847,10 +847,6 @@ func (p OutputPath) String() string {
return filepath.Join(p.config.buildDir, p.path) return filepath.Join(p.config.buildDir, p.path)
} }
func (p OutputPath) RelPathString() string {
return p.path
}
// Join creates a new OutputPath with paths... joined with the current path. The // Join creates a new OutputPath with paths... joined with the current path. The
// provided paths... may not use '..' to escape from the current path. // provided paths... may not use '..' to escape from the current path.
func (p OutputPath) Join(ctx PathContext, paths ...string) OutputPath { func (p OutputPath) Join(ctx PathContext, paths ...string) OutputPath {
@@ -1119,9 +1115,39 @@ func PathForModuleRes(ctx ModuleContext, pathComponents ...string) ModuleResPath
return ModuleResPath{PathForModuleOut(ctx, "res", p)} return ModuleResPath{PathForModuleOut(ctx, "res", p)}
} }
// InstallPath is a Path representing a installed file path rooted from the build directory
type InstallPath struct {
basePath
}
func (p InstallPath) writablePath() {}
func (p InstallPath) String() string {
return filepath.Join(p.config.buildDir, p.path)
}
// Join creates a new InstallPath with paths... joined with the current path. The
// provided paths... may not use '..' to escape from the current path.
func (p InstallPath) Join(ctx PathContext, paths ...string) InstallPath {
path, err := validatePath(paths...)
if err != nil {
reportPathError(ctx, err)
}
return p.withRel(path)
}
func (p InstallPath) withRel(rel string) InstallPath {
p.basePath = p.basePath.withRel(rel)
return p
}
func (p InstallPath) RelPathString() string {
return p.path
}
// 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) OutputPath { func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
var outPaths []string var outPaths []string
if ctx.Device() { if ctx.Device() {
partition := modulePartition(ctx) partition := modulePartition(ctx)
@@ -1144,10 +1170,24 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() { if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() {
return pathForInstallInMakeDir(ctx, outPaths...) return pathForInstallInMakeDir(ctx, outPaths...)
} }
return PathForOutput(ctx, outPaths...)
path, err := validatePath(outPaths...)
if err != nil {
reportPathError(ctx, err)
}
return InstallPath{basePath{path, ctx.Config(), ""}}
} }
func InstallPathToOnDevicePath(ctx PathContext, path OutputPath) string { func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath {
paths = append([]string{"ndk"}, paths...)
path, err := validatePath(paths...)
if err != nil {
reportPathError(ctx, err)
}
return InstallPath{basePath{path, ctx.Config(), ""}}
}
func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string {
rel := Rel(ctx, PathForOutput(ctx, "target", "product", ctx.Config().DeviceName()).String(), path.String()) rel := Rel(ctx, PathForOutput(ctx, "target", "product", ctx.Config().DeviceName()).String(), path.String())
return "/" + rel return "/" + rel

View File

@@ -65,7 +65,7 @@ type PrebuiltEtc struct {
installDirBase string installDirBase string
// The base install location when soc_specific property is set to true, e.g. "firmware" for prebuilt_firmware. // The base install location when soc_specific property is set to true, e.g. "firmware" for prebuilt_firmware.
socInstallDirBase string socInstallDirBase string
installDirPath OutputPath installDirPath InstallPath
additionalDependencies *Paths additionalDependencies *Paths
} }
@@ -91,7 +91,7 @@ func (p *PrebuiltEtc) SourceFilePath(ctx ModuleContext) Path {
return PathForModuleSrc(ctx, String(p.properties.Src)) return PathForModuleSrc(ctx, String(p.properties.Src))
} }
func (p *PrebuiltEtc) InstallDirPath() OutputPath { func (p *PrebuiltEtc) InstallDirPath() InstallPath {
return p.installDirPath return p.installDirPath
} }

View File

@@ -561,8 +561,8 @@ type apexBundle struct {
bundleModuleFile android.WritablePath bundleModuleFile android.WritablePath
outputFiles map[apexPackaging]android.WritablePath outputFiles map[apexPackaging]android.WritablePath
flattenedOutput android.OutputPath flattenedOutput android.InstallPath
installDir android.OutputPath installDir android.InstallPath
prebuiltFileToDelete string prebuiltFileToDelete string
@@ -1840,7 +1840,7 @@ type Prebuilt struct {
properties PrebuiltProperties properties PrebuiltProperties
inputApex android.Path inputApex android.Path
installDir android.OutputPath installDir android.InstallPath
installFilename string installFilename string
outputApex android.WritablePath outputApex android.WritablePath
} }

View File

@@ -52,7 +52,7 @@ type baseInstaller struct {
relative string relative string
location installLocation location installLocation
path android.OutputPath path android.InstallPath
} }
var _ installer = (*baseInstaller)(nil) var _ installer = (*baseInstaller)(nil)
@@ -61,7 +61,7 @@ func (installer *baseInstaller) installerProps() []interface{} {
return []interface{}{&installer.Properties} return []interface{}{&installer.Properties}
} }
func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath { func (installer *baseInstaller) installDir(ctx ModuleContext) android.InstallPath {
dir := installer.dir dir := installer.dir
if ctx.toolchain().Is64Bit() && installer.dir64 != "" { if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
dir = installer.dir64 dir = installer.dir64

View File

@@ -791,9 +791,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
// Optimize out relinking against shared libraries whose interface hasn't changed by // Optimize out relinking against shared libraries whose interface hasn't changed by
// depending on a table of contents file instead of the library itself. // depending on a table of contents file instead of the library itself.
tocPath := outputFile.RelPathString() tocFile := outputFile.ReplaceExtension(ctx, flags.Toolchain.ShlibSuffix()[1:]+".toc")
tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
tocFile := android.PathForOutput(ctx, tocPath)
library.tocFile = android.OptionalPathForPath(tocFile) library.tocFile = android.OptionalPathForPath(tocFile)
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags) TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)

View File

@@ -48,7 +48,7 @@ func init() {
} }
// Returns the NDK base include path for use with sdk_version current. Usable with -I. // Returns the NDK base include path for use with sdk_version current. Usable with -I.
func getCurrentIncludePath(ctx android.ModuleContext) android.OutputPath { func getCurrentIncludePath(ctx android.ModuleContext) android.InstallPath {
return getNdkSysrootBase(ctx).Join(ctx, "usr/include") return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
} }
@@ -94,7 +94,7 @@ type headerModule struct {
} }
func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string, func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string,
to string) android.OutputPath { to string) android.InstallPath {
// Output path is the sysroot base + "usr/include" + to directory + directory component // Output path is the sysroot base + "usr/include" + to directory + directory component
// of the file without the leading from directory stripped. // of the file without the leading from directory stripped.
// //

View File

@@ -66,12 +66,12 @@ func init() {
pctx.Import("android/soong/android") pctx.Import("android/soong/android")
} }
func getNdkInstallBase(ctx android.PathContext) android.OutputPath { func getNdkInstallBase(ctx android.PathContext) android.InstallPath {
return android.PathForOutput(ctx, "ndk") return android.PathForNdkInstall(ctx)
} }
// Returns the main install directory for the NDK sysroot. Usable with --sysroot. // Returns the main install directory for the NDK sysroot. Usable with --sysroot.
func getNdkSysrootBase(ctx android.PathContext) android.OutputPath { func getNdkSysrootBase(ctx android.PathContext) android.InstallPath {
return getNdkInstallBase(ctx).Join(ctx, "sysroot") return getNdkInstallBase(ctx).Join(ctx, "sysroot")
} }

View File

@@ -126,7 +126,7 @@ type AndroidApp struct {
// the install APK name is normally the same as the module name, but can be overridden with PRODUCT_PACKAGE_NAME_OVERRIDES. // the install APK name is normally the same as the module name, but can be overridden with PRODUCT_PACKAGE_NAME_OVERRIDES.
installApkName string installApkName string
installDir android.OutputPath installDir android.InstallPath
onDeviceDir string onDeviceDir string
@@ -773,7 +773,7 @@ type AndroidAppImport struct {
usesLibrary usesLibrary usesLibrary usesLibrary
installPath android.OutputPath installPath android.InstallPath
} }
type AndroidAppImportProperties struct { type AndroidAppImportProperties struct {

View File

@@ -22,7 +22,7 @@ import (
type dexpreopter struct { type dexpreopter struct {
dexpreoptProperties DexpreoptProperties dexpreoptProperties DexpreoptProperties
installPath android.OutputPath installPath android.InstallPath
uncompressedDex bool uncompressedDex bool
isSDKLibrary bool isSDKLibrary bool
isTest bool isTest bool
@@ -94,7 +94,7 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool {
return false return false
} }
func odexOnSystemOther(ctx android.ModuleContext, installPath android.OutputPath) bool { func odexOnSystemOther(ctx android.ModuleContext, installPath android.InstallPath) bool {
return dexpreopt.OdexOnSystemOtherByName(ctx.ModuleName(), android.InstallPathToOnDevicePath(ctx, installPath), dexpreoptGlobalConfig(ctx)) return dexpreopt.OdexOnSystemOtherByName(ctx.ModuleName(), android.InstallPathToOnDevicePath(ctx, installPath), dexpreoptGlobalConfig(ctx))
} }

View File

@@ -1795,7 +1795,7 @@ type Binary struct {
isWrapperVariant bool isWrapperVariant bool
wrapperFile android.Path wrapperFile android.Path
binaryFile android.OutputPath binaryFile android.InstallPath
} }
func (j *Binary) HostToolPath() android.OptionalPath { func (j *Binary) HostToolPath() android.OptionalPath {

View File

@@ -30,7 +30,7 @@ type platformCompatConfig struct {
android.ModuleBase android.ModuleBase
properties platformCompatConfigProperties properties platformCompatConfigProperties
installDirPath android.OutputPath installDirPath android.InstallPath
configFile android.OutputPath configFile android.OutputPath
} }

View File

@@ -33,7 +33,7 @@ type pythonInstaller struct {
dir64 string dir64 string
relative string relative string
path android.OutputPath path android.InstallPath
androidMkSharedLibs []string androidMkSharedLibs []string
} }
@@ -47,7 +47,7 @@ func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
var _ installer = (*pythonInstaller)(nil) var _ installer = (*pythonInstaller)(nil)
func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.OutputPath { func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.InstallPath {
dir := installer.dir dir := installer.dir
if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" { if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" {
dir = installer.dir64 dir = installer.dir64

View File

@@ -94,7 +94,7 @@ type baseCompiler struct {
dir64 string dir64 string
subDir string subDir string
relative string relative string
path android.OutputPath path android.InstallPath
} }
var _ compiler = (*baseCompiler)(nil) var _ compiler = (*baseCompiler)(nil)
@@ -173,7 +173,7 @@ func (compiler *baseCompiler) crateName() string {
return compiler.Properties.Crate_name return compiler.Properties.Crate_name
} }
func (compiler *baseCompiler) installDir(ctx ModuleContext) android.OutputPath { func (compiler *baseCompiler) installDir(ctx ModuleContext) android.InstallPath {
dir := compiler.dir dir := compiler.dir
if ctx.toolchain().Is64Bit() && compiler.dir64 != "" { if ctx.toolchain().Is64Bit() && compiler.dir64 != "" {
dir = compiler.dir64 dir = compiler.dir64