Add subdir to GenPath am: 21ec49068f
am: 37e1142b77
am: d1408ab977
Change-Id: I5800f17e5ba97819a4f14308bb9b4f06c333df03
This commit is contained in:
commit
104aec53bf
6 changed files with 21 additions and 26 deletions
|
@ -94,7 +94,7 @@ type WritablePath interface {
|
|||
}
|
||||
|
||||
type genPathProvider interface {
|
||||
genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath
|
||||
genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath
|
||||
}
|
||||
type objPathProvider interface {
|
||||
objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath
|
||||
|
@ -105,9 +105,9 @@ type resPathProvider interface {
|
|||
|
||||
// GenPathWithExt derives a new file path in ctx's generated sources directory
|
||||
// from the current path, but with the new extension.
|
||||
func GenPathWithExt(ctx ModuleContext, p Path, ext string) ModuleGenPath {
|
||||
func GenPathWithExt(ctx ModuleContext, subdir string, p Path, ext string) ModuleGenPath {
|
||||
if path, ok := p.(genPathProvider); ok {
|
||||
return path.genPathWithExt(ctx, ext)
|
||||
return path.genPathWithExt(ctx, subdir, ext)
|
||||
}
|
||||
reportPathError(ctx, "Tried to create generated file from unsupported path: %s(%s)", reflect.TypeOf(p).Name(), p)
|
||||
return PathForModuleGen(ctx)
|
||||
|
@ -115,7 +115,7 @@ func GenPathWithExt(ctx ModuleContext, p Path, ext string) ModuleGenPath {
|
|||
|
||||
// ObjPathWithExt derives a new file path in ctx's object directory from the
|
||||
// current path, but with the new extension.
|
||||
func ObjPathWithExt(ctx ModuleContext, p Path, subdir, ext string) ModuleObjPath {
|
||||
func ObjPathWithExt(ctx ModuleContext, subdir string, p Path, ext string) ModuleObjPath {
|
||||
if path, ok := p.(objPathProvider); ok {
|
||||
return path.objPathWithExt(ctx, subdir, ext)
|
||||
}
|
||||
|
@ -535,8 +535,8 @@ func (p ModuleSrcPath) String() string {
|
|||
return p.sourcePath.String()
|
||||
}
|
||||
|
||||
func (p ModuleSrcPath) genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath {
|
||||
return PathForModuleGen(ctx, p.moduleDir, pathtools.ReplaceExtension(p.path, ext))
|
||||
func (p ModuleSrcPath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath {
|
||||
return PathForModuleGen(ctx, subdir, p.moduleDir, pathtools.ReplaceExtension(p.path, ext))
|
||||
}
|
||||
|
||||
func (p ModuleSrcPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
|
||||
|
@ -583,9 +583,9 @@ func PathForModuleGen(ctx ModuleContext, paths ...string) ModuleGenPath {
|
|||
}
|
||||
}
|
||||
|
||||
func (p ModuleGenPath) genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath {
|
||||
func (p ModuleGenPath) genPathWithExt(ctx ModuleContext, subdir, ext string) ModuleGenPath {
|
||||
// TODO: make a different path for local vs remote generated files?
|
||||
return PathForModuleGen(ctx, pathtools.ReplaceExtension(p.path, ext))
|
||||
return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
|
||||
}
|
||||
|
||||
func (p ModuleGenPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
|
||||
|
|
|
@ -234,7 +234,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
}
|
||||
|
||||
for i, srcFile := range srcFiles {
|
||||
objFile := android.ObjPathWithExt(ctx, srcFile, subdir, "o")
|
||||
objFile := android.ObjPathWithExt(ctx, subdir, srcFile, "o")
|
||||
|
||||
objFiles[i] = objFile
|
||||
|
||||
|
@ -285,7 +285,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
})
|
||||
|
||||
if tidy {
|
||||
tidyFile := android.ObjPathWithExt(ctx, srcFile, subdir, "tidy")
|
||||
tidyFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy")
|
||||
tidyFiles = append(tidyFiles, tidyFile)
|
||||
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
|
|
10
cc/gen.go
10
cc/gen.go
|
@ -48,7 +48,7 @@ var (
|
|||
)
|
||||
|
||||
func genYacc(ctx android.ModuleContext, yaccFile android.Path, outFile android.ModuleGenPath, yaccFlags string) (headerFile android.ModuleGenPath) {
|
||||
headerFile = android.GenPathWithExt(ctx, yaccFile, "h")
|
||||
headerFile = android.GenPathWithExt(ctx, "yacc", yaccFile, "h")
|
||||
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: yacc,
|
||||
|
@ -80,19 +80,19 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
|||
for i, srcFile := range srcFiles {
|
||||
switch srcFile.Ext() {
|
||||
case ".y":
|
||||
cFile := android.GenPathWithExt(ctx, srcFile, "c")
|
||||
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
|
||||
srcFiles[i] = cFile
|
||||
deps = append(deps, genYacc(ctx, srcFile, cFile, buildFlags.yaccFlags))
|
||||
case ".yy":
|
||||
cppFile := android.GenPathWithExt(ctx, srcFile, "cpp")
|
||||
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
|
||||
srcFiles[i] = cppFile
|
||||
deps = append(deps, genYacc(ctx, srcFile, cppFile, buildFlags.yaccFlags))
|
||||
case ".l":
|
||||
cFile := android.GenPathWithExt(ctx, srcFile, "c")
|
||||
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
|
||||
srcFiles[i] = cFile
|
||||
genLex(ctx, srcFile, cFile)
|
||||
case ".ll":
|
||||
cppFile := android.GenPathWithExt(ctx, srcFile, "cpp")
|
||||
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
|
||||
srcFiles[i] = cppFile
|
||||
genLex(ctx, srcFile, cppFile)
|
||||
case ".proto":
|
||||
|
|
11
cc/proto.go
11
cc/proto.go
|
@ -15,8 +15,6 @@
|
|||
package cc
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong/android"
|
||||
|
@ -46,17 +44,14 @@ var (
|
|||
func genProto(ctx android.ModuleContext, protoFile android.Path,
|
||||
protoFlags string) (android.ModuleGenPath, android.ModuleGenPath) {
|
||||
|
||||
outDir := android.PathForModuleGen(ctx, "proto")
|
||||
baseName := strings.TrimSuffix(protoFile.Base(), protoFile.Ext())
|
||||
|
||||
outFile := android.PathForModuleGen(ctx, "proto", ctx.ModuleDir(), baseName+".pb.cc")
|
||||
headerFile := android.PathForModuleGen(ctx, "proto", ctx.ModuleDir(), baseName+".pb.h")
|
||||
outFile := android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc")
|
||||
headerFile := android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: proto,
|
||||
Outputs: android.WritablePaths{outFile, headerFile},
|
||||
Input: protoFile,
|
||||
Args: map[string]string{
|
||||
"outDir": outDir.String(),
|
||||
"outDir": protoDir(ctx).String(),
|
||||
"protoFlags": protoFlags,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -196,7 +196,7 @@ func GenSrcsFactory() (blueprint.Module, []interface{}) {
|
|||
for _, in := range srcFiles {
|
||||
tasks = append(tasks, generateTask{
|
||||
in: android.Paths{in},
|
||||
out: android.WritablePaths{android.GenPathWithExt(ctx, in, properties.Output_extension)},
|
||||
out: android.WritablePaths{android.GenPathWithExt(ctx, "", in, properties.Output_extension)},
|
||||
})
|
||||
}
|
||||
return tasks
|
||||
|
|
|
@ -57,7 +57,7 @@ var (
|
|||
)
|
||||
|
||||
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string) android.Path {
|
||||
javaFile := android.GenPathWithExt(ctx, aidlFile, "java")
|
||||
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
|
||||
depFile := javaFile.String() + ".d"
|
||||
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
|
@ -74,7 +74,7 @@ func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string)
|
|||
}
|
||||
|
||||
func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Path {
|
||||
javaFile := android.GenPathWithExt(ctx, logtagsFile, "java")
|
||||
javaFile := android.GenPathWithExt(ctx, "logtags", logtagsFile, "java")
|
||||
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: logtags,
|
||||
|
|
Loading…
Reference in a new issue