From d9e05750ba0f91f1a492ce95187237db859db887 Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Tue, 13 Jul 2021 11:36:24 +0900 Subject: [PATCH] Export paths for the snapshot modules Some makefiles require the paths to the snapshot to use the snapshot resources. Export SOONG_{IMAGE}_{VERSION}_SNAPSHOT_DIR to make. Bug: 187222756 Test: check ninja depedency with and without snasphots. Change-Id: Ie817285d43db094335e4c81ebb6eca7007c5f37d --- cc/snapshot_prebuilt.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go index fb89224f3..4f031ff96 100644 --- a/cc/snapshot_prebuilt.go +++ b/cc/snapshot_prebuilt.go @@ -264,6 +264,7 @@ var recoverySnapshotImageSingleton recoverySnapshotImage func init() { VendorSnapshotImageSingleton.Init(android.InitRegistrationContext) recoverySnapshotImageSingleton.init(android.InitRegistrationContext) + android.RegisterMakeVarsProvider(pctx, snapshotMakeVarsProvider) } const ( @@ -383,6 +384,24 @@ var SnapshotInfoProvider = blueprint.NewMutatorProvider(SnapshotInfo{}, "deps") var _ android.ImageInterface = (*snapshot)(nil) +func snapshotMakeVarsProvider(ctx android.MakeVarsContext) { + snapshotSet := map[string]struct{}{} + ctx.VisitAllModules(func(m android.Module) { + if s, ok := m.(*snapshot); ok { + if _, ok := snapshotSet[s.Name()]; ok { + // arch variant generates duplicated modules + // skip this as we only need to know the path of the module. + return + } + snapshotSet[s.Name()] = struct{}{} + imageNameVersion := strings.Split(s.image.imageVariantName(ctx.DeviceConfig()), ".") + ctx.Strict( + strings.Join([]string{strings.ToUpper(imageNameVersion[0]), s.baseSnapshot.Version(), "SNAPSHOT_DIR"}, "_"), + ctx.ModuleDir(s)) + } + }) +} + func vendorSnapshotFactory() android.Module { return snapshotFactory(VendorSnapshotImageSingleton) }