mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-29 23:27:25 -04:00
Mods: Curate exports and generate link stubs
`symgen exports` replaces -export_dynamic on Apple and curates
Android's dynamic symbols with a version script. `symgen stub` then
emits sdk/stub-{macos,ios,tvos}-<arch>, sdk/stub-android-<arch>.so,
and sdk/windows-<arch>.lib.
This commit is contained in:
+6
-3
@@ -491,9 +491,12 @@ if (WIN32)
|
||||
target_link_libraries(dusklight PRIVATE Psapi)
|
||||
endif ()
|
||||
if (APPLE)
|
||||
# Mods resolve game symbols from the executable at dlopen time.
|
||||
target_link_options(dusklight PRIVATE -Wl,-export_dynamic)
|
||||
elseif (UNIX AND NOT ANDROID)
|
||||
include(cmake/AppleExports.cmake)
|
||||
setup_apple_exports(dusklight)
|
||||
elseif (ANDROID)
|
||||
include(cmake/AndroidExports.cmake)
|
||||
setup_android_exports(dusklight)
|
||||
elseif (UNIX)
|
||||
target_link_options(dusklight PRIVATE -rdynamic)
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ function(setup_android_exports target)
|
||||
# TODO: src/dusk/ is NOT excluded: inline code in game headers
|
||||
# currently call into it (e.g. dusk::frame_interp::lookup_replacement).
|
||||
COMMAND "${SYMGEN_EXE}" exports
|
||||
--rsp "${_rsp}"
|
||||
"@${_rsp}"
|
||||
--out "${_vscript}"
|
||||
--format version-script
|
||||
--exclude cmake_pch
|
||||
@@ -53,16 +53,10 @@ function(setup_android_exports target)
|
||||
target_link_options(${target} PRIVATE "-Wl,--version-script=${_vscript}")
|
||||
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _arch)
|
||||
if (_arch STREQUAL "aarch64")
|
||||
set(_machine "arm64")
|
||||
else ()
|
||||
set(_machine "amd64")
|
||||
endif ()
|
||||
|
||||
set(_stub "${CMAKE_BINARY_DIR}/stub-android-${_arch}.so")
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND "${SYMGEN_EXE}" stub -f elf "$<TARGET_FILE:${target}>" -o "${_stub}"
|
||||
--soname "$<TARGET_FILE_NAME:${target}>" --machine "${_machine}"
|
||||
--soname "$<TARGET_FILE_NAME:${target}>" --arch "${_arch}"
|
||||
BYPRODUCTS "${_stub}"
|
||||
COMMENT "Generating dusklight link stub"
|
||||
VERBATIM)
|
||||
|
||||
@@ -44,7 +44,7 @@ function(setup_apple_exports target)
|
||||
# TODO: src/dusk/ is NOT excluded: inline code in game headers
|
||||
# currently call into it (e.g. dusk::frame_interp::lookup_replacement).
|
||||
COMMAND "${_symgen}" exports
|
||||
--rsp "${_rsp}"
|
||||
"@${_rsp}"
|
||||
--out "${_exp}"
|
||||
--exclude cmake_pch
|
||||
--exclude miniz
|
||||
|
||||
@@ -2,7 +2,7 @@ include_guard(GLOBAL)
|
||||
|
||||
get_filename_component(_SYMBOL_MANIFEST_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
|
||||
|
||||
set(_SYMGEN_VERSION "1.1.1")
|
||||
set(_SYMGEN_VERSION "1.2.0")
|
||||
set(_SYMGEN_RELEASE_BASE_URL "https://github.com/encounter/symgen/releases/download/v${_SYMGEN_VERSION}")
|
||||
set(SYMGEN_PATH "" CACHE FILEPATH "Path to a symgen executable; empty downloads the pinned release")
|
||||
mark_as_advanced(SYMGEN_PATH)
|
||||
|
||||
@@ -53,7 +53,7 @@ function(setup_windows_exports target)
|
||||
# TODO: src/dusk/ is NOT excluded: inline code in game headers
|
||||
# currently call into it (e.g. dusk::frame_interp::lookup_replacement).
|
||||
COMMAND "${_symgen}" def
|
||||
--rsp "${_rsp}"
|
||||
"@${_rsp}"
|
||||
--out "${_def}"
|
||||
--exclude cmake_pch
|
||||
--exclude miniz
|
||||
@@ -82,9 +82,7 @@ function(setup_windows_exports target)
|
||||
COMMENT "Generating dusklight import library"
|
||||
VERBATIM)
|
||||
set(DUSK_GAME_IMPLIB "${_implib}" CACHE INTERNAL "Import library for Windows mod linking")
|
||||
set(DUSK_GAME_DEF "${_def}" CACHE INTERNAL "Curated export .def for the game executable")
|
||||
|
||||
# Ship the import library as sdk/dusklight.lib in the install tree: mods may use it to
|
||||
# compile against Dusklight without having to build the whole game. (See DUSK_GAME_IMPLIB)
|
||||
install(FILES "${_implib}" DESTINATION sdk RENAME dusklight.lib)
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _implib_arch)
|
||||
install(FILES "${_implib}" DESTINATION sdk RENAME "windows-${_implib_arch}.lib")
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user