summaryrefslogtreecommitdiff
path: root/buildscripts/idl/gen_all_feature_flag_list.py
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /buildscripts/idl/gen_all_feature_flag_list.py
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'buildscripts/idl/gen_all_feature_flag_list.py')
-rw-r--r--buildscripts/idl/gen_all_feature_flag_list.py63
1 files changed, 31 insertions, 32 deletions
diff --git a/buildscripts/idl/gen_all_feature_flag_list.py b/buildscripts/idl/gen_all_feature_flag_list.py
index 88fee6b367f..518583898cb 100644
--- a/buildscripts/idl/gen_all_feature_flag_list.py
+++ b/buildscripts/idl/gen_all_feature_flag_list.py
@@ -30,6 +30,7 @@ Generate a file containing a list of disabled feature flags.
Used by resmoke.py to run only feature flag tests.
"""
+import argparse
import os
import sys
@@ -42,49 +43,47 @@ sys.path.append(os.path.normpath(os.path.join(os.path.abspath(__file__), '../../
# pylint: disable=wrong-import-position
import buildscripts.idl.lib as lib
-from buildscripts.idl.idl import parser
-def gen_all_feature_flags(idl_dirs: List[str] = None):
- """Generate a list of all feature flags."""
- default_idl_dirs = ["src", "buildscripts"]
+def is_third_party_idl(idl_path: str) -> bool:
+ """Check if an IDL file is under a third party directory."""
+ third_party_idl_subpaths = [os.path.join("third_party", "mozjs"), "win32com"]
- if not idl_dirs:
- idl_dirs = default_idl_dirs
+ for file_name in third_party_idl_subpaths:
+ if file_name in idl_path:
+ return True
- all_flags = []
- for idl_dir in idl_dirs:
- for idl_path in sorted(lib.list_idls(idl_dir)):
- if lib.is_third_party_idl(idl_path):
- continue
- # Most IDL files do not contain feature flags.
- # We can discard these quickly without expensive YAML parsing.
- with open(idl_path) as idl_file:
- if 'feature_flags' not in idl_file.read():
- continue
- with open(idl_path) as idl_file:
- doc = parser.parse_file(idl_file, idl_path)
- for feature_flag in doc.spec.feature_flags:
- if feature_flag.default.literal != "true":
- all_flags.append(feature_flag.name)
-
- with open("buildscripts/resmokeconfig/fully_disabled_feature_flags.yml") as fully_disabled_ffs:
- force_disabled_flags = yaml.safe_load(fully_disabled_ffs)
+ return False
- return list(set(all_flags) - set(force_disabled_flags))
+def gen_all_feature_flags(idl_dir: str, import_dirs: List[str]):
+ """Generate a list of all feature flags."""
+ all_flags = []
+ for idl_path in sorted(lib.list_idls(idl_dir)):
+ if is_third_party_idl(idl_path):
+ continue
+ for feature_flag in lib.parse_idl(idl_path, import_dirs).spec.feature_flags:
+ if feature_flag.default.literal != "true":
+ all_flags.append(feature_flag.name)
-def gen_all_feature_flags_file(filename: str = lib.ALL_FEATURE_FLAG_FILE):
- """Output generated list of feature flags to specified file."""
- flags = gen_all_feature_flags()
- with open(filename, "w") as output_file:
- output_file.write("\n".join(flags))
- print("Generated: ", os.path.realpath(output_file.name))
+ force_disabled_flags = yaml.safe_load(
+ open("buildscripts/resmokeconfig/fully_disabled_feature_flags.yml"))
+
+ return list(set(all_flags) - set(force_disabled_flags))
def main():
"""Run the main function."""
- gen_all_feature_flags_file()
+ arg_parser = argparse.ArgumentParser(description=__doc__)
+ arg_parser.add_argument("--import-dir", dest="import_dirs", type=str, action="append",
+ help="Directory to search for IDL import files")
+
+ args = arg_parser.parse_args()
+
+ flags = gen_all_feature_flags(os.getcwd(), args.import_dirs)
+ with open(lib.ALL_FEATURE_FLAG_FILE, "w") as output_file:
+ for flag in flags:
+ output_file.write("%s\n" % flag)
if __name__ == '__main__':