mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1776104 - Verify that the paths exist before writing ThirdPartyPaths.cpp. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D150069
This commit is contained in:
parent
b8e30b3751
commit
ce4ab516bb
@ -1,6 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Import buildconfig if available, otherwise set has_buildconfig to False so
|
||||
# we skip the check which relies on it.
|
||||
try:
|
||||
import buildconfig
|
||||
except ImportError:
|
||||
has_buildconfig = False
|
||||
else:
|
||||
has_buildconfig = True
|
||||
|
||||
|
||||
def generate(output, *input_paths):
|
||||
@ -11,6 +22,7 @@ def generate(output, *input_paths):
|
||||
"""
|
||||
tpp_list = []
|
||||
lines = set()
|
||||
path_found = True
|
||||
|
||||
for path in input_paths:
|
||||
with open(path) as f:
|
||||
@ -20,7 +32,25 @@ def generate(output, *input_paths):
|
||||
line = line.strip()
|
||||
if line.endswith("/"):
|
||||
line = line[:-1]
|
||||
|
||||
if has_buildconfig:
|
||||
# Ignore lines starting with $UNVALIDATED
|
||||
# These should only be coming from Unvalidated.txt
|
||||
if line.startswith("$UNVALIDATED"):
|
||||
line = line[13:]
|
||||
elif not glob.glob(buildconfig.topsrcdir + "/" + line):
|
||||
path_found = False
|
||||
|
||||
if path_found:
|
||||
tpp_list.append(line)
|
||||
else:
|
||||
print(
|
||||
"Third-party path "
|
||||
+ line
|
||||
+ " does not exist. Remove it from Generated.txt or "
|
||||
+ "ThirdPartyPaths.txt and try again."
|
||||
)
|
||||
sys.exit(1)
|
||||
tpp_strings = ",\n ".join([json.dumps(tpp) for tpp in sorted(tpp_list)])
|
||||
|
||||
output.write(
|
||||
|
@ -95,8 +95,14 @@ def add_moz_module(cmake_path):
|
||||
def write_third_party_paths(mozilla_path, module_path):
|
||||
tpp_txt = os.path.join(mozilla_path, "../../tools/rewriting/ThirdPartyPaths.txt")
|
||||
generated_txt = os.path.join(mozilla_path, "../../tools/rewriting/Generated.txt")
|
||||
# Unvalidated.txt is used for rare cases where we don't want to validate that a given
|
||||
# path exists but still want it included in the ThirdPartyPaths check in the plugin.
|
||||
# For example, headers exported to dist/include that live elsewhere.
|
||||
unvalidated_txt = os.path.join(
|
||||
mozilla_path, "../../tools/rewriting/Unvalidated.txt"
|
||||
)
|
||||
with open(os.path.join(module_path, "ThirdPartyPaths.cpp"), "w") as f:
|
||||
ThirdPartyPaths.generate(f, tpp_txt, generated_txt)
|
||||
ThirdPartyPaths.generate(f, tpp_txt, generated_txt, unvalidated_txt)
|
||||
|
||||
|
||||
def generate_thread_allows(mozilla_path, module_path):
|
||||
|
@ -70,8 +70,9 @@ GeneratedFile(
|
||||
script="ThirdPartyPaths.py",
|
||||
entry_point="generate",
|
||||
inputs=[
|
||||
"/tools/rewriting/ThirdPartyPaths.txt",
|
||||
"/tools/rewriting/Generated.txt",
|
||||
"/tools/rewriting/ThirdPartyPaths.txt",
|
||||
"/tools/rewriting/Unvalidated.txt",
|
||||
],
|
||||
)
|
||||
|
||||
|
1
tools/rewriting/Unvalidated.txt
Normal file
1
tools/rewriting/Unvalidated.txt
Normal file
@ -0,0 +1 @@
|
||||
$UNVALIDATED/function2
|
Loading…
Reference in New Issue
Block a user