Use aidl_library in cc libraries
Introduce aidl.libs prop on cc libraries to pass in aidl_library. The goal is to eventually disallow aidl.include_dirs (a pattern for passing aidl headers dir for aidl compilation) and enforce aidl headers to be explicitly specified in Android.bp. Bug: 278704136 Test: go test Change-Id: Ia78bc11dfa12f47d2d1bb90dc65372ddb17f7e14
This commit is contained in:
33
cc/gen.go
33
cc/gen.go
@@ -18,7 +18,9 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"android/soong/aidl_library"
|
||||
"android/soong/bazel"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong/android"
|
||||
@@ -124,11 +126,6 @@ func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile andr
|
||||
headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h")
|
||||
headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h")
|
||||
|
||||
baseDir := strings.TrimSuffix(aidlFile.String(), aidlFile.Rel())
|
||||
if baseDir != "" {
|
||||
aidlFlags += " -I" + baseDir
|
||||
}
|
||||
|
||||
cmd := rule.Command()
|
||||
cmd.BuiltTool("aidl-cpp").
|
||||
FlagWithDepFile("-d", depFile).
|
||||
@@ -282,7 +279,10 @@ type generatedSourceInfo struct {
|
||||
syspropOrderOnlyDeps android.Paths
|
||||
}
|
||||
|
||||
func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
func genSources(
|
||||
ctx android.ModuleContext,
|
||||
aidlLibraryInfos []aidl_library.AidlLibraryInfo,
|
||||
srcFiles android.Paths,
|
||||
buildFlags builderFlags) (android.Paths, android.Paths, generatedSourceInfo) {
|
||||
|
||||
var info generatedSourceInfo
|
||||
@@ -330,7 +330,8 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
aidlRule = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "aidl"),
|
||||
android.PathForModuleGen(ctx, "aidl.sbox.textproto"))
|
||||
}
|
||||
cppFile, aidlHeaders := genAidl(ctx, aidlRule, srcFile, buildFlags.aidlFlags)
|
||||
baseDir := strings.TrimSuffix(srcFile.String(), srcFile.Rel())
|
||||
cppFile, aidlHeaders := genAidl(ctx, aidlRule, srcFile, buildFlags.aidlFlags+" -I"+baseDir)
|
||||
srcFiles[i] = cppFile
|
||||
|
||||
info.aidlHeaders = append(info.aidlHeaders, aidlHeaders...)
|
||||
@@ -352,6 +353,24 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
}
|
||||
}
|
||||
|
||||
for _, aidlLibraryInfo := range aidlLibraryInfos {
|
||||
for _, aidlSrc := range aidlLibraryInfo.Srcs {
|
||||
if aidlRule == nil {
|
||||
// TODO(b/279960133): Sandbox inputs to ensure aidl headers are explicitly specified
|
||||
aidlRule = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "aidl"),
|
||||
android.PathForModuleGen(ctx, "aidl.sbox.textproto"))
|
||||
}
|
||||
cppFile, aidlHeaders := genAidl(ctx, aidlRule, aidlSrc, buildFlags.aidlFlags)
|
||||
|
||||
srcFiles = append(srcFiles, cppFile)
|
||||
info.aidlHeaders = append(info.aidlHeaders, aidlHeaders...)
|
||||
// Use the generated headers as order only deps to ensure that they are up to date when
|
||||
// needed.
|
||||
// TODO: Reduce the size of the ninja file by using one order only dep for the whole rule
|
||||
info.aidlOrderOnlyDeps = append(info.aidlOrderOnlyDeps, aidlHeaders...)
|
||||
}
|
||||
}
|
||||
|
||||
if aidlRule != nil {
|
||||
aidlRule.Build("aidl", "gen aidl")
|
||||
}
|
||||
|
Reference in New Issue
Block a user