platform_build/tools/generate-enforce-rro-android-manifest.py
Jaekyun Seok 39f97ae22a Enforce RROs for all the build-time ROs
This CL is to generate every static RRO package for its target package
automatically at build-time.

BOARD_ENFORCE_RRO build variable is added to specify whether enforcing
RRO is required or not.

BOARD_ENFORCE_RRO_EXEMPT_SOURCES build variable is added to specify
the module list of which item should be exempt from enforcing RRO.

Test: tested on bullhead and sailfish
Bug: 34097942
Change-Id: I455b2ce34e66c57a540c299b5e378b7c4e78d5b8
(cherry picked from commit 3070610b72)
2017-03-30 10:43:38 +09:00

65 lines
2 KiB
Python
Executable file

#!/usr/bin/env python
#
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Utility to generate the Android manifest file of runtime resource overlay
package for source module.
"""
from xml.dom.minidom import parseString
import argparse
import os
import sys
ANDROID_MANIFEST_TEMPLATE="""<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="%s.auto_generated_rro__"
android:versionCode="1"
android:versionName="1.0">
<overlay android:targetPackage="%s" android:priority="0" android:isStatic="true"/>
</manifest>
"""
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'-u', '--use-package-name', action='store_true',
help='Indicate that --package-info is a package name.')
parser.add_argument(
'-p', '--package-info', required=True,
help='Manifest package name or manifest file path of source module.')
parser.add_argument(
'-o', '--output', required=True,
help='Output manifest file path.')
return parser.parse_args()
def main(argv):
args = get_args()
package_name = args.package_info
if not args.use_package_name:
with open(args.package_info) as f:
data = f.read()
f.close()
dom = parseString(data)
package_name = dom.documentElement.getAttribute('package')
with open(args.output, 'w+') as f:
f.write(ANDROID_MANIFEST_TEMPLATE % (package_name, package_name))
f.close()
if __name__ == "__main__":
main(sys.argv)