diff options
author | 2021-07-20 14:27:32 +0100 | |
---|---|---|
committer | 2021-07-20 14:30:40 +0100 | |
commit | 1b513458b163c393e2d7fe14966d9b4432852675 (patch) | |
tree | 6c35ac965e1a679e4bc2d87acbe847b3d3743aaa /scripts/manifest_check.py | |
parent | ae86338676084cf5966adf99f34e7086f9687edc (diff) |
manifest_check.py: trim namespace part of the module, if needed.
Normally Soong does that automatically when it handles module names
specified in Android.bp properties. However not all <uses-library>
entries in the manifest correspond to real modules: some of the
optional libraries may be missing at build time. Therefor this script
accepts raw module names as spelled in Android.bp/Amdroid.mk and trims
the optional namespace part manually.
Bug: 193891722
Test: manifest_check_test.py
Test: $ lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd
$ adb wait-for-device && \
adb root && \
adb logcat | \
grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C1
# empty output, no errors
Change-Id: I184fb8a2dc26f49e90fb597ebcd6a58c00705206
Diffstat (limited to 'scripts/manifest_check.py')
-rwxr-xr-x | scripts/manifest_check.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py index 8168fbf6a..4ef4399ca 100755 --- a/scripts/manifest_check.py +++ b/scripts/manifest_check.py @@ -90,6 +90,15 @@ def enforce_uses_libraries(manifest, required, optional, relax, is_apk, path): else: manifest_required, manifest_optional, tags = extract_uses_libs_xml(manifest) + # Trim namespace component. Normally Soong does that automatically when it + # handles module names specified in Android.bp properties. However not all + # <uses-library> entries in the manifest correspond to real modules: some of + # the optional libraries may be missing at build time. Therefor this script + # accepts raw module names as spelled in Android.bp/Amdroid.mk and trims the + # optional namespace part manually. + required = trim_namespace_parts(required) + optional = trim_namespace_parts(optional) + if manifest_required == required and manifest_optional == optional: return None @@ -118,6 +127,17 @@ def enforce_uses_libraries(manifest, required, optional, relax, is_apk, path): return errmsg +MODULE_NAMESPACE = re.compile("^//[^:]+:") + +def trim_namespace_parts(modules): + """Trim the namespace part of each module, if present. Leave only the name.""" + + trimmed = [] + for module in modules: + trimmed.append(MODULE_NAMESPACE.sub('', module)) + return trimmed + + def extract_uses_libs_apk(badging): """Extract <uses-library> tags from the manifest of an APK.""" |