diff options
author | Jooyung Han <jooyung@google.com> | 2021-05-26 22:20:42 +0900 |
---|---|---|
committer | Jooyung Han <jooyung@google.com> | 2021-05-26 22:20:42 +0900 |
commit | 60699b5f0010228906c13f288ae37077c326deb3 (patch) | |
tree | 9cf300c63edd50d37f6a9ff9dbb207ac71d91913 /build/aidl_gen_rule.go | |
parent | 50a1dfc98ac59c21aa935c11654bfb2602df7ee7 (diff) | |
download | aidl-60699b5f0010228906c13f288ae37077c326deb3.tar.gz |
fix import paths when compiling snapshots
When compiling snapshots we should import
- snapshot dir (e.g <foo-iface>/aidl_api/foo-iface/1)
- "current" of imported interfaces
(e.g <bar-iface>/aidl_api/bar-iface/current)
Previously, the snapshot of generated sources(e.g. hidl2aidl_test_gen)
caused the build error due to the wrong import path.
Bug: 189288369
Test: aidl_unitttests
Test: m hidl2aidl_test_gen-freeze-api
m
Change-Id: I92f8e290b89c737f4b16fc064e763bd47cd1a9da
Diffstat (limited to 'build/aidl_gen_rule.go')
-rw-r--r-- | build/aidl_gen_rule.go | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go index 74f568d0..6af65a54 100644 --- a/build/aidl_gen_rule.go +++ b/build/aidl_gen_rule.go @@ -65,6 +65,7 @@ var ( type aidlGenProperties struct { Srcs []string `android:"path"` AidlRoot string // base directory for the input aidl file + IsToT bool ImportsWithoutVersion []string Stability *string Lang string // target language [java|cpp|ndk|rust] @@ -98,7 +99,7 @@ var _ android.SourceFileProducer = (*aidlGenRule)(nil) var _ genrule.SourceFileGenerator = (*aidlGenRule)(nil) func (g *aidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - srcs, imports := getPaths(ctx, g.properties.Srcs) + srcs, imports := getPaths(ctx, g.properties.Srcs, g.properties.AidlRoot) if ctx.Failed() { return @@ -107,23 +108,10 @@ func (g *aidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { genDirTimestamp := android.PathForModuleGen(ctx, "timestamp") // $out/gen/timestamp g.implicitInputs = append(g.implicitInputs, genDirTimestamp) - var importPaths []string - importPaths = append(importPaths, imports...) - ctx.VisitDirectDeps(func(dep android.Module) { - if importedAidl, ok := dep.(*aidlInterface); ok { - importPaths = append(importPaths, importedAidl.properties.Full_import_paths...) - } else if api, ok := dep.(*aidlApi); ok { - // When compiling an AIDL interface, also make sure that each - // version of the interface is compatible with its previous version - for _, path := range api.checkApiTimestamps { - g.implicitInputs = append(g.implicitInputs, path) - } - for _, path := range api.checkHashTimestamps { - g.implicitInputs = append(g.implicitInputs, path) - } - } - }) - g.importFlags = strings.Join(wrap("-I", importPaths, ""), " ") + importPaths, implicits := getImportsFromDeps(ctx, g.properties.IsToT) + imports = append(imports, importPaths...) + + g.importFlags = strings.Join(wrap("-I", imports, ""), " ") g.genOutDir = android.PathForModuleGen(ctx) g.genHeaderDir = android.PathForModuleGen(ctx, "include") @@ -135,9 +123,10 @@ func (g *aidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { // This is to clean genOutDir before generating any file ctx.Build(pctx, android.BuildParams{ - Rule: aidlDirPrepareRule, - Inputs: srcs, - Output: genDirTimestamp, + Rule: aidlDirPrepareRule, + Implicits: implicits, + Inputs: srcs, + Output: genDirTimestamp, Args: map[string]string{ "outDir": g.genOutDir.String(), }, @@ -283,11 +272,17 @@ func (g *aidlGenRule) GeneratedHeaderDirs() android.Paths { } func (g *aidlGenRule) DepsMutator(ctx android.BottomUpMutatorContext) { - ctx.AddDependency(ctx.Module(), nil, wrap("", g.properties.ImportsWithoutVersion, aidlInterfaceSuffix)...) + // original interface + ctx.AddDependency(ctx.Module(), interfaceDep, g.properties.BaseName+aidlInterfaceSuffix) + if !proptools.Bool(g.properties.Unstable) { - ctx.AddDependency(ctx.Module(), nil, g.properties.BaseName+aidlApiSuffix) + // for checkapi timestamps + ctx.AddDependency(ctx.Module(), apiDep, g.properties.BaseName+aidlApiSuffix) } + // imported interfaces + ctx.AddDependency(ctx.Module(), importInterfaceDep, wrap("", g.properties.ImportsWithoutVersion, aidlInterfaceSuffix)...) + ctx.AddReverseDependency(ctx.Module(), nil, aidlMetadataSingletonName) } |