WVCdm version stamping
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
This commit is contained in:
@@ -387,21 +387,24 @@ python_binary_host {
|
|||||||
|
|
||||||
genrule {
|
genrule {
|
||||||
name: "wv_android_build_id",
|
name: "wv_android_build_id",
|
||||||
|
srcs: ["version.txt"],
|
||||||
tools: ["wv-android-genrule"],
|
tools: ["wv-android-genrule"],
|
||||||
cmd: "$(location wv-android-genrule) build_id_header > $(out)",
|
cmd: "$(location wv-android-genrule) build_id_header $(in) > $(out)",
|
||||||
out: ["wv_android_build_id.h"],
|
out: ["wv_android_build_id.h"],
|
||||||
}
|
}
|
||||||
|
|
||||||
genrule {
|
genrule {
|
||||||
name: "widevine_apex_manifest.json",
|
name: "widevine_apex_manifest.json",
|
||||||
|
srcs: ["version.txt"],
|
||||||
tools: ["wv-android-genrule"],
|
tools: ["wv-android-genrule"],
|
||||||
cmd: "$(location wv-android-genrule) apex_manifest > $(out)",
|
cmd: "$(location wv-android-genrule) apex_manifest $(in) > $(out)",
|
||||||
out: ["gen_wv_apex_manifest.json"],
|
out: ["gen_wv_apex_manifest.json"],
|
||||||
}
|
}
|
||||||
|
|
||||||
genrule {
|
genrule {
|
||||||
name: "widevine_lazy_apex_manifest.json",
|
name: "widevine_lazy_apex_manifest.json",
|
||||||
|
srcs: ["version.txt"],
|
||||||
tools: ["wv-android-genrule"],
|
tools: ["wv-android-genrule"],
|
||||||
cmd: "$(location wv-android-genrule) apex_manifest --name com.google.android.widevine.lazy > $(out)",
|
cmd: "$(location wv-android-genrule) apex_manifest --name com.google.android.widevine.lazy $(in) > $(out)",
|
||||||
out: ["gen_wv_lazy_apex_manifest.json"],
|
out: ["gen_wv_lazy_apex_manifest.json"],
|
||||||
}
|
}
|
||||||
|
|||||||
1
libwvdrmengine/version.txt
Normal file
1
libwvdrmengine/version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
MAIN
|
||||||
@@ -5,30 +5,12 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
INT32_MAX = 2 ** 31 - 1
|
CDM_MAJOR = 19
|
||||||
|
CDM_MINOR = 0
|
||||||
|
|
||||||
def guess_build_top():
|
def get_build_id(args):
|
||||||
if 'ANDROID_BUILD_TOP' in os.environ:
|
with args.version_txt as file:
|
||||||
return os.environ['ANDROID_BUILD_TOP']
|
return file.read().strip()
|
||||||
cwd = os.getcwd()
|
|
||||||
parts = cwd.split('/out/soong/')
|
|
||||||
return parts[0]
|
|
||||||
|
|
||||||
|
|
||||||
def get_build_number():
|
|
||||||
top = guess_build_top()
|
|
||||||
with open(f'{top}/out/soong/build_number.txt', 'r') as file:
|
|
||||||
soong_build_number = file.read().strip()
|
|
||||||
return soong_build_number
|
|
||||||
|
|
||||||
|
|
||||||
def get_build_id():
|
|
||||||
top = guess_build_top()
|
|
||||||
with open(f'{top}/build/core/build_id.mk', 'r') as file:
|
|
||||||
for line in file:
|
|
||||||
if line.startswith('BUILD_ID='):
|
|
||||||
_, rc = line.strip().split('=', 1)
|
|
||||||
return rc
|
|
||||||
|
|
||||||
|
|
||||||
def hdr(args):
|
def hdr(args):
|
||||||
@@ -36,59 +18,19 @@ def hdr(args):
|
|||||||
#ifndef {args.guard}
|
#ifndef {args.guard}
|
||||||
#define {args.guard}
|
#define {args.guard}
|
||||||
|
|
||||||
#define WV_ANDROID_BUILD_ID "{get_build_id()}"
|
#define WV_ANDROID_BUILD_ID "{get_build_id(args)}"
|
||||||
|
|
||||||
#endif // {args.guard}'''
|
#endif // {args.guard}'''
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
def safe_int(str_value):
|
|
||||||
"""Converts a build number to an integer, capped at INT32_MAX.
|
|
||||||
|
|
||||||
INT32_MAX is the max supported by Android Build.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
str_value: The build number to convert.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The integer representation of build number, capped at INT32_MAX;
|
|
||||||
0 on error.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
v = int(str_value)
|
|
||||||
return min(INT32_MAX, v)
|
|
||||||
except ValueError:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def apex_manifest(args):
|
def apex_manifest(args):
|
||||||
rc = get_build_id()
|
rc = get_build_id(args)
|
||||||
v = get_build_number()
|
m = re.match(r'[A-Z0-9]{4}\.(?P<build_date>\d{6})\.', rc)
|
||||||
|
if m:
|
||||||
if v.startswith('eng.'):
|
v = int(f'{CDM_MAJOR}{CDM_MINOR}{m["build_date"]}')
|
||||||
# local build
|
|
||||||
#
|
|
||||||
# set large version so local builds can overwrite other build types
|
|
||||||
v = INT32_MAX
|
|
||||||
elif re.match(r'P\d+$', v):
|
|
||||||
# presubmit build
|
|
||||||
#
|
|
||||||
# numeric value of presubmit builds are typically higher than
|
|
||||||
# postsubmit builds, so presubmit builds can overwrite postsubmit
|
|
||||||
# builds during test
|
|
||||||
v = safe_int(v[1:])
|
|
||||||
elif rc in ('MASTER', 'MAIN'):
|
|
||||||
# postsubmit dev branch
|
|
||||||
#
|
|
||||||
# set APEX version to 1 (preserve udc behavior)
|
|
||||||
v = 1
|
|
||||||
elif re.match(r'\d+$', v):
|
|
||||||
# postsubmit release branch
|
|
||||||
#
|
|
||||||
# set APEX version to ab build number
|
|
||||||
v = safe_int(v)
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Unsupported Widevine APEX build env')
|
v = 1
|
||||||
|
|
||||||
out = dict(name=args.name, version=v, requireNativeLibs=['liboemcrypto.so'])
|
out = dict(name=args.name, version=v, requireNativeLibs=['liboemcrypto.so'])
|
||||||
print(json.dumps(out))
|
print(json.dumps(out))
|
||||||
@@ -104,12 +46,20 @@ if __name__ == '__main__':
|
|||||||
parser_hdr.add_argument('--guard', type=str,
|
parser_hdr.add_argument('--guard', type=str,
|
||||||
default='WVCDM_WV_ANDROID_BUILD_ID_H_',
|
default='WVCDM_WV_ANDROID_BUILD_ID_H_',
|
||||||
help='Include guard')
|
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)
|
parser_hdr.set_defaults(func=hdr)
|
||||||
|
|
||||||
apex_description = 'Generate APEX manifest json (stdout)'
|
apex_description = 'Generate APEX manifest json (stdout)'
|
||||||
parser_apex = subparsers.add_parser('apex_manifest', help=apex_description)
|
parser_apex = subparsers.add_parser('apex_manifest', help=apex_description)
|
||||||
parser_apex.add_argument('--name', help='apex name',
|
parser_apex.add_argument('--name', help='apex name',
|
||||||
default='com.google.android.widevine')
|
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)
|
parser_apex.set_defaults(func=apex_manifest)
|
||||||
|
|
||||||
# Parse the arguments and call the appropriate function
|
# Parse the arguments and call the appropriate function
|
||||||
|
|||||||
Reference in New Issue
Block a user