diff options
author | Artur Satayev <satayev@google.com> | 2020-06-24 10:17:19 +0000 |
---|---|---|
committer | Artur Satayev <satayev@google.com> | 2020-06-24 10:17:19 +0000 |
commit | 9af168d4c238e760b67012ec48ae7ff6447d44fa (patch) | |
tree | 37acdd9c72ad4d5ec3bf85b4e302b13f61c5ee3a /apex/apex_singleton.go | |
parent | a4405fa3dea15bc71534f6391d36f1a8a65a7844 (diff) |
Revert "Track allowed transitive deps in any updatable module."
Revert submission 11883270-apex-allowed-deps
Reason for revert: b/159762187 broken build
Reverted Changes:
I56771ba3f:Track allowed transitive deps in any updatable mod...
I52a4be72e:Add a check for apex/allowed_deps.txt to droidcore...
Change-Id: Iefd8a8b21c4eba6ef8dfcb3aeb5a86b9d8357255
Diffstat (limited to 'apex/apex_singleton.go')
-rw-r--r-- | apex/apex_singleton.go | 113 |
1 files changed, 16 insertions, 97 deletions
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index f96491f88..83a56a2b5 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -17,8 +17,9 @@ package apex import ( - "android/soong/android" "github.com/google/blueprint" + + "android/soong/android" ) func init() { @@ -26,121 +27,39 @@ func init() { } type apexDepsInfoSingleton struct { - allowedApexDepsInfoCheckResult android.OutputPath + // Output file with all flatlists from updatable modules' deps-info combined + updatableFlatListsPath android.OutputPath } func apexDepsInfoSingletonFactory() android.Singleton { return &apexDepsInfoSingleton{} } -var ( - mergeApexDepsInfoFilesRule = pctx.AndroidStaticRule("mergeApexDepsInfoFilesRule", blueprint.RuleParams{ +var combineFilesRule = pctx.AndroidStaticRule("combineFilesRule", + blueprint.RuleParams{ Command: "cat $out.rsp | xargs cat > $out", Rspfile: "$out.rsp", RspfileContent: "$in", - }) - - // Filter out apex dependencies that are external or safe to ignore for build determinism. - filterApexDepsRule = pctx.AndroidStaticRule("filterApexDepsRule", blueprint.RuleParams{ - Command: "cat ${in}" + - // Only track non-external dependencies, i.e. those that end up in the binary... - " | grep -v '(external)'" + - // ...and those that are safe in any apex but can be different per product. - " | grep -v 'libgcc_stripped'" + - " | grep -v 'libunwind_llvm'" + - " | grep -v 'ndk_crtbegin_so.19'" + - " | grep -v 'ndk_crtbegin_so.21'" + - " | grep -v 'ndk_crtbegin_so.27'" + - " | grep -v 'ndk_crtend_so.19'" + - " | grep -v 'ndk_crtend_so.21'" + - " | grep -v 'ndk_crtend_so.27'" + - " | grep -v 'ndk_libunwind'" + - " | grep -v 'prebuilt_libclang_rt.builtins-aarch64-android'" + - " | grep -v 'prebuilt_libclang_rt.builtins-arm-android'" + - " | grep -v 'prebuilt_libclang_rt.builtins-i686-android'" + - " | grep -v 'prebuilt_libclang_rt.builtins-x86_64-android'" + - " | grep -v 'libclang_rt.hwasan-aarch64-android.llndk'" + - " > ${out}", - }) - - diffAllowedApexDepsInfoRule = pctx.AndroidStaticRule("diffAllowedApexDepsInfoRule", blueprint.RuleParams{ - // Diff two given lists while ignoring comments in the allowed deps file - Description: "Diff ${allowed_flatlists} and ${merged_flatlists}", - Command: ` - if grep -v '^#' ${allowed_flatlists} | diff -B ${merged_flatlists} -; then - touch ${out}; - else - echo -e "\n******************************"; - echo "ERROR: go/apex-allowed-deps-error"; - echo "******************************"; - echo "Detected changes to allowed dependencies in updatable modules."; - echo "To fix and update build/soong/apex/allowed_deps.txt, please run:"; - echo "$$ (croot && build/soong/scripts/update-apex-allowed-deps.sh)"; - echo "Members of mainline-modularization@google.com will review the changes."; - echo -e "******************************\n"; - exit 1; - fi;`, - }, "allowed_flatlists", "merged_flatlists") + }, ) func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) { - modulePaths := map[string]android.Path{} + updatableFlatLists := android.Paths{} ctx.VisitAllModules(func(module android.Module) { if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok { - if !binaryInfo.Updatable() { - return - } - if path := binaryInfo.FlatListPath(); path.String() != "" { - // TODO(b/159734404): don't use module.String() to sort modules/variants. - // This is needed though, as an order of module variants may be - // different between products. - ms := module.String() - if _, ok := modulePaths[ms]; !ok { - modulePaths[ms] = path - } else if modulePaths[ms] != path { - ctx.Errorf("Mismatching output paths for the same module %v:\n%v\n%v", ms, modulePaths[ms], path) + if path := binaryInfo.FlatListPath(); path != nil { + if binaryInfo.Updatable() { + updatableFlatLists = append(updatableFlatLists, path) } } } }) - updatableFlatLists := android.Paths{} - // Avoid non-determinism by sorting module and variation names. - for _, key := range android.FirstUniqueStrings(android.SortedStringKeys(modulePaths)) { - updatableFlatLists = append(updatableFlatLists, modulePaths[key]) - } - - // Merge all individual flatlists of updatable modules into a single output file - updatableFlatListsPath := android.PathForOutput(ctx, "apex", "depsinfo", "updatable-flatlists.txt") + s.updatableFlatListsPath = android.PathForOutput(ctx, "apex", "depsinfo", "updatable-flatlists.txt") ctx.Build(pctx, android.BuildParams{ - Rule: mergeApexDepsInfoFilesRule, - Inputs: updatableFlatLists, - Output: updatableFlatListsPath, + Rule: combineFilesRule, + Description: "Generate " + s.updatableFlatListsPath.String(), + Inputs: updatableFlatLists, + Output: s.updatableFlatListsPath, }) - - // Build a filtered version of updatable flatlists without external dependencies - filteredFlatLists := android.PathForOutput(ctx, "apex", "depsinfo", "filtered-updatable-flatlists.txt") - ctx.Build(pctx, android.BuildParams{ - Rule: filterApexDepsRule, - Input: updatableFlatListsPath, - Output: filteredFlatLists, - }) - - // Check filtered version against allowed deps - allowedDeps := android.ExistentPathForSource(ctx, "build/soong/apex/allowed_deps.txt").Path() - s.allowedApexDepsInfoCheckResult = android.PathForOutput(ctx, filteredFlatLists.Rel()+".check") - ctx.Build(pctx, android.BuildParams{ - Rule: diffAllowedApexDepsInfoRule, - Input: filteredFlatLists, - Output: s.allowedApexDepsInfoCheckResult, - Args: map[string]string{ - "allowed_flatlists": allowedDeps.String(), - "merged_flatlists": filteredFlatLists.String(), - }, - }) -} - -func (s *apexDepsInfoSingleton) MakeVars(ctx android.MakeVarsContext) { - // Export check result to Make. The path is added to droidcore. - ctx.Strict("APEX_ALLOWED_DEPS_CHECK", s.allowedApexDepsInfoCheckResult.String()) } |