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
This commit is contained in:
parent
a4405fa3de
commit
9af168d4c2
4 changed files with 17 additions and 5215 deletions
|
@ -1,4 +1 @@
|
|||
per-file * = jiyong@google.com
|
||||
|
||||
per-file allowed_deps.txt = set noparent
|
||||
per-file allowed_deps.txt = dariofreni@google.com,hansson@google.com,harpin@google.com,jiyong@google.com,narayan@google.com,omakoto@google.com,jham@google.com
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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,
|
||||
Rule: combineFilesRule,
|
||||
Description: "Generate " + s.updatableFlatListsPath.String(),
|
||||
Inputs: updatableFlatLists,
|
||||
Output: 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(),
|
||||
},
|
||||
Output: s.updatableFlatListsPath,
|
||||
})
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
#
|
||||
# The script to run locally to re-generate global allowed list of dependencies
|
||||
# for updatable modules.
|
||||
|
||||
if [ ! -e "build/envsetup.sh" ]; then
|
||||
echo "ERROR: $0 must be run from the top of the tree"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source build/envsetup.sh > /dev/null || exit 1
|
||||
|
||||
readonly ALLOWED_DEPS_FILE="build/soong/apex/allowed_deps.txt"
|
||||
readonly OUT_DIR=$(get_build_var OUT_DIR)
|
||||
readonly FILTERED_UPDATABLE_FLATLISTS="${OUT_DIR}/soong/apex/depsinfo/filtered-updatable-flatlists.txt"
|
||||
|
||||
# If the script is run after droidcore failure, ${FILTERED_UPDATABLE_FLATLISTS}
|
||||
# should already be built. If running the script manually, make sure it exists.
|
||||
m "${FILTERED_UPDATABLE_FLATLISTS}"
|
||||
|
||||
cat > "${ALLOWED_DEPS_FILE}" << EndOfFileComment
|
||||
# A list of allowed dependencies for all updatable modules.
|
||||
#
|
||||
# The list tracks all direct and transitive dependencies that end up within any of the updatable
|
||||
# binaries; specifically excluding external dependencies required to compile those binaries. This
|
||||
# prevents potential regressions in case a new dependency is not aware of the different functional
|
||||
# and non-functional requirements being part of an updatable module (e.g. min_sdk_version).
|
||||
#
|
||||
# To update the list, run:
|
||||
# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh
|
||||
#
|
||||
# See go/apex-allowed-deps-error for more details.
|
||||
# TODO(b/157465465): introduce automated quality signals and remove this list.
|
||||
|
||||
EndOfFileComment
|
||||
|
||||
cat "${FILTERED_UPDATABLE_FLATLISTS}" >> "${ALLOWED_DEPS_FILE}"
|
Loading…
Reference in a new issue