First, version.txt will be stamped by Android CI with a release candidate name like "ZV1A.240307.001". Next, a genrule will read version.txt and embed the release candidate name inside the Widevine CDM binary. See also: - go/wv-trunk "Versioning" - cl/616721723 Bug: 327241925 Test: Coastguard Change-Id: I892ee957c058ac5f624912a38a048781af5f3487
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
import argparse
|
|
import datetime
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
CDM_MAJOR = 19
|
|
CDM_MINOR = 0
|
|
|
|
def get_build_id(args):
|
|
with args.version_txt as file:
|
|
return file.read().strip()
|
|
|
|
|
|
def hdr(args):
|
|
output = f'''\
|
|
#ifndef {args.guard}
|
|
#define {args.guard}
|
|
|
|
#define WV_ANDROID_BUILD_ID "{get_build_id(args)}"
|
|
|
|
#endif // {args.guard}'''
|
|
print(output)
|
|
|
|
|
|
def apex_manifest(args):
|
|
rc = get_build_id(args)
|
|
m = re.match(r'[A-Z0-9]{4}\.(?P<build_date>\d{6})\.', rc)
|
|
if m:
|
|
v = int(f'{CDM_MAJOR}{CDM_MINOR}{m["build_date"]}')
|
|
else:
|
|
v = 1
|
|
|
|
out = dict(name=args.name, version=v, requireNativeLibs=['liboemcrypto.so'])
|
|
print(json.dumps(out))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description='Widevine Android genrule utility')
|
|
parser.set_defaults(func=lambda _: parser.print_help())
|
|
subparsers = parser.add_subparsers(help='Available subcommands')
|
|
|
|
hdr_description = 'Generate build id C++ header (stdout)'
|
|
parser_hdr = subparsers.add_parser('build_id_header', help=hdr_description)
|
|
parser_hdr.add_argument('--guard', type=str,
|
|
default='WVCDM_WV_ANDROID_BUILD_ID_H_',
|
|
help='Include guard')
|
|
parser_hdr.add_argument('version_txt', type=argparse.FileType('r'),
|
|
nargs='?',
|
|
default=sys.stdin,
|
|
help='version.txt file')
|
|
parser_hdr.set_defaults(func=hdr)
|
|
|
|
apex_description = 'Generate APEX manifest json (stdout)'
|
|
parser_apex = subparsers.add_parser('apex_manifest', help=apex_description)
|
|
parser_apex.add_argument('--name', help='apex name',
|
|
default='com.google.android.widevine')
|
|
parser_apex.add_argument('version_txt', type=argparse.FileType('r'),
|
|
nargs='?',
|
|
default=sys.stdin,
|
|
help='version.txt file')
|
|
parser_apex.set_defaults(func=apex_manifest)
|
|
|
|
# Parse the arguments and call the appropriate function
|
|
args = parser.parse_args()
|
|
args.func(args)
|