Source release 15.0.0
This commit is contained in:
@@ -10,21 +10,43 @@ from __future__ import print_function
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
CDM_TOP = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
REQUIRED_LIBS = [
|
||||
'libdevice_files.a',
|
||||
'liblicense_protocol.a',
|
||||
'libmetrics_proto.a',
|
||||
'libwidevine_cdm_core.a',
|
||||
'libwidevine_ce_cdm_static.a',
|
||||
'device_files',
|
||||
'license_protocol',
|
||||
'metrics_proto',
|
||||
'widevine_cdm_core',
|
||||
'widevine_ce_cdm_static',
|
||||
]
|
||||
SSL_LIB_NAME = 'libcrypto.a'
|
||||
PROTOBUF_NAME = 'libprotobuf_lite.a'
|
||||
RESULT_LIB_NAME = 'libwidevine_cdm_complete.a'
|
||||
SSL_LIB_NAME = 'crypto'
|
||||
PROTOBUF_NAME = 'protobuf_lite'
|
||||
RESULT_LIB_NAME = 'widevine_cdm_complete'
|
||||
|
||||
|
||||
def _CombineLinuxLibs(ar, result_path, libs):
|
||||
# Extract each static library into the temporary directory.
|
||||
temp_dir = os.path.join(os.path.dirname(result_path), 'bundle_dir')
|
||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||
os.mkdir(temp_dir)
|
||||
|
||||
for lib in libs:
|
||||
if subprocess.call([ar, 'x', lib], cwd=temp_dir) != 0:
|
||||
return 1
|
||||
|
||||
# Create the combined static library.
|
||||
if os.path.exists(result_path):
|
||||
os.remove(result_path)
|
||||
cmd = [ar, 'rcs', result_path] + glob.glob(os.path.join(temp_dir, '*.o'))
|
||||
if subprocess.call(cmd) != 0:
|
||||
return 1
|
||||
|
||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||
return 0
|
||||
|
||||
|
||||
def main(args):
|
||||
@@ -42,6 +64,9 @@ def main(args):
|
||||
parser.add_argument('--ar', dest='ar', default='ar',
|
||||
help='Use the given program as the archiver (defaults '
|
||||
'to "ar").')
|
||||
parser.add_argument('--lib', dest='lib', default='lib.exe',
|
||||
help='Use the given lib.exe program (defaults to '
|
||||
'lib.exe, which is normally not on PATH)')
|
||||
parser.add_argument('--boringssl', dest='ssl', action='store_true',
|
||||
help='Include BoringSSL in the bundle')
|
||||
parser.add_argument('--protobuf', dest='protobuf', action='store_true',
|
||||
@@ -49,40 +74,33 @@ def main(args):
|
||||
|
||||
options = parser.parse_args(args)
|
||||
|
||||
is_win = sys.platform == 'win32'
|
||||
lib_prefix = '' if is_win else 'lib'
|
||||
lib_ext = '.lib' if is_win else '.a'
|
||||
|
||||
build_dir = os.path.join(CDM_TOP, 'out', options.platform,
|
||||
options.build_config)
|
||||
if not os.path.exists(os.path.join(build_dir, REQUIRED_LIBS[0])):
|
||||
print('Unable to find libraries, be sure to run ./build.py first.')
|
||||
return 1
|
||||
|
||||
temp_dir = os.path.join(build_dir, 'bundle_dir')
|
||||
if not os.path.exists(temp_dir):
|
||||
os.mkdir(temp_dir)
|
||||
|
||||
# Clean up old builds.
|
||||
for root, dirs, files in os.walk(temp_dir, topdown=False):
|
||||
for f in files:
|
||||
os.remove(os.path.join(root, f))
|
||||
for d in dirs:
|
||||
os.rmdir(os.path.join(root, d))
|
||||
|
||||
# Extract each static library into the temporary directory.
|
||||
libs = REQUIRED_LIBS
|
||||
if options.ssl:
|
||||
libs += [SSL_LIB_NAME]
|
||||
if options.protobuf:
|
||||
libs += [PROTOBUF_NAME]
|
||||
for lib in libs:
|
||||
if subprocess.call([options.ar, 'x', os.path.join(build_dir, lib)],
|
||||
cwd=temp_dir) != 0:
|
||||
return 1
|
||||
lib_paths = [os.path.join(build_dir, lib_prefix + lib + lib_ext)
|
||||
for lib in libs]
|
||||
result_path = os.path.join(build_dir, lib_prefix + RESULT_LIB_NAME + lib_ext)
|
||||
|
||||
# Create the combined static library.
|
||||
result_path = os.path.join(build_dir, RESULT_LIB_NAME)
|
||||
if os.path.exists(result_path):
|
||||
os.remove(result_path)
|
||||
return subprocess.call([options.ar, 'rcs', result_path] +
|
||||
glob.glob(os.path.join(temp_dir, '*.o')))
|
||||
not_found = [lib for lib in lib_paths if not os.path.exists(lib)]
|
||||
if not_found:
|
||||
print('Unable to find %s, be sure to run ./build.py first.' %
|
||||
os.path.basename(not_found[0]))
|
||||
return 1
|
||||
|
||||
if is_win:
|
||||
return subprocess.call(
|
||||
[options.lib, '/NOLOGO', '/OUT:' + result_path] + lib_paths)
|
||||
else:
|
||||
return _CombineLinuxLibs(options.ar, result_path, lib_paths)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user