Merge "Add SrcPath to InstallHookContext" am: 1bb4665c40 am: 5d0dfbf87b

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1323754

Change-Id: I3a828c23ea633d1d1961845e3aff538daef3109d
This commit is contained in:
David Srbecky 2020-06-24 23:27:03 +00:00 committed by Automerger Merge Worker
commit 3a968ade8c
2 changed files with 13 additions and 4 deletions

View File

@ -120,6 +120,7 @@ func (l *loadHookContext) registerScopedModuleType(name string, factory blueprin
type InstallHookContext interface {
ModuleContext
SrcPath() Path
Path() InstallPath
Symlink() bool
}
@ -134,10 +135,17 @@ func AddInstallHook(m blueprint.Module, hook func(InstallHookContext)) {
type installHookContext struct {
ModuleContext
srcPath Path
path InstallPath
symlink bool
}
var _ InstallHookContext = &installHookContext{}
func (x *installHookContext) SrcPath() Path {
return x.srcPath
}
func (x *installHookContext) Path() InstallPath {
return x.path
}
@ -146,10 +154,11 @@ func (x *installHookContext) Symlink() bool {
return x.symlink
}
func (x *hooks) runInstallHooks(ctx ModuleContext, path InstallPath, symlink bool) {
func (x *hooks) runInstallHooks(ctx ModuleContext, srcPath Path, path InstallPath, symlink bool) {
if len(x.install) > 0 {
mctx := &installHookContext{
ModuleContext: ctx,
srcPath: srcPath,
path: path,
symlink: symlink,
}

View File

@ -1959,7 +1959,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
rule blueprint.Rule, deps []Path) InstallPath {
fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, fullInstallPath, false)
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
if !m.skipInstall(fullInstallPath) {
@ -1993,7 +1993,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, true)
if !m.skipInstall(fullInstallPath) {
@ -2022,7 +2022,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
// (e.g. /apex/...)
func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
if !m.skipInstall(fullInstallPath) {
m.Build(pctx, BuildParams{