mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
Meta: Add build support for RISC-V (riscv64)
Co-authored-by: Bas M. <bas@opvolger.net>
This commit is contained in:
parent
5b2a71a712
commit
b28a97b399
6
Meta/CMake/vcpkg/base-triplets/riscv64-linux.cmake
Normal file
6
Meta/CMake/vcpkg/base-triplets/riscv64-linux.cmake
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
|
||||
set(VCPKG_TARGET_ARCHITECTURE riscv64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
set(VCPKG_FIXUP_ELF_RPATH ON)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/riscv64-linux.cmake)
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/debug.cmake)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/riscv64-linux.cmake)
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/distribution.cmake)
|
||||
|
|
@ -49,7 +49,9 @@ if (NOT DEFINED CACHE{VCPKG_TARGET_TRIPLET} AND NOT DEFINED CACHE{VCPKG_HOST_TRI
|
|||
cmake_host_system_information(RESULT os_name QUERY OS_NAME)
|
||||
|
||||
if(os_platform MATCHES "^(x86_64|AMD64|amd64)$")
|
||||
set(arch x64)
|
||||
set(arch x64)
|
||||
elseif(os_platform STREQUAL "riscv64")
|
||||
set(arch riscv64)
|
||||
elseif(os_platform MATCHES "^(aarch64|arm64|ARM64)$")
|
||||
set(arch arm64)
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
|||
set(ANGLE_CPU_BITNESS ANGLE_IS_32_BIT_CPU)
|
||||
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
||||
set(ANGLE_CPU_BITNESS ANGLE_IS_64_BIT_CPU)
|
||||
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "riscv64")
|
||||
set(ANGLE_CPU_BITNESS ANGLE_IS_64_BIT_CPU)
|
||||
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
||||
set(ANGLE_CPU_BITNESS ANGLE_IS_32_BIT_CPU)
|
||||
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/riscv64-linux.cmake)
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/release.cmake)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/riscv64-linux.cmake)
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/sanitizer.cmake)
|
||||
|
|
@ -11,6 +11,7 @@ import sys
|
|||
|
||||
class HostArchitecture(enum.IntEnum):
|
||||
x86_64 = enum.auto()
|
||||
riscv64 = enum.auto()
|
||||
AArch64 = enum.auto()
|
||||
|
||||
|
||||
|
|
@ -39,6 +40,8 @@ class Platform:
|
|||
self.architecture = platform.machine().lower()
|
||||
if self.architecture in ("x86_64", "amd64"):
|
||||
self.host_architecture = HostArchitecture.x86_64
|
||||
elif self.architecture == "riscv64":
|
||||
self.host_architecture = HostArchitecture.riscv64
|
||||
elif self.architecture in ("aarch64", "arm64"):
|
||||
self.host_architecture = HostArchitecture.AArch64
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -175,12 +175,12 @@ def main():
|
|||
build_main(build_dir, args.jobs, args.target, args.args)
|
||||
build_main(build_dir, args.jobs, "install", args.args)
|
||||
elif args.command == "vcpkg":
|
||||
configure_build_env(args.preset)
|
||||
configure_build_env(platform, args.preset)
|
||||
build_vcpkg()
|
||||
elif args.command == "clean":
|
||||
clean_main(args.preset)
|
||||
clean_main(platform, args.preset)
|
||||
elif args.command == "rebuild":
|
||||
clean_main(args.preset)
|
||||
clean_main(platform, args.preset)
|
||||
build_dir = configure_main(platform, args.preset, args.cc, args.cxx)
|
||||
build_main(build_dir, args.jobs, args.target, args.args)
|
||||
elif args.command == "addr2line":
|
||||
|
|
@ -190,7 +190,7 @@ def main():
|
|||
|
||||
|
||||
def configure_main(platform: Platform, preset: str, cc: str, cxx: str) -> Path:
|
||||
ladybird_source_dir, build_preset_dir = configure_build_env(preset)
|
||||
ladybird_source_dir, build_preset_dir = configure_build_env(platform, preset)
|
||||
build_vcpkg()
|
||||
|
||||
if build_preset_dir.joinpath("build.ninja").exists() or build_preset_dir.joinpath("ladybird.sln").exists():
|
||||
|
|
@ -265,7 +265,7 @@ def configure_skia_jemalloc() -> list[str]:
|
|||
return cmake_args
|
||||
|
||||
|
||||
def configure_build_env(preset: str) -> tuple[Path, Path]:
|
||||
def configure_build_env(platform: Platform, preset: str) -> tuple[Path, Path]:
|
||||
ladybird_source_dir = ensure_ladybird_source_dir()
|
||||
build_root_dir = ladybird_source_dir / "Build"
|
||||
|
||||
|
|
@ -289,6 +289,11 @@ def configure_build_env(preset: str) -> tuple[Path, Path]:
|
|||
os.environ["PATH"] += os.pathsep + str(ladybird_source_dir.joinpath("Toolchain", "Local", "cmake", "bin"))
|
||||
os.environ["PATH"] += os.pathsep + vcpkg_root
|
||||
os.environ["VCPKG_ROOT"] = vcpkg_root
|
||||
if platform.host_architecture == HostArchitecture.riscv64:
|
||||
# vcpkg refuses to build ports on riscv64 and other less common architectures without this flag.
|
||||
# With it set vcpkg will use the system provided CMake and Ninja binaries but will still download,
|
||||
# build and use its own pinned versions of gn, meson and pkg-config.
|
||||
os.environ["VCPKG_FORCE_SYSTEM_BINARIES"] = "1"
|
||||
|
||||
return ladybird_source_dir, build_preset_dir
|
||||
|
||||
|
|
@ -417,8 +422,8 @@ def profile_main(host_system: HostSystem, build_dir: Path, target: str, args: li
|
|||
run_command(valgrind_args, exit_on_failure=True)
|
||||
|
||||
|
||||
def clean_main(preset: str):
|
||||
ladybird_source_dir, build_preset_dir = configure_build_env(preset)
|
||||
def clean_main(platform: Platform, preset: str):
|
||||
ladybird_source_dir, build_preset_dir = configure_build_env(platform, preset)
|
||||
shutil.rmtree(str(build_preset_dir), ignore_errors=True)
|
||||
|
||||
user_vars_cmake_module = ladybird_source_dir.joinpath("Meta", "CMake", "vcpkg", "user-variables.cmake")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user