forked from mirrors/gecko-dev
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly. To produce this patch I did all of the following: 1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions. 2. Run ./mach lint --linter black --fix 3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks. 4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat. 5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023). # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D94045
40 lines
918 B
Python
40 lines
918 B
Python
#!/usr/bin/env python3
|
|
|
|
import json
|
|
|
|
|
|
def generate(output, *input_paths):
|
|
"""
|
|
This file generates a ThirdPartyPaths.cpp file from the ThirdPartyPaths.txt
|
|
file in /tools/rewriting, which is used by the Clang Plugin to help identify
|
|
sources which should be ignored.
|
|
"""
|
|
tpp_list = []
|
|
lines = set()
|
|
|
|
for path in input_paths:
|
|
with open(path) as f:
|
|
lines.update(f.readlines())
|
|
|
|
for line in lines:
|
|
line = line.strip()
|
|
if line.endswith("/"):
|
|
line = line[:-1]
|
|
tpp_list.append(line)
|
|
tpp_strings = ",\n ".join([json.dumps(tpp) for tpp in sorted(tpp_list)])
|
|
|
|
output.write(
|
|
"""\
|
|
/* THIS FILE IS GENERATED BY ThirdPartyPaths.py - DO NOT EDIT */
|
|
|
|
#include <stdint.h>
|
|
|
|
const char* MOZ_THIRD_PARTY_PATHS[] = {
|
|
%s
|
|
};
|
|
|
|
extern const uint32_t MOZ_THIRD_PARTY_PATHS_COUNT = %d;
|
|
|
|
"""
|
|
% (tpp_strings, len(tpp_list))
|
|
)
|