Meta: Add clean command to ladybird.py

This commit is contained in:
Ashton 2025-05-20 05:23:40 -07:00 committed by Andrew Kaster
commit 56fd109252
Notes: github-actions[bot] 2025-05-21 17:36:33 +00:00

View file

@ -113,6 +113,8 @@ def main(platform):
subparsers.add_parser('vcpkg', help='Ensure that dependencies are available',
parents=[preset_parser, compiler_parser])
subparsers.add_parser('clean', help='Cleans the build environment', parents=[preset_parser, compiler_parser])
args = parser.parse_args()
kwargs = vars(args)
command = kwargs.pop('command', None)
@ -162,6 +164,8 @@ def main(platform):
elif command == 'vcpkg':
_configure_build_env(**kwargs)
_build_vcpkg()
elif command == 'clean':
_clean_main(**kwargs)
def _configure_main(platform, **kwargs):
@ -424,6 +428,14 @@ def _debug_main(host_system, build_dir, **kwargs):
sys.exit(1)
def _clean_main(**kwargs):
lb_source_dir, build_preset_dir, _ = _configure_build_env(**kwargs)
shutil.rmtree(str(build_preset_dir), ignore_errors=True)
user_vars_cmake_module = lb_source_dir.joinpath('Meta', 'CMake', 'vcpkg', 'user-variables.cmake')
user_vars_cmake_module.unlink(missing_ok=True)
def _print_process_stderr(e, msg):
err_details = f': {e.stderr}' if e.stderr else ''
print(f'{msg}{err_details}', file=sys.stderr)