Use correct install paths in generated Android.mk

Extract Soong's install path and put it in the generated Android.mk file
so that tests get installed in the correct place.

Change-Id: Id4726855c5677855406de20773a5da533bdd4cea
This commit is contained in:
Colin Cross
2016-03-24 13:14:12 -07:00
parent ca860ac720
commit a23446680f
5 changed files with 28 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ package cc
import ( import (
"fmt" "fmt"
"io" "io"
"path/filepath"
"strings" "strings"
"android/soong/common" "android/soong/common"
@@ -105,5 +106,17 @@ func (binary *binaryLinker) AndroidMk(ret *common.AndroidMkData) {
} }
func (test *testLinker) AndroidMk(ret *common.AndroidMkData) { func (test *testLinker) AndroidMk(ret *common.AndroidMkData) {
ret.Disabled = true test.binaryLinker.AndroidMk(ret)
if Bool(test.Properties.Test_per_src) {
ret.SubName = test.binaryLinker.Properties.Stem
}
}
func (installer *baseInstaller) AndroidMk(ret *common.AndroidMkData) {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error {
path := installer.path.RelPathString()
fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Dir(path))
fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+filepath.Base(path))
return nil
})
} }

View File

@@ -1195,7 +1195,7 @@ type baseInstaller struct {
dir64 string dir64 string
data bool data bool
path common.Path path common.OutputPath
} }
var _ installer = (*baseInstaller)(nil) var _ installer = (*baseInstaller)(nil)

View File

@@ -38,6 +38,7 @@ type AndroidMkDataProvider interface {
type AndroidMkData struct { type AndroidMkData struct {
Class string Class string
SubName string
OutputFile OptionalPath OutputFile OptionalPath
Disabled bool Disabled bool
@@ -141,6 +142,10 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
return err return err
} }
if data.SubName != "" {
name += "_" + data.SubName
}
hostCross := false hostCross := false
if amod.Host() && amod.HostType() != CurrentHostType() { if amod.Host() && amod.HostType() != CurrentHostType() {
hostCross = true hostCross = true

View File

@@ -76,8 +76,8 @@ type AndroidModuleContext interface {
ExpandSources(srcFiles, excludes []string) Paths ExpandSources(srcFiles, excludes []string) Paths
Glob(outDir, globPattern string, excludes []string) Paths Glob(outDir, globPattern string, excludes []string) Paths
InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path InstallFile(installPath OutputPath, srcPath Path, deps ...Path) OutputPath
InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) Path InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
CheckbuildFile(srcPath Path) CheckbuildFile(srcPath Path)
AddMissingDependencies(deps []string) AddMissingDependencies(deps []string)
@@ -531,7 +531,7 @@ func (a *androidBaseContextImpl) InstallInData() bool {
} }
func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path, func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path,
deps ...Path) Path { deps ...Path) OutputPath {
fullInstallPath := installPath.Join(a, name) fullInstallPath := installPath.Join(a, name)
@@ -552,7 +552,7 @@ func (a *androidModuleContext) InstallFileName(installPath OutputPath, name stri
return fullInstallPath return fullInstallPath
} }
func (a *androidModuleContext) InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path { func (a *androidModuleContext) InstallFile(installPath OutputPath, srcPath Path, deps ...Path) OutputPath {
return a.InstallFileName(installPath, filepath.Base(srcPath.String()), srcPath, deps...) return a.InstallFileName(installPath, filepath.Base(srcPath.String()), srcPath, deps...)
} }

View File

@@ -478,6 +478,10 @@ func (p OutputPath) String() string {
return filepath.Join(p.config.buildDir, p.path) return filepath.Join(p.config.buildDir, p.path)
} }
func (p OutputPath) RelPathString() string {
return p.path
}
// Join creates a new OutputPath with paths... joined with the current path. The // Join creates a new OutputPath with paths... joined with the current path. The
// provided paths... may not use '..' to escape from the current path. // provided paths... may not use '..' to escape from the current path.
func (p OutputPath) Join(ctx PathContext, paths ...string) OutputPath { func (p OutputPath) Join(ctx PathContext, paths ...string) OutputPath {