Add test data dependencies to APEX.
Test: soong go tests
Bug: 155820504
Change-Id: If96d82c27f19953e34efb31f2111f1643c0c4008
diff --git a/apex/builder.go b/apex/builder.go
index ca24f2c..47ae501 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -350,6 +350,19 @@
symlinkDest := android.PathForModuleOut(ctx, "image"+suffix, symlinkPath).String()
copyCommands = append(copyCommands, "ln -sfn "+filepath.Base(destPath)+" "+symlinkDest)
}
+ for _, d := range fi.dataPaths {
+ // TODO(eakammer): This is now the third repetition of ~this logic for test paths, refactoring should be possible
+ relPath := d.Rel()
+ dataPath := d.String()
+ if !strings.HasSuffix(dataPath, relPath) {
+ panic(fmt.Errorf("path %q does not end with %q", dataPath, relPath))
+ }
+
+ dataDest := android.PathForModuleOut(ctx, "image"+suffix, fi.apexRelativePath(relPath)).String()
+
+ copyCommands = append(copyCommands, "cp -f "+d.String()+" "+dataDest)
+ implicitInputs = append(implicitInputs, d)
+ }
}
// TODO(jiyong): use RuleBuilder
@@ -406,6 +419,9 @@
pathInApex := filepath.Join(f.installDir, f.builtFile.Base())
if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") {
executablePaths = append(executablePaths, pathInApex)
+ for _, d := range f.dataPaths {
+ readOnlyPaths = append(readOnlyPaths, filepath.Join(f.installDir, d.Rel()))
+ }
for _, s := range f.symlinks {
executablePaths = append(executablePaths, filepath.Join(f.installDir, s))
}