From e922d2139dd4fec6fdae4a6e71ec62de264bd212 Mon Sep 17 00:00:00 2001 From: Alexei Nicoara Date: Fri, 8 Jul 2022 15:24:41 +0100 Subject: [PATCH] Replace version 0 with the default version Having 0 as the default version causes problems in flattened apexes and is being parsed in protobuf as non-existing field. It will be hard to revert 100 of commits for all the modules. Changing the version in soong to mitigate time impact. Test: presubmit, checked .intermediary jsons Bug: 231691643 Change-Id: I451186d79fd9f8345fd4e28d9daadbfc59047445 --- apex/builder.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apex/builder.go b/apex/builder.go index e3c447632..dda342f82 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -93,6 +93,11 @@ var ( Description: "strip ${in}=>${out}", }) + setVersionApexManifestRule = pctx.StaticRule("setVersionApexManifestRule", blueprint.RuleParams{ + Command: `sed 's/\"version\":\s*0\([^0-9]*\)$$/\"version\":\ ${default_version}\1/' $in > $out`, + Description: "Replace 'version: 0' with the correct version // ${in}=>${out}", + }, "default_version") + pbApexManifestRule = pctx.StaticRule("pbApexManifestRule", blueprint.RuleParams{ Command: `rm -f $out && ${conv_apex_manifest} proto $in -o $out`, CommandDeps: []string{"${conv_apex_manifest}"}, @@ -219,10 +224,20 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, Output: manifestJsonCommentsStripped, }) + manifestJsonVersionChanged := android.PathForModuleOut(ctx, "apex_manifest_version_changed.json") + ctx.Build(pctx, android.BuildParams{ + Rule: setVersionApexManifestRule, + Input: manifestJsonCommentsStripped, + Output: manifestJsonVersionChanged, + Args: map[string]string{ + "default_version": defaultManifestVersion, + }, + }) + manifestJsonFullOut := android.PathForModuleOut(ctx, "apex_manifest_full.json") ctx.Build(pctx, android.BuildParams{ Rule: apexManifestRule, - Input: manifestJsonCommentsStripped, + Input: manifestJsonVersionChanged, Output: manifestJsonFullOut, Args: map[string]string{ "provideNativeLibs": strings.Join(provideNativeLibs, " "),