diff options
author | 2022-03-25 18:25:00 +0000 | |
---|---|---|
committer | 2022-03-29 16:08:43 +0000 | |
commit | 9e5cc8a6741e07cd9c433913016a9c8ce39f957e (patch) | |
tree | 6b785028fd746cd4ba7ee4e825a28227d38f9fc6 /snapshot | |
parent | ac38c0bb93b57a295171f6f16edfe9dd2eed18a9 (diff) |
Add pre-built attribute to host module definition for fake snapshot.
The host-snapshot provides host tools via prebuilt modules.
Having 2 prebuilts of the same module in a source tree leads to a build
time error. Add new attribute when building the fake snapshot to
indicate that the host tool contains a prebuilt version.
When installing the host snapshot the user can opt not to include
modules that have a prebuilt version.
Bug: 225890931
Test: m HOST_FAKE_SNAPSHOT_ENABLE=true host-fake-snapshot dist
Change-Id: I044a92a280536f9c5ec93dcb277a5e5568cc4e42
Diffstat (limited to 'snapshot')
-rw-r--r-- | snapshot/host_fake_snapshot.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/snapshot/host_fake_snapshot.go b/snapshot/host_fake_snapshot.go index 1a75f3a65..b04657d3d 100644 --- a/snapshot/host_fake_snapshot.go +++ b/snapshot/host_fake_snapshot.go @@ -68,6 +68,12 @@ func init() { registerHostSnapshotComponents(android.InitRegistrationContext) } +// Add prebuilt information to snapshot data +type hostSnapshotFakeJsonFlags struct { + SnapshotJsonFlags + Prebuilt bool `json:",omitempty"` +} + func registerHostSnapshotComponents(ctx android.RegistrationContext) { ctx.RegisterSingletonType("host-fake-snapshot", HostToolsFakeAndroidSingleton) } @@ -94,7 +100,9 @@ func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) { // Find all host binary modules add 'fake' versions to snapshot var outputs android.Paths seen := make(map[string]bool) - var jsonData []SnapshotJsonFlags + var jsonData []hostSnapshotFakeJsonFlags + prebuilts := make(map[string]bool) + ctx.VisitAllModules(func(module android.Module) { if module.Target().Os != ctx.Config().BuildOSTarget.Os { return @@ -104,9 +112,10 @@ func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) { } if android.IsModulePrebuilt(module) { + // Add non-prebuilt module name to map of prebuilts + prebuilts[android.RemoveOptionalPrebuiltPrefix(module.Name())] = true return } - if !module.Enabled() || module.IsHideFromMake() { return } @@ -120,11 +129,17 @@ func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) { if !seen[outFile] { seen[outFile] = true outputs = append(outputs, WriteStringToFileRule(ctx, "", outFile)) - jsonData = append(jsonData, *hostJsonDesc(module)) + jsonData = append(jsonData, hostSnapshotFakeJsonFlags{*hostJsonDesc(module), false}) } } }) - + // Update any module prebuilt information + for idx, _ := range jsonData { + if _, ok := prebuilts[jsonData[idx].ModuleName]; ok { + // Prebuilt exists for this module + jsonData[idx].Prebuilt = true + } + } marsh, err := json.Marshal(jsonData) if err != nil { ctx.Errorf("host fake snapshot json marshal failure: %#v", err) |