mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
Meta: Migrate find_compiler.sh logic to a python script
This will allow us to re-use this logic from within other python scripts. The find_compiler.sh script still exists, as it is used by some other bash scripts. The pick_host_compiler() function will now execute find_compiler.py and store its result in $CC and $CXX. Note that the python script supports Windows.
This commit is contained in:
parent
8e792cd094
commit
3d0fdaacff
Notes:
github-actions[bot]
2025-05-29 23:35:21 +00:00
Author: https://github.com/trflynn89
Commit: 3d0fdaacff
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4904
Reviewed-by: https://github.com/ADKaster
4 changed files with 247 additions and 69 deletions
41
Meta/utils.py
Normal file
41
Meta/utils.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
|
||||
def run_command(
|
||||
command: list[str],
|
||||
input: Union[str, None] = None,
|
||||
return_output: bool = False,
|
||||
exit_on_failure: bool = False,
|
||||
) -> Optional[str]:
|
||||
stdin = subprocess.PIPE if type(input) is str else None
|
||||
stdout = subprocess.PIPE if return_output else None
|
||||
|
||||
try:
|
||||
# FIXME: For Windows, set the working directory so DLLs are found.
|
||||
with subprocess.Popen(command, stdin=stdin, stdout=stdout, text=True) as process:
|
||||
(output, _) = process.communicate(input=input)
|
||||
|
||||
if process.returncode != 0:
|
||||
if exit_on_failure:
|
||||
sys.exit(process.returncode)
|
||||
return None
|
||||
|
||||
except KeyboardInterrupt:
|
||||
process.send_signal(signal.SIGINT)
|
||||
process.wait()
|
||||
|
||||
sys.exit(process.returncode)
|
||||
|
||||
if return_output:
|
||||
return output.strip()
|
||||
|
||||
return None
|
Loading…
Add table
Add a link
Reference in a new issue