Merge "Add test data dependencies to APEX." am: 6109adaee0
am: 5b5cecd94e
Change-Id: I2589597f744dd62d0799f20d7de79dab4e8b07ae
This commit is contained in:
commit
8d501ef107
|
@ -120,6 +120,9 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
if len(fi.symlinks) > 0 {
|
||||
fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS :=", strings.Join(fi.symlinks, " "))
|
||||
}
|
||||
if len(fi.dataPaths) > 0 {
|
||||
fmt.Println(w, "LOCAL_TEST_DATA :=", strings.Join(cc.AndroidMkDataPaths(fi.dataPaths), " "))
|
||||
}
|
||||
|
||||
if fi.module != nil && len(fi.module.NoticeFiles()) > 0 {
|
||||
fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", strings.Join(fi.module.NoticeFiles().Strings(), " "))
|
||||
|
|
10
apex/apex.go
10
apex/apex.go
|
@ -1217,6 +1217,7 @@ type apexFile struct {
|
|||
module android.Module
|
||||
// list of symlinks that will be created in installDir that point to this apexFile
|
||||
symlinks []string
|
||||
dataPaths android.Paths
|
||||
transitiveDep bool
|
||||
moduleDir string
|
||||
|
||||
|
@ -1252,16 +1253,20 @@ func (af *apexFile) Ok() bool {
|
|||
return af.builtFile != nil && af.builtFile.String() != ""
|
||||
}
|
||||
|
||||
func (af *apexFile) apexRelativePath(path string) string {
|
||||
return filepath.Join(af.installDir, path)
|
||||
}
|
||||
|
||||
// Path() returns path of this apex file relative to the APEX root
|
||||
func (af *apexFile) Path() string {
|
||||
return filepath.Join(af.installDir, af.builtFile.Base())
|
||||
return af.apexRelativePath(af.builtFile.Base())
|
||||
}
|
||||
|
||||
// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
|
||||
func (af *apexFile) SymlinkPaths() []string {
|
||||
var ret []string
|
||||
for _, symlink := range af.symlinks {
|
||||
ret = append(ret, filepath.Join(af.installDir, symlink))
|
||||
ret = append(ret, af.apexRelativePath(symlink))
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
@ -1667,6 +1672,7 @@ func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFil
|
|||
fileToCopy := cc.OutputFile().Path()
|
||||
af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
|
||||
af.symlinks = cc.Symlinks()
|
||||
af.dataPaths = cc.DataPaths()
|
||||
return af
|
||||
}
|
||||
|
||||
|
|
|
@ -180,6 +180,8 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||
"build/make/core/proguard.flags": nil,
|
||||
"build/make/core/proguard_basic_keeps.flags": nil,
|
||||
"dummy.txt": nil,
|
||||
"baz": nil,
|
||||
"bar/baz": nil,
|
||||
}
|
||||
|
||||
cc.GatherRequiredFilesForTest(fs)
|
||||
|
@ -3267,6 +3269,14 @@ func TestApexWithTests(t *testing.T) {
|
|||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "fg",
|
||||
srcs: [
|
||||
"baz",
|
||||
"bar/baz"
|
||||
],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "mytest",
|
||||
gtest: false,
|
||||
|
@ -3276,6 +3286,7 @@ func TestApexWithTests(t *testing.T) {
|
|||
system_shared_libs: [],
|
||||
static_executable: true,
|
||||
stl: "none",
|
||||
data: [":fg"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
|
@ -3308,6 +3319,10 @@ func TestApexWithTests(t *testing.T) {
|
|||
ensureContains(t, copyCmds, "image.apex/bin/test/mytest")
|
||||
ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
|
||||
|
||||
//Ensure that test data are copied into apex.
|
||||
ensureContains(t, copyCmds, "image.apex/bin/test/baz")
|
||||
ensureContains(t, copyCmds, "image.apex/bin/test/bar/baz")
|
||||
|
||||
// Ensure that test deps built with `test_per_src` are copied into apex.
|
||||
ensureContains(t, copyCmds, "image.apex/bin/test/mytest1")
|
||||
ensureContains(t, copyCmds, "image.apex/bin/test/mytest2")
|
||||
|
|
|
@ -350,6 +350,19 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
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 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||
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))
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
|||
return []android.AndroidMkEntries{entries}
|
||||
}
|
||||
|
||||
func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
|
||||
func AndroidMkDataPaths(data android.Paths) []string {
|
||||
var testFiles []string
|
||||
for _, d := range data {
|
||||
rel := d.Rel()
|
||||
|
@ -160,6 +160,11 @@ func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, entries *a
|
|||
path = strings.TrimSuffix(path, rel)
|
||||
testFiles = append(testFiles, path+":"+rel)
|
||||
}
|
||||
return testFiles
|
||||
}
|
||||
|
||||
func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
|
||||
testFiles := AndroidMkDataPaths(data)
|
||||
if len(testFiles) > 0 {
|
||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||
entries.AddStrings("LOCAL_TEST_DATA", testFiles...)
|
||||
|
|
9
cc/cc.go
9
cc/cc.go
|
@ -1395,6 +1395,15 @@ func (c *Module) IsTestPerSrcAllTestsVariation() bool {
|
|||
return ok && test.isAllTestsVariation()
|
||||
}
|
||||
|
||||
func (c *Module) DataPaths() android.Paths {
|
||||
if p, ok := c.installer.(interface {
|
||||
dataPaths() android.Paths
|
||||
}); ok {
|
||||
return p.dataPaths()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string {
|
||||
// Returns the name suffix for product and vendor variants. If the VNDK version is not
|
||||
// "current", it will append the VNDK version to the name suffix.
|
||||
|
|
|
@ -160,6 +160,10 @@ func (test *testBinary) srcs() []string {
|
|||
return test.baseCompiler.Properties.Srcs
|
||||
}
|
||||
|
||||
func (test *testBinary) dataPaths() android.Paths {
|
||||
return test.data
|
||||
}
|
||||
|
||||
func (test *testBinary) isAllTestsVariation() bool {
|
||||
stem := test.binaryDecorator.Properties.Stem
|
||||
return stem != nil && *stem == ""
|
||||
|
|
Loading…
Reference in New Issue