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 file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
6 FIRST_LINE
= "// This file was generated by generate_thread_allows.py. DO NOT EDIT."
9 def generate_allows(input_paths
):
11 This script reads in the ThreadAllows.txt and ThreadFileAllows.txt lists
12 and generates a header file containing a two arrays of allowed threads.
13 These can be the following formats:
14 -Files which the checker should ignore
15 These files either contain definitions of NS_NewNamedThread or
16 use args which the plugin can't cast (such as func args).
17 -Thread names which the checker should ignore
18 Specifies which individual thread names to ignore.
24 for path
in input_paths
:
25 with
open(path
) as file:
26 lines
.update(file.readlines())
28 for line
in sorted(lines
):
30 We are assuming lines ending in .cpp, .h are files. Threads should
31 NOT have names containing filenames. Please don't do that.
34 if line
.endswith(".cpp") or line
.endswith(".h"):
35 file_list
.append(line
)
37 name_list
.append(line
)
38 file_list_s
= ",\n ".join(json
.dumps(elem
) for elem
in file_list
)
39 name_list_s
= ",\n ".join(json
.dumps(elem
) for elem
in name_list
)
44 static const char *allow_thread_files[] = {
48 static const char *allow_thread_names[] = {
53 % (file_list_s
, name_list_s
)
58 def generate_file(output
, *input_paths
):
59 output
.write(generate_allows(input_paths
))