Path: blob/main/tools/maint/find_unused_settings.py
6177 views
#!/usr/bin/env python31"""Find unused settings from settings.js and settings_internal.js.2"""34import os5import subprocess6import sys78script_dir = os.path.dirname(os.path.abspath(__file__))9root_dir = os.path.dirname(os.path.dirname(script_dir))1011sys.path.insert(0, root_dir)1213# This avoids including `LEGACY_SETTINGS`14os.environ['EMCC_STRICT'] = '1'1516from tools.settings import settings171819def main():20print(f'Searching {len(settings.internal_settings)} internal settings')21for key in settings.internal_settings:22cmd = ['git', 'grep', '-q', f'\\<{key}\\>', '*.mjs', '*.js', ':(exclude)src/settings.js', ':(exclude)src/settings_internal.js']23if subprocess.run(cmd, check=False).returncode:24print('NOT FOUND IN JS:', key)2526print(f'Searching {len(settings.attrs)} settings')27for key in settings.attrs:28cmd = ['git', 'grep', '-q', f'\\<{key}\\>', ':(exclude)src/settings.js', ':(exclude)src/settings_internal.js']29# git grep returns 0 if there is a match and non-zero when there is not30if subprocess.run(cmd, check=False).returncode:31print('NOT FOUND ANYWHERE:', key)323334if __name__ == '__main__':35sys.exit(main())363738