1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:07:35 +00:00

Everywhere: Add support for compilation under emscripten

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
This commit is contained in:
Ali Mohammad Pur 2022-11-20 06:53:14 +03:30 committed by Ali Mohammad Pur
parent 84502f53b5
commit 2110e7cf85
9 changed files with 50 additions and 16 deletions

View file

@ -93,6 +93,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_INSTALL_MESSAGE NEVER)
if (EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_compile_options(-gsource-map)
add_link_options(--emrun "SHELL:-s ALLOW_MEMORY_GROWTH")
endif()
if (ENABLE_ADDRESS_SANITIZER)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address")
@ -290,7 +296,7 @@ endif()
add_library(LibC INTERFACE)
add_library(LibCrypt INTERFACE)
add_library(LibSystem INTERFACE)
if (NOT APPLE AND NOT ANDROID AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
if (NOT APPLE AND NOT ANDROID AND NOT EMSCRIPTEN AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(LibCrypt INTERFACE crypt) # LibCore::Account uses crypt() but it's not in libcrypt on macOS
endif()
if (SERENITYOS)
@ -395,7 +401,7 @@ if (BUILD_LAGOM)
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# for Lagom on Apple M1
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" AND NOT EMSCRIPTEN)
# FIXME: Create a LIBELF_SOURCES macro similar to AK
file(GLOB LIBELF_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibELF/*.cpp")
# There's no way we can reliably make the dynamic loading classes cross platform
@ -446,12 +452,14 @@ if (BUILD_LAGOM)
target_link_libraries(TestJson LibCore)
# Lagom Utilities
add_executable(adjtime ../../Userland/Utilities/adjtime.cpp)
target_link_libraries(adjtime LibCore LibMain)
if (NOT EMSCRIPTEN)
add_executable(adjtime ../../Userland/Utilities/adjtime.cpp)
target_link_libraries(adjtime LibCore LibMain)
endif()
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# for Lagom on Apple M1
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" AND NOT EMSCRIPTEN)
add_executable(disasm ../../Userland/Utilities/disasm.cpp)
target_link_libraries(disasm LibCore LibELF LibX86 LibMain)
endif()
@ -470,8 +478,10 @@ if (BUILD_LAGOM)
add_executable(markdown-check ../../Userland/Utilities/markdown-check.cpp)
target_link_libraries(markdown-check LibMarkdown LibMain)
add_executable(ntpquery ../../Userland/Utilities/ntpquery.cpp)
target_link_libraries(ntpquery LibCore LibMain)
if (NOT EMSCRIPTEN)
add_executable(ntpquery ../../Userland/Utilities/ntpquery.cpp)
target_link_libraries(ntpquery LibCore LibMain)
endif()
add_executable(test262-runner ../../Tests/LibJS/test262-runner.cpp)
target_link_libraries(test262-runner LibJS LibCore)