Update Runtime

This commit is contained in:
TheBrokenRail 2025-02-15 13:51:54 -05:00
parent 6f5f405327
commit 386e4a19eb
10 changed files with 23 additions and 38 deletions

View File

@ -1,6 +1,5 @@
# Specify Installation Paths
set(MCPI_INSTALL_DIR "lib/${MCPI_APP_NAME}")
set(MCPI_BIN_DIR "${MCPI_INSTALL_DIR}/bin")
set(MCPI_LEGAL_DIR "${MCPI_INSTALL_DIR}/legal") # For Software Licenses
set(MCPI_SDK_DIR "${MCPI_INSTALL_DIR}/sdk")
set(MCPI_SDK_LIB_DIR "${MCPI_SDK_DIR}/lib")

View File

@ -4,9 +4,3 @@ project(runtime)
# Build
add_subdirectory(src)
# RPath
if(TARGET runtime)
set_target_properties(runtime PROPERTIES INSTALL_RPATH "$ORIGIN/../lib/native")
target_link_options(runtime PRIVATE "LINKER:--disable-new-dtags")
endif()

@ -1 +1 @@
Subproject commit 84e37b572b55afb1eaa2ada1e37bc36de1584cfd
Subproject commit 5d400a2b7790f3d99284acb9d44b29012b628943

View File

@ -63,7 +63,7 @@ void bootstrap(const options_t &options) {
// Arguments
const std::vector<std::string> args {
#ifdef MCPI_BUILD_RUNTIME
"runtime",
binary_directory + "/lib/native/runtime",
#endif
new_mcpi_exe_path
};

View File

@ -28,9 +28,6 @@ static void setup_environment(const options_t &options) {
bind_to_env(_MCPI_FORCE_HEADLESS_ENV, options.force_headless);
bind_to_env(_MCPI_FORCE_NON_HEADLESS_ENV, options.force_non_headless);
// Configure PATH
setup_path();
// Setup MCPI_HOME
setup_home();
// Create If Needed

View File

@ -6,20 +6,6 @@
#include <libreborn/env/env.h>
#include <libreborn/config.h>
// $PATH
void setup_path() {
// Get Binary Directory
const std::string binary_directory = get_binary_directory();
std::string new_path = binary_directory + "/bin";
// Add Existing PATH
const char *value = getenv("PATH");
if (value != nullptr && strlen(value) > 0) {
new_path += std::string(":") + value;
}
// Set And Free
set_and_print_env("PATH", new_path.c_str());
}
// Profile Directory
void setup_home() {
const char *custom_profile_directory = getenv(MCPI_PROFILE_DIRECTORY_ENV);

View File

@ -9,7 +9,6 @@ std::string get_binary_directory();
void copy_sdk(const std::string &binary_directory, bool force);
void setup_path();
void setup_home();
bool read_directory(const std::string &path, const std::function<void(const struct dirent *)> &callback, bool allow_nonexistent_dir = false);

View File

@ -6,15 +6,15 @@ set(MEDIA_LAYER_TRAMPOLINE_SRC src/media-layer-core.cpp src/GLESv1_CM.cpp)
# Build
if(BUILD_NATIVE_COMPONENTS)
# Host Component
add_library(media-layer-trampoline src/host/host.cpp ${MEDIA_LAYER_TRAMPOLINE_SRC})
target_link_libraries(media-layer-trampoline
add_library("${TRAMPOLINE_LIBRARY_NAME}" src/host/host.cpp ${MEDIA_LAYER_TRAMPOLINE_SRC})
target_link_libraries("${TRAMPOLINE_LIBRARY_NAME}"
reborn-util
media-layer-core
trampoline-headers
)
target_compile_definitions(media-layer-trampoline PRIVATE MEDIA_LAYER_TRAMPOLINE_HOST)
target_compile_definitions("${TRAMPOLINE_LIBRARY_NAME}" PRIVATE MEDIA_LAYER_TRAMPOLINE_HOST)
# Install
setup_library(media-layer-trampoline TRUE TRUE)
setup_library("${TRAMPOLINE_LIBRARY_NAME}" TRUE TRUE)
elseif(BUILD_ARM_COMPONENTS)
# Guest Component
add_library(media-layer-core SHARED ${MEDIA_LAYER_TRAMPOLINE_SRC})

View File

@ -2,6 +2,9 @@
#include <cstring>
#include <cstdlib>
#include <utility>
#include <libreborn/log.h>
#include "../common/common.h"
@ -36,7 +39,7 @@ inline void _handle_trampoline_arg<copy_array>(unsigned char *&out, const copy_a
_handle_trampoline_arg(out, arg.size);
// Send Data
if (arg.size > 0) {
static bool just_send_pointer = getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr;
static bool just_send_pointer = !is_trampoline_pipe_based();
if (just_send_pointer) {
_handle_trampoline_arg(out, uint32_t(arg.data));
} else {
@ -49,19 +52,26 @@ inline void _handle_trampoline_arg<copy_array>(unsigned char *&out, const copy_a
__attribute__((unused)) static void _add_to_trampoline_args(__attribute__((unused)) unsigned char *&out) {
}
template <typename T, typename... Args>
void _add_to_trampoline_args(unsigned char *&out, const T &first, const Args... args) {
void _add_to_trampoline_args(unsigned char *&out, const T &first, Args&&... args) {
_handle_trampoline_arg(out, first);
_add_to_trampoline_args(out, args...);
_add_to_trampoline_args(out, std::forward<Args>(args)...);
}
// Main Trampoline Function
template <typename... Args>
unsigned int _trampoline(const unsigned int id, const bool allow_early_return, Args... args) {
unsigned int _trampoline(const unsigned int id, const bool allow_early_return, Args&&... args) {
// Create Arguments
static unsigned char out[MAX_TRAMPOLINE_ARGS_SIZE];
unsigned char *end = out;
_add_to_trampoline_args(end, args...);
_add_to_trampoline_args(end, std::forward<Args>(args)...);
const uint32_t length = end - out;
return raw_trampoline(id, allow_early_return, length, out);
// Call
uint32_t ret = 0;
const uint32_t err = raw_trampoline(id, allow_early_return ? nullptr : &ret, length, out);
if (err != 0) {
ERR("Trampoline Error: %u", err);
}
return ret;
}
#define trampoline(...) _trampoline(_id, ##__VA_ARGS__)