mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-06-25 01:48:52 +00:00
f6fa831116
- Update libnestegg from upstream (dad1c31db) - [webm] Store LastSeenFrame dimensions as an nsIntSize (ae3cdb4be) - [vpx] Store VPXDecoder codec as an enum (5a83ed9eb) - Add Span support to MediaRawData (2a00bf126) - Implement keyframe and framesize VPXDecoder helpers (55c6aa422) - Call VPXDecoder libvpx wrappers for WebM (3ec54eeac) - [webm] Treat demuxing errors differently than EOS (632b67483) - [webm] Don't reject seeks with EOS (81c39ba87) - Port the libvpx mozbuild generator to aom (07c17b6b9) - Import aom library (68569dee1) - Generate build description for libaom (a66e91651) - Add --enable-av1 configure switch (99ed16064) - Add AOMDecoder (9aea199da) - Add AOMDecoder to AgnosticDecoderModule (3e0443e4c) - Recognize AV1 in WebMDemuxer (ee2cb65e2) - Add missing includes to WebMDemuxer (e5545e10a) - Add aom to the list of thirdparty code (e8480f8a7) - [aom] Remove 32-bit Mac OS build config (08619db14) - [aom] Enable YASM (f45278950) - Make AOMDecoder actually build (26dc168e3) - Remove aom_codec_stream_info_t sz field references (1036d1fa0) - Add av1 to MediaSource.isTypeSupported (0cc51bc10) - Update aom to slightly newer commit ID (df9477dfa) - Fix typo (build bustage) (4b5e22956) - Add missing includes to FFmpegLibWrapper (dddc2aa9e) - [av1] Clean up duplicate filenames check (afda5e384) - [aom] Add x86-win32-gcc config (857b86f25) - Make aom_config.asm match upstream (ecdaf7930) - [aom] Filter out CONFIG_EXT_PARTITION_TYPES (4121d7571) - [aom] Remove unused option (77887af9c) - Update aom to commit id f5bdeac22930ff4c6b219be49c843db35970b918 (7369c7d7a) - Export aom_config.h (21598d1bd) - [aom] Fix stream info peeking (e394e2049) - [aom] Resample high bit depth frames (4653be960) - [aom] Don't resample 8-bit images (0c98b7165) - [aom] Fix win32 debug build (01eb57073) - Update aom to commit id e87fb2378f01103d5d6e477a4ef6892dc714e614 (ec910d814) - [av1] Fix build issues (464c3130f) - Fix aom compile errors with VS2015 (125aff11b) - Add Python cmake parser (39e842a83) - Add generate_sources_mozbuild.py (5c0c6c73a) - Update generate_sources_mozbuild.sh (b425400e9) - Add aom_version.h (c410f04e8) - Add support for SSE 4.2 to libaom moz.build (14805f6dd) - Update aom to v1.0.0 (bbcc64772) - Do not build aomstats unless examples are enabled (ab5b4462a) - [aom] Fixup moz.build (4f63fc3bd) - Updates to AOMDecoder for aom v1.0.0 (ee1300453) - Add missing : to libaom moz.build (9469bc196) - [aom] No longer necessary to run lint_config.sh anymore (a4d3c59dc) - Update libaom to rev b25610052a1398032320008d69b51d2da94f5928 (b8df135c9) - [aom] Only build stats code if examples are enabled (ba5a1ea60) - Update libaom vendor scripts to account for upstream changes (41fbdea45) - Update libaom to commit ID 1e227d41f0616de9548a673a83a21ef990b62591 (d2499ead9) - Put AV1 codec behind a pref (6ddf66542) - Fix canPlayType/isTypeSupported for AV1 content (e5b30fc95) - Downsample av1 images unconditionally (070c2cb24) - Use larger stack for media decoder threads (47a01617e) - Add support for AV1 in MP4 (29f718ef7) - Ensure we correctly parse the finalized codec string for av1 (23013dda6) - Revert "Add support for AV1 in MP4" (192199b03) - Add support to libstagefright for AV1 FourCCs (df59d06fd) - Add support to libstagefright for AV1 FourCCs (part 2) (4d8b7a376) - Add AV1 support to MP4Decoder. (56c26d867)
294 lines
11 KiB
Python
294 lines
11 KiB
Python
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
from pyparsing import (CharsNotIn, Group, Forward, Literal, Suppress, Word,
|
|
QuotedString, ZeroOrMore, alphas, alphanums)
|
|
from string import Template
|
|
import re
|
|
|
|
# Grammar for CMake
|
|
comment = Literal('#') + ZeroOrMore(CharsNotIn('\n'))
|
|
quoted_argument = QuotedString('\"', '\\', multiline=True)
|
|
unquoted_argument = CharsNotIn('\n ()#\"\\')
|
|
argument = quoted_argument | unquoted_argument | Suppress(comment)
|
|
arguments = Forward()
|
|
arguments << (argument | (Literal('(') + ZeroOrMore(arguments) + Literal(')')))
|
|
identifier = Word(alphas, alphanums+'_')
|
|
command = Group(identifier + Literal('(') + ZeroOrMore(arguments) + Literal(')'))
|
|
file_elements = command | Suppress(comment)
|
|
cmake = ZeroOrMore(file_elements)
|
|
|
|
|
|
def extract_arguments(parsed):
|
|
"""Extract the command arguments skipping the parentheses"""
|
|
return parsed[2:len(parsed) - 1]
|
|
|
|
|
|
def match_block(command, parsed, start):
|
|
"""Find the end of block starting with the command"""
|
|
depth = 0
|
|
end = start + 1
|
|
endcommand = 'end' + command
|
|
while parsed[end][0] != endcommand or depth > 0:
|
|
if parsed[end][0] == command:
|
|
depth += 1
|
|
elif parsed[end][0] == endcommand:
|
|
depth -= 1
|
|
end = end + 1
|
|
if end == len(parsed):
|
|
print('error: eof when trying to match block statement: %s'
|
|
% parsed[start])
|
|
return end
|
|
|
|
|
|
def parse_if(parsed, start):
|
|
"""Parse if/elseif/else/endif into a list of conditions and commands"""
|
|
depth = 0
|
|
conditions = []
|
|
condition = [extract_arguments(parsed[start])]
|
|
start = start + 1
|
|
end = start
|
|
|
|
while parsed[end][0] != 'endif' or depth > 0:
|
|
command = parsed[end][0]
|
|
if command == 'if':
|
|
depth += 1
|
|
elif command == 'else' and depth == 0:
|
|
condition.append(parsed[start:end])
|
|
conditions.append(condition)
|
|
start = end + 1
|
|
condition = [['TRUE']]
|
|
elif command == 'elseif' and depth == 0:
|
|
condition.append(parsed[start:end])
|
|
conditions.append(condition)
|
|
condition = [extract_arguments(parsed[end])]
|
|
start = end + 1
|
|
elif command == 'endif':
|
|
depth -= 1
|
|
end = end + 1
|
|
if end == len(parsed):
|
|
print('error: eof when trying to match if statement: %s'
|
|
% parsed[start])
|
|
condition.append(parsed[start:end])
|
|
conditions.append(condition)
|
|
return end, conditions
|
|
|
|
|
|
def substs(variables, values):
|
|
"""Substitute variables into values"""
|
|
new_values = []
|
|
for value in values:
|
|
t = Template(value)
|
|
new_value = t.safe_substitute(variables)
|
|
|
|
# Safe substitute leaves unrecognized variables in place.
|
|
# We replace them with the empty string.
|
|
new_values.append(re.sub('\$\{\w+\}', '', new_value))
|
|
return new_values
|
|
|
|
|
|
def evaluate(variables, cache_variables, parsed):
|
|
"""Evaluate a list of parsed commands, returning sources to build"""
|
|
i = 0
|
|
sources = []
|
|
while i < len(parsed):
|
|
command = parsed[i][0]
|
|
arguments = substs(variables, extract_arguments(parsed[i]))
|
|
|
|
if command == 'foreach':
|
|
end = match_block(command, parsed, i)
|
|
for argument in arguments[1:]:
|
|
# ; is also a valid divider, why have one when you can have two?
|
|
argument = argument.replace(';', ' ')
|
|
for value in argument.split():
|
|
variables[arguments[0]] = value
|
|
cont_eval, new_sources = evaluate(variables, cache_variables,
|
|
parsed[i+1:end])
|
|
sources.extend(new_sources)
|
|
if not cont_eval:
|
|
return cont_eval, sources
|
|
elif command == 'function':
|
|
# for now we just execute functions inline at point of declaration
|
|
# as this is sufficient to build libaom
|
|
pass
|
|
elif command == 'if':
|
|
i, conditions = parse_if(parsed, i)
|
|
for condition in conditions:
|
|
if evaluate_boolean(variables, condition[0]):
|
|
cont_eval, new_sources = evaluate(variables,
|
|
cache_variables,
|
|
condition[1])
|
|
sources.extend(new_sources)
|
|
if not cont_eval:
|
|
return cont_eval, sources
|
|
break
|
|
elif command == 'include':
|
|
if arguments:
|
|
try:
|
|
print('including: %s' % arguments[0])
|
|
sources.extend(parse(variables, cache_variables, arguments[0]))
|
|
except IOError:
|
|
print('warning: could not include: %s' % arguments[0])
|
|
elif command == 'list':
|
|
try:
|
|
action = arguments[0]
|
|
variable = arguments[1]
|
|
values = arguments[2:]
|
|
if action == 'APPEND':
|
|
if not variables.has_key(variable):
|
|
variables[variable] = ' '.join(values)
|
|
else:
|
|
variables[variable] += ' ' + ' '.join(values)
|
|
except (IndexError, KeyError):
|
|
pass
|
|
elif command == 'option':
|
|
variable = arguments[0]
|
|
value = arguments[2]
|
|
# Allow options to be override without changing CMake files
|
|
if not variables.has_key(variable):
|
|
variables[variable] = value
|
|
elif command == 'return':
|
|
return False, sources
|
|
elif command == 'set':
|
|
variable = arguments[0]
|
|
values = arguments[1:]
|
|
# CACHE variables are not set if already present
|
|
try:
|
|
cache = values.index('CACHE')
|
|
values = values[0:cache]
|
|
if not variables.has_key(variable):
|
|
variables[variable] = ' '.join(values)
|
|
cache_variables.append(variable)
|
|
except ValueError:
|
|
variables[variable] = ' '.join(values)
|
|
# we need to emulate the behavior of these function calls
|
|
# because we don't support interpreting them directly
|
|
# see bug 1492292
|
|
elif command in ['set_aom_config_var', 'set_aom_detect_var']:
|
|
variable = arguments[0]
|
|
value = arguments[1]
|
|
if variable not in variables:
|
|
variables[variable] = value
|
|
cache_variables.append(variable)
|
|
elif command == 'set_aom_option_var':
|
|
# option vars cannot go into cache_variables
|
|
variable = arguments[0]
|
|
value = arguments[2]
|
|
if variable not in variables:
|
|
variables[variable] = value
|
|
elif command == 'add_asm_library':
|
|
try:
|
|
sources.extend(variables[arguments[1]].split(' '))
|
|
except (IndexError, KeyError):
|
|
pass
|
|
elif command == 'add_intrinsics_object_library':
|
|
try:
|
|
sources.extend(variables[arguments[3]].split(' '))
|
|
except (IndexError, KeyError):
|
|
pass
|
|
elif command == 'add_library':
|
|
for source in arguments[1:]:
|
|
sources.extend(source.split(' '))
|
|
elif command == 'target_sources':
|
|
for source in arguments[1:]:
|
|
sources.extend(source.split(' '))
|
|
elif command == 'MOZDEBUG':
|
|
print('>>>> MOZDEBUG: %s' % ' '.join(arguments))
|
|
i += 1
|
|
return True, sources
|
|
|
|
|
|
def evaluate_boolean(variables, arguments):
|
|
"""Evaluate a boolean expression"""
|
|
if not arguments:
|
|
return False
|
|
|
|
argument = arguments[0]
|
|
|
|
if argument == 'NOT':
|
|
return not evaluate_boolean(variables, arguments[1:])
|
|
|
|
if argument == '(':
|
|
i = 0
|
|
depth = 1
|
|
while depth > 0 and i < len(arguments):
|
|
i += 1
|
|
if arguments[i] == '(':
|
|
depth += 1
|
|
if arguments[i] == ')':
|
|
depth -= 1
|
|
return evaluate_boolean(variables, arguments[1:i])
|
|
|
|
def evaluate_constant(argument):
|
|
try:
|
|
as_int = int(argument)
|
|
if as_int != 0:
|
|
return True
|
|
else:
|
|
return False
|
|
except ValueError:
|
|
upper = argument.upper()
|
|
if upper in ['ON', 'YES', 'TRUE', 'Y']:
|
|
return True
|
|
elif upper in ['OFF', 'NO', 'FALSE', 'N', 'IGNORE', '', 'NOTFOUND']:
|
|
return False
|
|
elif upper.endswith('-NOTFOUND'):
|
|
return False
|
|
return None
|
|
|
|
def lookup_variable(argument):
|
|
# If statements can have old-style variables which are not demarcated
|
|
# like ${VARIABLE}. Attempt to look up the variable both ways.
|
|
try:
|
|
if re.search('\$\{\w+\}', argument):
|
|
try:
|
|
t = Template(argument)
|
|
value = t.substitute(variables)
|
|
try:
|
|
# Attempt an old-style variable lookup with the
|
|
# substituted value.
|
|
return variables[value]
|
|
except KeyError:
|
|
return value
|
|
except ValueError:
|
|
# TODO: CMake supports nesting, e.g. ${${foo}}
|
|
return None
|
|
else:
|
|
return variables[argument]
|
|
except KeyError:
|
|
return None
|
|
|
|
lhs = lookup_variable(argument)
|
|
if lhs is None:
|
|
# variable resolution failed, treat as string
|
|
lhs = argument
|
|
|
|
if len(arguments) > 1:
|
|
op = arguments[1]
|
|
if op == 'AND':
|
|
return evaluate_constant(lhs) and evaluate_boolean(variables, arguments[2:])
|
|
elif op == 'MATCHES':
|
|
rhs = lookup_variable(arguments[2])
|
|
if not rhs:
|
|
rhs = arguments[2]
|
|
return not re.match(rhs, lhs) is None
|
|
elif op == 'OR':
|
|
return evaluate_constant(lhs) or evaluate_boolean(variables, arguments[2:])
|
|
elif op == 'STREQUAL':
|
|
rhs = lookup_variable(arguments[2])
|
|
if not rhs:
|
|
rhs = arguments[2]
|
|
return lhs == rhs
|
|
else:
|
|
lhs = evaluate_constant(lhs)
|
|
if lhs is None:
|
|
lhs = lookup_variable(argument)
|
|
|
|
return lhs
|
|
|
|
|
|
def parse(variables, cache_variables, filename):
|
|
parsed = cmake.parseFile(filename)
|
|
cont_eval, sources = evaluate(variables, cache_variables, parsed)
|
|
return sources
|