mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
Meta: Tentatively support BSD distributions in ladybird.py
Support was unknowingly dropped when porting ladybird.sh to ladybird.py. This tentatively restores this support, but is untested on a BSD system.
This commit is contained in:
parent
7ce88eb4cd
commit
aa0fcc67b3
Notes:
github-actions[bot]
2025-05-29 23:34:49 +00:00
Author: https://github.com/trflynn89
Commit: aa0fcc67b3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4904
Reviewed-by: https://github.com/ADKaster
3 changed files with 28 additions and 22 deletions
|
@ -123,6 +123,9 @@ def pick_host_compiler(platform: Platform, cc: str, cxx: str) -> tuple[str, str]
|
|||
"gcc-14",
|
||||
]
|
||||
|
||||
if platform.host_system == HostSystem.BSD:
|
||||
gcc_candidates.append("egcc")
|
||||
|
||||
if platform.host_system == HostSystem.macOS:
|
||||
clang_homebrew_path = Path("/opt/homebrew/opt/llvm/bin")
|
||||
homebrew_path = Path("/opt/homebrew/bin")
|
||||
|
@ -131,7 +134,7 @@ def pick_host_compiler(platform: Platform, cc: str, cxx: str) -> tuple[str, str]
|
|||
clang_candidates.extend([str(homebrew_path.joinpath(c)) for c in clang_candidates])
|
||||
|
||||
gcc_candidates.extend([str(homebrew_path.joinpath(c)) for c in gcc_candidates])
|
||||
elif platform.host_system == HostSystem.Linux:
|
||||
elif platform.host_system in (HostSystem.Linux, HostSystem.BSD):
|
||||
local_path = Path("/usr/local/bin")
|
||||
|
||||
clang_candidates.extend([str(local_path.joinpath(c)) for c in clang_candidates])
|
||||
|
@ -166,15 +169,9 @@ def pick_host_compiler(platform: Platform, cc: str, cxx: str) -> tuple[str, str]
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def default_host_compiler(platform: Platform) -> tuple[str, str]:
|
||||
if platform.host_system == HostSystem.Windows:
|
||||
return ("clang-cl", "clang-cl")
|
||||
return ("cc", "c++")
|
||||
|
||||
|
||||
def main():
|
||||
platform = Platform()
|
||||
(default_cc, default_cxx) = default_host_compiler(platform)
|
||||
(default_cc, default_cxx) = platform.default_compiler()
|
||||
|
||||
parser = argparse.ArgumentParser(description="Find valid compilers")
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class HostSystem(enum.IntEnum):
|
|||
Linux = enum.auto()
|
||||
macOS = enum.auto()
|
||||
Windows = enum.auto()
|
||||
BSD = enum.auto()
|
||||
|
||||
|
||||
class Platform:
|
||||
|
@ -28,6 +29,8 @@ class Platform:
|
|||
self.host_system = HostSystem.macOS
|
||||
elif self.system == "Linux":
|
||||
self.host_system = HostSystem.Linux
|
||||
elif self.system in ("FreeBSD", "OpenBSD", "NetBSD", "DragonFly"):
|
||||
self.host_system = HostSystem.BSD
|
||||
else:
|
||||
print(f"Unsupported host system {self.system}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
@ -40,3 +43,20 @@ class Platform:
|
|||
else:
|
||||
print(f"Unsupported host architecture {self.architecture}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def default_compiler(self) -> tuple[str, str]:
|
||||
if self.host_system == HostSystem.Windows:
|
||||
return ("clang-cl", "clang-cl")
|
||||
return ("cc", "c++")
|
||||
|
||||
def default_debugger(self) -> str:
|
||||
if self.host_system in (HostSystem.Linux, HostSystem.BSD):
|
||||
return "gdb"
|
||||
return "lldb"
|
||||
|
||||
def default_symbolizer(self) -> str:
|
||||
if self.host_system == HostSystem.Windows:
|
||||
return "llvm-symbolizer"
|
||||
if self.host_system == HostSystem.macOS:
|
||||
return "atos"
|
||||
return "addr2line"
|
||||
|
|
|
@ -18,7 +18,6 @@ from typing import Optional
|
|||
|
||||
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from Meta.find_compiler import default_host_compiler
|
||||
from Meta.find_compiler import pick_host_compiler
|
||||
from Meta.host_platform import HostArchitecture
|
||||
from Meta.host_platform import HostSystem
|
||||
|
@ -29,7 +28,7 @@ from Toolchain.BuildVcpkg import build_vcpkg
|
|||
|
||||
def main():
|
||||
platform = Platform()
|
||||
(default_cc, default_cxx) = default_host_compiler(platform)
|
||||
(default_cc, default_cxx) = platform.default_compiler()
|
||||
|
||||
parser = argparse.ArgumentParser(description="Ladybird")
|
||||
subparsers = parser.add_subparsers(dest="command")
|
||||
|
@ -76,9 +75,7 @@ def main():
|
|||
help="Launches the application on the build host in a gdb or lldb session",
|
||||
parents=[preset_parser, target_parser],
|
||||
)
|
||||
debug_parser.add_argument(
|
||||
"--debugger", required=False, default="gdb" if platform.host_system == HostSystem.Linux else "lldb"
|
||||
)
|
||||
debug_parser.add_argument("--debugger", required=False, default=platform.default_debugger())
|
||||
debug_parser.add_argument(
|
||||
"-cmd", action="append", required=False, default=[], help="Additional commands passed through to the debugger"
|
||||
)
|
||||
|
@ -107,15 +104,7 @@ def main():
|
|||
help="Resolves the addresses in the target binary to a file:line",
|
||||
parents=[preset_parser, compiler_parser, target_parser],
|
||||
)
|
||||
addr2line_parser.add_argument(
|
||||
"--program",
|
||||
required=False,
|
||||
default=(
|
||||
"llvm-symbolizer"
|
||||
if platform.host_system == HostSystem.Windows
|
||||
else "addr2line" if platform.host_system == HostSystem.Linux else "atos"
|
||||
),
|
||||
)
|
||||
addr2line_parser.add_argument("--program", required=False, default=platform.default_symbolizer())
|
||||
addr2line_parser.add_argument("addresses", nargs=argparse.REMAINDER)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue