Loading apex/androidmk.go +3 −0 Original line number Diff line number Diff line Loading @@ -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(), " ")) Loading apex/apex.go +8 −2 Original line number Diff line number Diff line Loading @@ -1213,6 +1213,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 Loading Loading @@ -1248,16 +1249,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 } Loading Loading @@ -1663,6 +1668,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 } Loading apex/apex_test.go +15 −0 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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, Loading @@ -3276,6 +3286,7 @@ func TestApexWithTests(t *testing.T) { system_shared_libs: [], static_executable: true, stl: "none", data: [":fg"], } cc_library { Loading Loading @@ -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") Loading apex/builder.go +16 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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)) } Loading cc/androidmk.go +6 −1 Original line number Diff line number Diff line Loading @@ -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() Loading @@ -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...) Loading Loading
apex/androidmk.go +3 −0 Original line number Diff line number Diff line Loading @@ -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(), " ")) Loading
apex/apex.go +8 −2 Original line number Diff line number Diff line Loading @@ -1213,6 +1213,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 Loading Loading @@ -1248,16 +1249,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 } Loading Loading @@ -1663,6 +1668,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 } Loading
apex/apex_test.go +15 −0 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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, Loading @@ -3276,6 +3286,7 @@ func TestApexWithTests(t *testing.T) { system_shared_libs: [], static_executable: true, stl: "none", data: [":fg"], } cc_library { Loading Loading @@ -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") Loading
apex/builder.go +16 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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)) } Loading
cc/androidmk.go +6 −1 Original line number Diff line number Diff line Loading @@ -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() Loading @@ -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...) Loading