Vendor PatchELF

This commit is contained in:
TheBrokenRail 2022-07-13 11:58:35 -04:00
parent eb96d80e5a
commit 67002006f3
10 changed files with 67 additions and 25 deletions

3
.gitmodules vendored
View File

@ -10,3 +10,6 @@
[submodule "dependencies/zenity/src"] [submodule "dependencies/zenity/src"]
path = dependencies/zenity/src path = dependencies/zenity/src
url = https://gitea.thebrokenrail.com/TheBrokenRail/zenity.git url = https://gitea.thebrokenrail.com/TheBrokenRail/zenity.git
[submodule "launcher/dependencies/patchelf/src"]
path = launcher/dependencies/patchelf/src
url = https://github.com/NixOS/patchelf.git

View File

@ -1,8 +1,31 @@
# Setup Toolchain # Setup Toolchain
macro(setup_toolchain target) macro(setup_toolchain target)
# Use ARM Cross-Compiler # Target Variants
set(CMAKE_C_COMPILER "${target}-gcc") set(target_variants "${target}")
set(CMAKE_CXX_COMPILER "${target}-g++") macro(add_target_variant value)
string(REPLACE "-linux" "-${value}-linux" target_variant "${target}")
list(APPEND target_variants "${target_variant}")
endmacro()
add_target_variant(unknown)
add_target_variant(none)
add_target_variant(pc)
# Find Compiler
macro(find_compiler output name)
set(possible_names "")
foreach(possible_target IN LISTS target_variants)
list(APPEND possible_names "${possible_target}-${name}")
endforeach()
find_program(
"${output}"
NAMES ${possible_names}
NO_CACHE
)
if("${${output}}" STREQUAL "${output}-NOTFOUND")
message(FATAL_ERROR "Unable To Find ${name}")
endif()
endmacro()
find_compiler(CMAKE_C_COMPILER "gcc")
find_compiler(CMAKE_CXX_COMPILER "g++")
# Extra # Extra
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Custom Search Paths # Custom Search Paths

View File

@ -2,7 +2,6 @@
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#include <symbols/minecraft.h> #include <symbols/minecraft.h>
#include <mods/init/init.h>
#include <mods/misc/misc.h> #include <mods/misc/misc.h>
// The Actual Mod // The Actual Mod
@ -633,11 +632,7 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(unsig
} }
// Init // Init
HOOK(init_creative, void, ()) { __attribute__((constructor)) static void init_expanded_creative() {
ensure_init_creative();
(*real_init_creative)();
INFO("Loading Expanded Creative Mod"); INFO("Loading Expanded Creative Mod");
misc_run_on_creative_inventory_setup(Inventory_setupDefault_FillingContainer_addItem_call_injection); misc_run_on_creative_inventory_setup(Inventory_setupDefault_FillingContainer_addItem_call_injection);
} }

View File

@ -1,5 +1,8 @@
project(launcher) project(launcher)
# Dependencies
add_subdirectory(dependencies)
# Launcher # Launcher
add_executable(launcher src/bootstrap.c src/patchelf.c src/crash-report.c) add_executable(launcher src/bootstrap.c src/patchelf.c src/crash-report.c)
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)

View File

@ -0,0 +1,4 @@
project(launcher-dependencies)
# PatchELF
add_subdirectory(patchelf)

View File

@ -0,0 +1,14 @@
project(patchelf)
# Silence Warnings
add_compile_options(-w)
## PatchELF
# Build
add_executable(patchelf src/src/patchelf.cc)
target_compile_definitions(patchelf PRIVATE -D_FILE_OFFSET_BITS=64)
set_target_properties(patchelf PROPERTIES CXX_STANDARD 17)
# Install
install(TARGETS patchelf DESTINATION "${MCPI_BIN_DIR}")

@ -0,0 +1 @@
Subproject commit 734daa3d0f79cf1a0c81f927d846ace5d6a2c8e1

View File

@ -72,8 +72,9 @@ static void duplicate_mcpi_executable(const char *original_path, char *new_path)
"--remove-needed", "libbcm_host.so", \ "--remove-needed", "libbcm_host.so", \
"--remove-needed", "libX11.so.6", \ "--remove-needed", "libX11.so.6", \
"--remove-needed", "libEGL.so", \ "--remove-needed", "libEGL.so", \
"--replace-needed", "libGLESv2.so", "libGLESv1_CM.so.1", \ "--remove-needed", "libGLESv2.so", \
"--replace-needed", "libSDL-1.2.so.0", "libmedia-layer-core.so", \ "--remove-needed", "libSDL-1.2.so.0", \
"--add-needed", "libmedia-layer-core.so", \
new_path, \ new_path, \
NULL \ NULL \
}; \ }; \

View File

@ -1,19 +1,19 @@
project(media-layer-gles) project(media-layer-gles)
# Build # Build
if(NOT MCPI_HEADLESS_MODE) if(MCPI_HEADLESS_MODE)
if(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
# GLESv1_CM Compatibility Layer
set(GLES_SRC src/compatibility-layer/state.c src/compatibility-layer/passthrough.c src/compatibility-layer/matrix.c src/compatibility-layer/draw.c src/compatibility-layer/buffer.cpp)
else()
# Passthrough To glfwGetProcAddress()
set(GLES_SRC src/passthrough.c)
endif()
add_library(GLESv1_CM SHARED ${GLES_SRC})
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
else()
# Stubs For Headless Mode # Stubs For Headless Mode
add_library(GLESv1_CM SHARED src/stubs.c) set(GLES_SRC src/stubs.c)
elseif(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
# GLESv1_CM Compatibility Layer
set(GLES_SRC src/compatibility-layer/state.c src/compatibility-layer/passthrough.c src/compatibility-layer/matrix.c src/compatibility-layer/draw.c src/compatibility-layer/buffer.cpp)
else()
# Passthrough To glfwGetProcAddress()
set(GLES_SRC src/passthrough.c)
endif()
add_library(GLESv1_CM SHARED ${GLES_SRC})
if(NOT MCPI_HEADLESS_MODE)
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
endif() endif()
# Common # Common

View File

@ -19,6 +19,4 @@ elseif(BUILD_ARM_COMPONENTS)
# Install # Install
install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}") install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}")
install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}") install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
# Symlink GLESv1_CM To Media Layer Proxy Server
install_symlink("libmedia-layer-core.so" "${MCPI_LIB_DIR}/libGLESv1_CM.so.1")
endif() endif()