cpp output of an AIDL file is together with the headers
For an AIDL file, five files are generated for the CPP backend: cpp output, depfile, and three headers. Previously, the cpp output and the dep file were created at <module_out>/gen/<abs_path_to_input_aidl>.cpp, while the headers were at <module_out>/gen/aidl/<package_name>/*.h. This not only looks inconsistent, but more critically makes it difficult for the aidl compiler to infer the path to the headers that the build system registered as implicit outputs. Inferring the implicit outputs by the aidl compiler is needed because otherwise users will see the error message from sbox just saying that some of the expected files are not created. This can happen when the input AIDL file is put directly into the srcs property without specifying the base directory, e.g. some/subdir/android/foo/IFoo.aidl where the pacakge is actually android.foo. In order to make it easy for developers to fix such an error, I0f23b6027ba3a4755cc2901f4a7f7fc70bffd0ef introduces a check in the aidl compiler which is triggered earlier than the sbox error. The compiler now enforces that the cpp output is at <out_dir>/<package_name>/<type>.app. When the check fails, it suggests to fix that by correctly feeding the AIDL file via filegroup and the path property. This change in Soong is required to satisfy aidl compiler when the base directory is correctly set. The cpp output is now at <module_out>/gen/aidl/<pacakge_name>/<type>.cpp. Bug: 184586092 Test: aidl_unittests Change-Id: I172180a40bded4f6c08679a2d862b086998be1e1
This commit is contained in:
parent
8c56183fb7
commit
c7e592cdef
15
cc/gen.go
15
cc/gen.go
|
@ -111,9 +111,7 @@ func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile andr
|
|||
return ret
|
||||
}
|
||||
|
||||
func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile android.Path,
|
||||
outFile, depFile android.ModuleGenPath, aidlFlags string) android.Paths {
|
||||
|
||||
func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile android.Path, aidlFlags string) (cppFile android.OutputPath, headerFiles android.Paths) {
|
||||
aidlPackage := strings.TrimSuffix(aidlFile.Rel(), aidlFile.Base())
|
||||
baseName := strings.TrimSuffix(aidlFile.Base(), aidlFile.Ext())
|
||||
shortName := baseName
|
||||
|
@ -126,6 +124,8 @@ func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile andr
|
|||
}
|
||||
|
||||
outDir := android.PathForModuleGen(ctx, "aidl")
|
||||
cppFile = outDir.Join(ctx, aidlPackage, baseName+".cpp")
|
||||
depFile := outDir.Join(ctx, aidlPackage, baseName+".cpp.d")
|
||||
headerI := outDir.Join(ctx, aidlPackage, baseName+".h")
|
||||
headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h")
|
||||
headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h")
|
||||
|
@ -142,14 +142,14 @@ func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile andr
|
|||
Flag(aidlFlags).
|
||||
Input(aidlFile).
|
||||
OutputDir().
|
||||
Output(outFile).
|
||||
Output(cppFile).
|
||||
ImplicitOutputs(android.WritablePaths{
|
||||
headerI,
|
||||
headerBn,
|
||||
headerBp,
|
||||
})
|
||||
|
||||
return android.Paths{
|
||||
return cppFile, android.Paths{
|
||||
headerI,
|
||||
headerBn,
|
||||
headerBp,
|
||||
|
@ -293,10 +293,9 @@ 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 := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp")
|
||||
depFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp.d")
|
||||
cppFile, aidlHeaders := genAidl(ctx, aidlRule, srcFile, buildFlags.aidlFlags)
|
||||
srcFiles[i] = cppFile
|
||||
aidlHeaders := genAidl(ctx, aidlRule, srcFile, cppFile, depFile, buildFlags.aidlFlags)
|
||||
|
||||
info.aidlHeaders = append(info.aidlHeaders, aidlHeaders...)
|
||||
// Use the generated headers as order only deps to ensure that they are up to date when
|
||||
// needed.
|
||||
|
|
Loading…
Reference in New Issue