diff options
author | 2023-11-15 12:39:40 -0800 | |
---|---|---|
committer | 2023-11-30 13:38:49 -0800 | |
commit | 5c1d5fb21b19d6bcc8b0f83bc68124c21b31fabc (patch) | |
tree | 5cf196863f57dfc7ae817cf9ede98cf53126559f /android/module_context.go | |
parent | 312634eb0fd02c2e084a6925c4f00e5fc00fca54 (diff) |
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
Diffstat (limited to 'android/module_context.go')
-rw-r--r-- | android/module_context.go | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/android/module_context.go b/android/module_context.go index a0a410428..39986df87 100644 --- a/android/module_context.go +++ b/android/module_context.go @@ -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) } |