Source release 16.4.0

This commit is contained in:
John W. Bruce
2020-10-09 16:08:56 -07:00
parent 160df9f57a
commit 9d17a531ee
562 changed files with 52913 additions and 37426 deletions

166
build.py
View File

@@ -24,8 +24,8 @@ import gyp
# pylint: enable=C6204
PLATFORMS_DIR_PATH = os.path.join(CDM_TOP_PATH, 'platforms')
OEMCRYPTO_FUZZTEST_DIR_PATH = os.path.join(
CDM_TOP_PATH, 'oemcrypto', 'test', 'fuzz_tests')
OEMCRYPTO_FUZZTEST_DIR_PATH = os.path.join(CDM_TOP_PATH, 'oemcrypto', 'test',
'fuzz_tests')
# Exit status for script if failure arises.
EXIT_FAILURE = 1
@@ -38,8 +38,8 @@ def LoadFields(path):
specified at the given |path|.
Args:
path: The path (absolute to relative) to the source file containing
module to be loaded.
path: The path (absolute to relative) to the source file containing module
to be loaded.
Returns:
The fields dictionary if it is successfully loaded. Otherwise
@@ -59,7 +59,8 @@ def IsNinjaInstalled():
dev_null = subprocess.DEVNULL
else:
dev_null = open(os.devnull, 'w')
subprocess.check_call(['ninja', '--version'], stdout=dev_null,
subprocess.check_call(['ninja', '--version'],
stdout=dev_null,
stderr=dev_null)
return True
except subprocess.CalledProcessError:
@@ -75,9 +76,9 @@ def PlatformExists(platform, print_details=False):
Args:
platform: Name of the platform (ex. "x86-64")
print_details: An optional flag to enable printing of the reason
the platform was determined to not exist. Does not print
anything if the platform is valid.
print_details: An optional flag to enable printing of the reason the
platform was determined to not exist. Does not print anything if the
platform is valid.
Returns:
True if the there exists configuration files for the specified |platform|,
@@ -100,8 +101,9 @@ def PlatformExists(platform, print_details=False):
.format(platform_gypi_path))
return False
if not os.path.isfile(platform_environment_path):
vprint(' Target platform is missing environment.py file: env_path = {}'
.format(platform_environment_path))
vprint(
' Target platform is missing environment.py file: env_path = {}'.format(
platform_environment_path))
return False
return True
@@ -113,8 +115,10 @@ def RetrieveListOfPlatforms():
A list of strings containing the name of the platform
"""
if not os.path.isdir(PLATFORMS_DIR_PATH):
print('Cannot find platforms directory: expected_path = {}'
.format(PLATFORMS_DIR_PATH), file=sys.stderr)
print(
'Cannot find platforms directory: expected_path = {}'.format(
PLATFORMS_DIR_PATH),
file=sys.stderr)
return []
return sorted(filter(PlatformExists, os.listdir(PLATFORMS_DIR_PATH)))
@@ -149,8 +153,7 @@ def RunNinja(output_path, build_config, job_limit, verbose):
if job_limit is not None:
if math.isinf(job_limit):
print('Ninja cannot run an infinite number of jobs',
file=sys.stderr)
print('Ninja cannot run an infinite number of jobs', file=sys.stderr)
print('Running at most 1000 jobs')
job_limit = 1000
job_args = ['-j', str(job_limit)]
@@ -163,11 +166,15 @@ def RunNinja(output_path, build_config, job_limit, verbose):
return VerboseSubprocess(['ninja', '-C', build_path] + job_args)
# Map from generator name to generator invocation function.
BUILDERS = {
'make': RunMake,
'ninja': RunNinja,
}
def GetBuilder(generator):
return {
'make': RunMake,
'ninja': RunNinja,
}.get(generator)
return BUILDERS.get(generator)
def ImportPlatform(platform, gyp_args, build_fuzz_tests):
@@ -196,10 +203,10 @@ def ImportPlatform(platform, gyp_args, build_fuzz_tests):
gyp_args.append('--include=' + platform_gypi_path)
if build_fuzz_tests:
fuzzer_settings_path = os.path.join(
OEMCRYPTO_FUZZTEST_DIR_PATH, 'platforms/x86-64')
fuzzer_settings_gypi_path = os.path.join(
fuzzer_settings_path, 'fuzzer_settings.gypi')
fuzzer_settings_path = os.path.join(OEMCRYPTO_FUZZTEST_DIR_PATH,
'platforms/x86-64')
fuzzer_settings_gypi_path = os.path.join(fuzzer_settings_path,
'fuzzer_settings.gypi')
gyp_args.append('--include=' + fuzzer_settings_gypi_path)
gyp_args.append('-Goutput_dir=' + output_path)
@@ -217,44 +224,83 @@ def ImportPlatform(platform, gyp_args, build_fuzz_tests):
def main(args):
if IsNinjaInstalled():
print('ninja is installed - use ninja for generator')
print('ninja is installed - use ninja for default generator')
default_generator = 'ninja'
else:
print('ninja is not installed - use make for generator')
print('ninja is not installed - use make for default generator')
default_generator = 'make'
parser = argparse.ArgumentParser()
parser.add_argument('platform',
help=('The platform configuration to use (x86-64). '
'Should be one of the folder names inside '
'platforms/'),
choices=RetrieveListOfPlatforms())
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('-g', '--generator', default=default_generator,
help='Which build system to use (make, ninja, ...). '
'Defaults to ninja when available, make otherwise.')
parser.add_argument('-j', '--jobs', nargs='?', const=float('inf'), type=int,
help='When building, run up to this many jobs in '
'parallel. The default is the default for your chosen '
'generator. If this flag is specified without a value, '
'jobs will spawn without limit.')
parser.add_argument('-D', action='append', default=[],
help='Pass variable definitions to gyp.')
parser.add_argument('-e', '--extra_gyp', action='append', default=[],
help='External gyp file that are processed after the '
'standard gyp files. (Maybe be specified multiple times)')
parser.add_argument('-ft', '--fuzz_tests', default=False,
action='store_true',
help='Set this flag if you want to build fuzz tests.')
parser.add_argument('-v', '--verbose', action='store_true',
help='Print verbose output.')
parser.add_argument(
'platform',
help=('The platform to target. To add a new platform, create a new '
'platform directory with "environment.py" and "settings.gypi" '
'files under platforms/.'),
choices=RetrieveListOfPlatforms())
build_config_group = parser.add_mutually_exclusive_group(required=True)
build_config_group.add_argument(
'-d',
'--debug',
dest='build_config',
action='store_const',
const='debug',
help='Build a debug build. This is shorthand for "--config debug".')
build_config_group.add_argument(
'-r',
'--release',
dest='build_config',
action='store_const',
const='release',
help='Build a release build. This is shorthand for "--config release".')
build_config_group.add_argument(
'-c',
'--config',
dest='build_config',
help=('Select a build configuration to use. Any configuration defined in '
'the chosen platform\'s "settings.gypi" file may be used.'))
parser.add_argument(
'-g',
'--generator',
default=default_generator,
help='Which build system to use. Defaults to {}.'.format(
default_generator),
choices=BUILDERS.keys())
parser.add_argument(
'-j',
'--jobs',
nargs='?',
const=float('inf'),
type=int,
help=('When building, run up to this many jobs in parallel. The default '
'is the default for your chosen generator. If this flag is '
'specified without a value, jobs will spawn without limit.'))
parser.add_argument(
'-D',
'--define',
action='append',
default=[],
help=('Pass variable definitions to GYP. (May be specified multiple '
'times.)'))
parser.add_argument(
'-e',
'--extra_gyp',
action='append',
default=[],
help=('External GYP file that is processed after the standard GYP files. '
'(May be specified multiple times.)'))
parser.add_argument(
'-ft',
'--fuzz_tests',
action='store_true',
help='Set this flag if you want to build fuzz tests.')
parser.add_argument(
'-v',
'--verbose',
action='store_true',
help=('Print verbose build output, including verbose output from the '
'generator.'))
options = parser.parse_args(args)
@@ -273,14 +319,14 @@ def main(args):
os.path.join(OEMCRYPTO_FUZZTEST_DIR_PATH, 'oemcrypto_fuzztests.gyp'))
else:
gyp_args.append(os.path.join(CDM_TOP_PATH, 'cdm', 'cdm_unittests.gyp'))
for var in options.extra_gyp:
gyp_args.append(var)
for var in options.D:
for var in options.define:
gyp_args.append('-D' + var)
output_path = ImportPlatform(
options.platform, gyp_args, options.fuzz_tests)
output_path = ImportPlatform(options.platform, gyp_args, options.fuzz_tests)
print(' Running: {}'.format(' '.join(['gyp'] + gyp_args)))
retval = gyp.main(gyp_args)
@@ -295,8 +341,8 @@ def main(args):
print(' Cannot automatically build with this generator', file=sys.stderr)
print(' Please start the build manually', file=sys.stderr)
return EXIT_FAILURE
return builder(
output_path, options.build_config, options.jobs, options.verbose)
return builder(output_path, options.build_config, options.jobs,
options.verbose)
if __name__ == '__main__':