Move test data installation to Soong
To generate module-info.json in Soong for b/309006256 Soong needs to know the test data paths. Moving test data installation into Soong will also help later for test suite packaging. Add ModuleContext.InstallTestData that installs the files listed in a []DataPath alongside the test. The files will also be passed to Make to allow it to continue packaging them into the test suites for now. Update the module types that are producing LOCAL_TEST_DATA entries in their Android.mk files to go through InstallTestData instead. Bug: 311428265 Test: atest --host toybox-gtests --test-timeout=120000 Change-Id: Ia8b964f86e584ea464667fd86a48d754d118bead
This commit is contained in:
@@ -153,6 +153,15 @@ type ModuleContext interface {
|
||||
// for which IsInstallDepNeeded returns true.
|
||||
InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
|
||||
|
||||
// InstallTestData creates rules to install test data (e.g. data files used during a test) into
|
||||
// the installPath directory.
|
||||
//
|
||||
// The installed files will be returned by FilesToInstall(), and the PackagingSpec for the
|
||||
// installed files will be returned by PackagingSpecs() on this module or by
|
||||
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
||||
// for which IsInstallDepNeeded returns true.
|
||||
InstallTestData(installPath InstallPath, data []DataPath) InstallPaths
|
||||
|
||||
// PackageFile creates a PackagingSpec as if InstallFile was called, but without creating
|
||||
// the rule to copy the file. This is useful to define how a module would be packaged
|
||||
// without installing it into the global installation directories.
|
||||
@@ -213,6 +222,8 @@ type moduleContext struct {
|
||||
katiInstalls []katiInstall
|
||||
katiSymlinks []katiInstall
|
||||
|
||||
testData []DataPath
|
||||
|
||||
// For tests
|
||||
buildParams []BuildParams
|
||||
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
||||
@@ -452,17 +463,17 @@ func (m *moduleContext) skipInstall() bool {
|
||||
|
||||
func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
|
||||
deps ...InstallPath) InstallPath {
|
||||
return m.installFile(installPath, name, srcPath, deps, false, nil)
|
||||
return m.installFile(installPath, name, srcPath, deps, false, true, nil)
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
|
||||
deps ...InstallPath) InstallPath {
|
||||
return m.installFile(installPath, name, srcPath, deps, true, nil)
|
||||
return m.installFile(installPath, name, srcPath, deps, true, true, nil)
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
|
||||
extraZip Path, deps ...InstallPath) InstallPath {
|
||||
return m.installFile(installPath, name, srcPath, deps, false, &extraFilesZip{
|
||||
return m.installFile(installPath, name, srcPath, deps, false, true, &extraFilesZip{
|
||||
zip: extraZip,
|
||||
dir: installPath,
|
||||
})
|
||||
@@ -488,10 +499,12 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
|
||||
}
|
||||
|
||||
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
|
||||
executable bool, extraZip *extraFilesZip) InstallPath {
|
||||
executable bool, hooks bool, extraZip *extraFilesZip) InstallPath {
|
||||
|
||||
fullInstallPath := installPath.Join(m, name)
|
||||
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
|
||||
if hooks {
|
||||
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
|
||||
}
|
||||
|
||||
if !m.skipInstall() {
|
||||
deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList())...)
|
||||
@@ -647,6 +660,19 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
|
||||
return fullInstallPath
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallTestData(installPath InstallPath, data []DataPath) InstallPaths {
|
||||
m.testData = append(m.testData, data...)
|
||||
|
||||
ret := make(InstallPaths, 0, len(data))
|
||||
for _, d := range data {
|
||||
relPath := d.ToRelativeInstallPath()
|
||||
installed := m.installFile(installPath, relPath, d.SrcPath, nil, false, false, nil)
|
||||
ret = append(ret, installed)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m *moduleContext) CheckbuildFile(srcPath Path) {
|
||||
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
||||
}
|
||||
|
Reference in New Issue
Block a user