Skip to content

Commit

Permalink
Add needed patchelf to devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
Wend4r committed Nov 30, 2024
1 parent 3996f34 commit 9ac6159
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ option(SOURCESDK_COMPILE_PROTOBUF "Compile Protocol Buffers" ON)
option(SOURCESDK_CREATE_INTEFACE_OVERRIDE "Enable it if you are using your own CreateInteface" OFF)
option(SOURCESDK_LINK_TIER0 "Link with tier0" ON)
option(SOURCESDK_LINK_STEAMWORKS "Link with Steam API" ON)
option(SOURCESDK_LINK_STRIP_CPP_EXPORTS "Strip C++/STL export funcitons. Need \"patchelf\" package" OFF)
option(SOURCESDK_LINK_STRIP_CPP_EXPORTS "Strip C++/STL export funcitons" OFF)
option(SOURCESDK_MALLOC_OVERRIDE "Valve memory system" OFF)
option(SOURCESDK_MSVC_RUNTIME_LIBRARY "MultiThreaded assembly of run-time library by MSVC" ON)

Expand Down
5 changes: 4 additions & 1 deletion cmake/sourcesdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ endif()

set(SOURCESDK_LIB_PLATFORM_DIR "${SOURCESDK_LIB_DIR}/${SOURCESDK_PLATFORM_DIR}")

set(SOURCESDK_PATCHELF_EXE "patchelf${CMAKE_EXECUTABLE_SUFFIX}")
set(SOURCESDK_PATCHELF_EXECUTABLE "${DEVTOOLS_BIN_DIR}/${SOURCESDK_PLATFORM_DIR}/${SOURCESDK_PATCHELF_EXE}")

function(append_sourcesdk_shared_library VAR_NAME LIB_NAME)
set(SOURCESDK_SHARED_LIBRARY_LIB_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_NAME}")

Expand All @@ -113,7 +116,7 @@ function(append_sourcesdk_shared_library VAR_NAME LIB_NAME)

message(STATUS "Patching ${SOURCESDK_SHARED_LIBRARY_LIB} ...")
execute_process(
COMMAND bash -c "readelf -Ws --dyn-syms ${SOURCESDK_SHARED_LIBRARY_LIB} | awk '{print $8}' | grep -E '_ZS|_ZNS|_ZNKS|_ZN9__gnu_cxx|_ZNK9__gnu_cxx|_ZTIS|_ZTT|_ZTSS|_Zd|_Zn|_NSd|St[0-9]|Si[0-9]' | awk '{print substr($0, 3)}' | awk '{print \"_Z\" $0 \" XX\" $0}' >> ${SOURCESDK_SHARED_LIBRARY_LIB_NAME}.map && patchelf --output ${SOURCESDK_SHARED_LIBRARY_LIB} --rename-dynamic-symbols ${SOURCESDK_SHARED_LIBRARY_LIB_NAME}.map ${SOURCESDK_SHARED_LIBRARY_LIB}"
COMMAND bash -c "readelf -Ws --dyn-syms ${SOURCESDK_SHARED_LIBRARY_LIB} | awk '{print $8}' | grep -E '_ZS|_ZNS|_ZNKS|_ZN9__gnu_cxx|_ZNK9__gnu_cxx|_ZTIS|_ZTT|_ZTSS|_Zd|_Zn|_NSd|St[0-9]|Si[0-9]' | awk '{print substr($0, 3)}' | awk '{print \"_Z\" $0 \" XX\" $0}' >> ${SOURCESDK_SHARED_LIBRARY_LIB_NAME}.map && ${SOURCESDK_PATCHELF_EXECUTABLE} --output ${SOURCESDK_SHARED_LIBRARY_LIB} --rename-dynamic-symbols ${SOURCESDK_SHARED_LIBRARY_LIB_NAME}.map ${SOURCESDK_SHARED_LIBRARY_LIB}"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
Expand Down
Binary file added devtools/bin/linuxsteamrt64/patchelf
Binary file not shown.

0 comments on commit 9ac6159

Please sign in to comment.