1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 # This file takes the .mk files from an upstream opus repo and generates the
6 # sources.mozbuild file. It is invoked as part of update.sh
11 # These files are not used, ignore them.
13 'silk/float/regularize_correlations_FLP.c',
14 'silk/float/LPC_inv_pred_gain_FLP.c',
15 'src/opus_projection_encoder.c',
17 'src/mapping_matrix.c',
18 'src/opus_projection_decoder.c',
21 def should_ignore(value
):
22 return any(item
in value
for item
in ignore_list
)
24 def add_value(values
, text
):
25 text
= text
.replace('\\', '')
27 if text
and not should_ignore(text
):
30 def write_values(output
, values
):
31 for value
in sorted(values
, key
=lambda x
: x
.lower()):
32 output
.write(" '%s',\n" % value
)
35 def generate_sources_mozbuild(path
):
42 var_definition
= re
.compile('([A-Z0-9_]*) = (.*)')
43 with
open('sources.mozbuild', 'w') as output
:
45 output
.write('# THIS FILE WAS AUTOMATICALLY GENERATED BY %s. DO NOT EDIT.\n' % sys
.argv
[0])
46 for makefile
in makefiles
:
48 definition_started
= False
50 with
open('%s/%s' % (path
, makefile
), 'r') as mk
:
53 result
= var_definition
.match(line
)
55 if definition_started
:
56 write_values(output
, values
)
58 definition_started
= True
60 # Some variable definitions have the first entry on the
63 # CELT_SOURCES = celt/bands.c
65 # So we treat the first group as the variable name and
66 # the second group as a potential value.
68 # Note that we write the variable name in lower case (so
69 # "CELT_SOURCES" in the .mk file becomes "celt_sources"
70 # in the .mozbuild file) because moz.build reserves
71 # upper-case variable names for build system outputs.
72 output
.write('%s = [\n' % result
.group(1).lower())
73 add_value(values
, result
.group(2))
75 add_value(values
, line
)
76 write_values(output
, values
)
78 if __name__
== '__main__':
79 if len(sys
.argv
) != 2:
80 print("Usage: %s /path/to/opus" % (sys
.argv
[0]))
83 generate_sources_mozbuild(sys
.argv
[1])