Source release 14.1.0
This commit is contained in:
89
create_static_bundle.py
Executable file
89
create_static_bundle.py
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
# source code may only be used and distributed under the Widevine Master
|
||||
# License Agreement.
|
||||
|
||||
"""Creates a self-contained static library of the CDM."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
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',
|
||||
]
|
||||
SSL_LIB_NAME = 'libcrypto.a'
|
||||
PROTOBUF_NAME = 'libprotobuf_lite.a'
|
||||
RESULT_LIB_NAME = 'libwidevine_cdm_complete.a'
|
||||
|
||||
|
||||
def main(args):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'platform',
|
||||
help='The platform configuration to use (x86-64, ...). '
|
||||
'Should be one of the folder names inside platforms/')
|
||||
parser.add_argument('-r', '--release', dest='build_config', default='Debug',
|
||||
action='store_const', const='Release',
|
||||
help='Builds a release build (equivalent to -c Release)')
|
||||
parser.add_argument('-c', '--config', dest='build_config', default='Debug',
|
||||
help='Select a build config (Debug, Release). '
|
||||
'Defaults to Debug.')
|
||||
parser.add_argument('--ar', dest='ar', default='ar',
|
||||
help='Use the given program as the archiver (defaults '
|
||||
'to "ar").')
|
||||
parser.add_argument('--boringssl', dest='ssl', action='store_true',
|
||||
help='Include BoringSSL in the bundle')
|
||||
parser.add_argument('--protobuf', dest='protobuf', action='store_true',
|
||||
help='Include protobuf in the bundle')
|
||||
|
||||
options = parser.parse_args(args)
|
||||
|
||||
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
|
||||
|
||||
# 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')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
Reference in New Issue
Block a user