Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fef9d4b6 authored by Christopher Parsons's avatar Christopher Parsons Committed by Gerrit Code Review
Browse files

Merge "Install data_libs using relative_install_path property"

parents 8481186d 216e10a0
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1555,3 +1555,15 @@ func absolutePath(path string) string {
	}
	return filepath.Join(absSrcDir, path)
}

// A DataPath represents the path of a file to be used as data, for example
// a test library to be installed alongside a test.
// The data file should be installed (copied from `<SrcPath>`) to
// `<install_root>/<RelativeInstallPath>/<filename>`, or
// `<install_root>/<filename>` if RelativeInstallPath is empty.
type DataPath struct {
	// The path of the data file that should be copied into the data directory
	SrcPath Path
	// The install path of the data file, relative to the install root.
	RelativeInstallPath string
}
+2 −2
Original line number Diff line number Diff line
@@ -116,9 +116,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, " "))
			}
			newDataPaths := []android.Path{}
			newDataPaths := []android.DataPath{}
			for _, path := range fi.dataPaths {
				dataOutPath := modulePath + ":" + path.Rel()
				dataOutPath := modulePath + ":" + path.SrcPath.Rel()
				if ok := seenDataOutPaths[dataOutPath]; !ok {
					newDataPaths = append(newDataPaths, path)
					seenDataOutPaths[dataOutPath] = true
+1 −1
Original line number Diff line number Diff line
@@ -1145,7 +1145,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
	dataPaths     []android.DataPath
	transitiveDep bool
	moduleDir     string

+5 −5
Original line number Diff line number Diff line
@@ -403,16 +403,16 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
		}
		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()
			relPath := d.SrcPath.Rel()
			dataPath := d.SrcPath.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)
			copyCommands = append(copyCommands, "cp -f "+d.SrcPath.String()+" "+dataDest)
			implicitInputs = append(implicitInputs, d.SrcPath)
		}
	}

@@ -473,7 +473,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
			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()))
					readOnlyPaths = append(readOnlyPaths, filepath.Join(f.installDir, d.SrcPath.Rel()))
				}
				for _, s := range f.symlinks {
					executablePaths = append(executablePaths, filepath.Join(f.installDir, s))
+14 −7
Original line number Diff line number Diff line
@@ -149,21 +149,25 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
	return []android.AndroidMkEntries{entries}
}

func AndroidMkDataPaths(data android.Paths) []string {
func AndroidMkDataPaths(data []android.DataPath) []string {
	var testFiles []string
	for _, d := range data {
		rel := d.Rel()
		path := d.String()
		rel := d.SrcPath.Rel()
		path := d.SrcPath.String()
		if !strings.HasSuffix(path, rel) {
			panic(fmt.Errorf("path %q does not end with %q", path, rel))
		}
		path = strings.TrimSuffix(path, rel)
		testFiles = append(testFiles, path+":"+rel)
		testFileString := path + ":" + rel
		if len(d.RelativeInstallPath) > 0 {
			testFileString += ":" + d.RelativeInstallPath
		}
		testFiles = append(testFiles, testFileString)
	}
	return testFiles
}

func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
	testFiles := AndroidMkDataPaths(data)
	if len(testFiles) > 0 {
		entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
@@ -357,8 +361,11 @@ func (benchmark *benchmarkDecorator) AndroidMkEntries(ctx AndroidMkContext, entr
			entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
		}
	})

	androidMkWriteTestData(benchmark.data, ctx, entries)
	dataPaths := []android.DataPath{}
	for _, srcPath := range benchmark.data {
		dataPaths = append(dataPaths, android.DataPath{SrcPath: srcPath})
	}
	androidMkWriteTestData(dataPaths, ctx, entries)
}

func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Loading