More Fixes

This commit is contained in:
TheBrokenRail 2022-07-07 00:37:53 -04:00
parent 4bd2fecfa2
commit 3937f88084
13 changed files with 46 additions and 25 deletions

View File

@ -6,12 +6,15 @@ set(MCPI_BUILD_MODE "native" CACHE STRING "\"arm\" = Build Only Code That Must B
set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native") set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native")
option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE) option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE)
option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE) option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE)
# Server/Headless Builds # Server/Headless Builds
option(MCPI_SERVER_MODE "Server Mode" FALSE) option(MCPI_SERVER_MODE "Server Mode" FALSE)
option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE}) option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE})
# ARMHF Sysroot # ARMHF Sysroot
option(MCPI_BUNDLE_ARMHF_SYSROOT "Whether To Include An ARMHF Sysroot" ${MCPI_IS_MIXED_BUILD}) option(MCPI_BUNDLE_ARMHF_SYSROOT "Whether To Include An ARMHF Sysroot" ${MCPI_IS_MIXED_BUILD})
set(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT "" CACHE PATH "Custom Bundled ARMHF Sysroot") set(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT "" CACHE PATH "Custom Bundled ARMHF Sysroot")
# Media Layer # Media Layer
if(NOT MCPI_HEADLESS_MODE) if(NOT MCPI_HEADLESS_MODE)
option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${MCPI_IS_MIXED_BUILD}) option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${MCPI_IS_MIXED_BUILD})
@ -20,6 +23,7 @@ else()
set(MCPI_USE_MEDIA_LAYER_PROXY FALSE) set(MCPI_USE_MEDIA_LAYER_PROXY FALSE)
set(MCPI_USE_GLES1_COMPATIBILITY_LAYER FALSE) set(MCPI_USE_GLES1_COMPATIBILITY_LAYER FALSE)
endif() endif()
# App ID # App ID
set(DEFAULT_APP_ID "com.thebrokenrail.MCPIReborn") set(DEFAULT_APP_ID "com.thebrokenrail.MCPIReborn")
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
@ -28,6 +32,7 @@ else()
string(APPEND DEFAULT_APP_ID "Client") string(APPEND DEFAULT_APP_ID "Client")
endif() endif()
set(MCPI_APP_ID "${DEFAULT_APP_ID}" CACHE STRING "App ID") set(MCPI_APP_ID "${DEFAULT_APP_ID}" CACHE STRING "App ID")
# App Title # App Title
set(DEFAULT_APP_TITLE "Minecraft: Pi Edition: Reborn") set(DEFAULT_APP_TITLE "Minecraft: Pi Edition: Reborn")
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
@ -76,6 +81,12 @@ elseif(BUILD_NATIVE_COMPONENTS)
string(APPEND MCPI_LIB_DIR "/native") string(APPEND MCPI_LIB_DIR "/native")
endif() endif()
# Share Directory
set(MCPI_SHARE_DIR "share")
if(MCPI_IS_APPIMAGE_BUILD)
string(PREPEND MCPI_SHARE_DIR "usr/")
endif()
# Build Mode # Build Mode
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")

View File

@ -16,7 +16,7 @@ set(PNG_SHARED TRUE CACHE BOOL "" FORCE)
# Download # Download
set(ZLIB_LIBRARY zlibstatic) set(ZLIB_LIBRARY zlibstatic)
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../zlib/src" "${CMAKE_CURRENT_BINARY_DIR}/../zlib/src") set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
set(CMAKE_POLICY_DEFAULT_CMP0054 OLD) # Silence Warning set(CMAKE_POLICY_DEFAULT_CMP0054 OLD) # Silence Warning
set(CMAKE_POLICY_DEFAULT_CMP0003 NEW) # Silence Warning set(CMAKE_POLICY_DEFAULT_CMP0003 NEW) # Silence Warning
set(CMAKE_POLICY_DEFAULT_CMP0022 NEW) # Fix Error set(CMAKE_POLICY_DEFAULT_CMP0022 NEW) # Fix Error

View File

@ -12,12 +12,12 @@ endif()
# Icon # Icon
install( install(
FILES "icon.png" FILES "icon.png"
DESTINATION "share/icons/hicolor/scalable/apps" DESTINATION "${MCPI_SHARE_DIR}/icons/hicolor/scalable/apps"
RENAME "${MCPI_APP_ID}.png" RENAME "${MCPI_APP_ID}.png"
) )
# AppImage # AppImage
if(MCPI_IS_APPIMAGE_BUILD) if(MCPI_IS_APPIMAGE_BUILD)
install_symlink("share/icons/hicolor/scalable/apps/${MCPI_APP_ID}.png" "${MCPI_APP_ID}.png") install_symlink("${MCPI_SHARE_DIR}/icons/hicolor/scalable/apps/${MCPI_APP_ID}.png" "${MCPI_APP_ID}.png")
install_symlink("${MCPI_APP_ID}.png" ".DirIcon") install_symlink("${MCPI_APP_ID}.png" ".DirIcon")
endif() endif()

View File

@ -44,7 +44,7 @@ else()
endif() endif()
install( install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop" FILES "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop"
DESTINATION "share/applications" DESTINATION "${MCPI_SHARE_DIR}/applications"
RENAME "${MCPI_APP_ID}.desktop" RENAME "${MCPI_APP_ID}.desktop"
) )
@ -107,13 +107,12 @@ file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml"
) )
install( install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml" FILES "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml"
DESTINATION "share/metainfo" DESTINATION "${MCPI_SHARE_DIR}/metainfo"
RENAME "${MCPI_APP_ID}.appdata.xml" RENAME "${MCPI_APP_ID}.appdata.xml"
) )
# AppImage # AppImage
if(MCPI_IS_APPIMAGE_BUILD) if(MCPI_IS_APPIMAGE_BUILD)
install_symlink("bin/${MCPI_VARIANT_NAME}" "AppRun") install_symlink("bin/${MCPI_VARIANT_NAME}" "AppRun")
install_symlink("share/applications/${MCPI_APP_ID}.desktop" "${MCPI_APP_ID}.desktop") install_symlink("${MCPI_SHARE_DIR}/applications/${MCPI_APP_ID}.desktop" "${MCPI_APP_ID}.desktop")
install_symlink("." "usr")
endif() endif()

View File

@ -72,6 +72,12 @@ static unsigned char *code_block = NULL;
#define CODE_SIZE 8 #define CODE_SIZE 8
static int code_block_remaining = CODE_BLOCK_SIZE; static int code_block_remaining = CODE_BLOCK_SIZE;
static void _long_overwrite(void *start, void *target) {
unsigned char patch_data[4] = {0x04, 0xf0, 0x1f, 0xe5}; // "ldr pc, [pc, #-0x4]"
_patch(NULL, -1, start, patch_data);
_patch_address(NULL, -1, (void *) (((unsigned char *) start) + 4), target);
}
static void update_code_block(void *target) { static void update_code_block(void *target) {
// BL Instructions Can Only Access A Limited Portion of Memory, So This Allocates Memory Closer To The Original Instruction, That When Run, Will Jump Into The Actual Target // BL Instructions Can Only Access A Limited Portion of Memory, So This Allocates Memory Closer To The Original Instruction, That When Run, Will Jump Into The Actual Target
if (code_block == NULL) { if (code_block == NULL) {
@ -84,7 +90,7 @@ static void update_code_block(void *target) {
if (code_block_remaining < CODE_SIZE) { if (code_block_remaining < CODE_SIZE) {
ERR("Maximum Amount Of overwrite_calls() Uses Reached"); ERR("Maximum Amount Of overwrite_calls() Uses Reached");
} }
_overwrite(NULL, -1, code_block, target); _long_overwrite(code_block, target);
} }
static void increment_code_block() { static void increment_code_block() {
code_block = code_block + CODE_SIZE; code_block = code_block + CODE_SIZE;
@ -92,18 +98,21 @@ static void increment_code_block() {
} }
// Overwrite Specific B(L) Instruction // Overwrite Specific B(L) Instruction
void _overwrite_call(const char *file, int line, void *start, void *target) { static void _overwrite_call_internal(const char *file, int line, void *start, void *target, int use_b_instruction) {
// Add New Target To Code Block // Add New Target To Code Block
update_code_block(target); update_code_block(target);
// Patch // Patch
int use_b_instruction = ((unsigned char *) start)[3] == B_INSTRUCTION;
uint32_t new_instruction = generate_bl_instruction(start, code_block, use_b_instruction); uint32_t new_instruction = generate_bl_instruction(start, code_block, use_b_instruction);
_patch(file, line, start, (unsigned char *) &new_instruction); _patch(file, line, start, (unsigned char *) &new_instruction);
// Increment Code Block Position // Increment Code Block Position
increment_code_block(); increment_code_block();
} }
void _overwrite_call(const char *file, int line, void *start, void *target) {
int use_b_instruction = ((unsigned char *) start)[3] == B_INSTRUCTION;
_overwrite_call_internal(file, line, start, target, use_b_instruction);
}
// Overwrite All B(L) Intrusctions That Target The Specified Address // Overwrite All B(L) Intrusctions That Target The Specified Address
void _overwrite_calls(const char *file, int line, void *start, void *target) { void _overwrite_calls(const char *file, int line, void *start, void *target) {
@ -144,12 +153,8 @@ void *extract_from_bl_instruction(unsigned char *from) {
} }
// Overwrite Function // Overwrite Function
// NOTE: "start" Must Be At Least 8 Bytes Long
void _overwrite(const char *file, int line, void *start, void *target) { void _overwrite(const char *file, int line, void *start, void *target) {
unsigned char patch_data[4] = {0x04, 0xf0, 0x1f, 0xe5}; // "ldr pc, [pc, #-0x4]" _overwrite_call_internal(file, line, start, target, 1);
_patch(file, line, start, patch_data);
_patch_address(file, line, (void *) (((unsigned char *) start) + 4), target);
} }
// Print Patch Debug Data // Print Patch Debug Data

View File

@ -1,4 +1,4 @@
project(media-layer-stubs) project(media-layer-gles)
# Stubs Only Needed For ARM # Stubs Only Needed For ARM
if(NOT MCPI_HEADLESS_MODE AND ((BUILD_NATIVE_COMPONENTS AND MCPI_USE_MEDIA_LAYER_PROXY) OR (BUILD_ARM_COMPONENTS AND NOT MCPI_USE_MEDIA_LAYER_PROXY))) if(NOT MCPI_HEADLESS_MODE AND ((BUILD_NATIVE_COMPONENTS AND MCPI_USE_MEDIA_LAYER_PROXY) OR (BUILD_ARM_COMPONENTS AND NOT MCPI_USE_MEDIA_LAYER_PROXY)))

View File

@ -11,19 +11,25 @@ BRANCH='master'
./scripts/build.sh "$1" "$2" ./scripts/build.sh "$1" "$2"
# Download Runtime # Download Runtime
mkdir -p build/appimage
if [ ! -f "build/appimage/runtime-$2" ]; then
case "$2" in case "$2" in
'armhf') RUNTIME_ARCH='armhf';; 'armhf') RUNTIME_ARCH='armhf';;
'arm64') RUNTIME_ARCH='aarch64';; 'arm64') RUNTIME_ARCH='aarch64';;
'i386') RUNTIME_ARCH='i686';; 'i386') RUNTIME_ARCH='i686';;
'amd64') RUNTIME_ARCH='x86_64';; 'amd64') RUNTIME_ARCH='x86_64';;
esac esac
mkdir -p build/appimage
if [ ! -f "build/appimage/runtime-$2" ]; then
wget -O "build/appimage/runtime-$2" "https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-${RUNTIME_ARCH}" wget -O "build/appimage/runtime-$2" "https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-${RUNTIME_ARCH}"
fi fi
# Package # Package
ARCH="${RUNTIME_ARCH}" appimagetool \ case "$2" in
'armhf') APPIMAGE_ARCH='arm';;
'arm64') APPIMAGE_ARCH='arm_aarch64';;
'i386') APPIMAGE_ARCH='i686';;
'amd64') APPIMAGE_ARCH='x86_64';;
esac
ARCH="${APPIMAGE_ARCH}" appimagetool \
--updateinformation "zsync|https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/${BRANCH}/lastSuccessfulBuild/artifact/out/${NAME}-latest-$2.AppImage.zsync" \ --updateinformation "zsync|https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/${BRANCH}/lastSuccessfulBuild/artifact/out/${NAME}-latest-$2.AppImage.zsync" \
--runtime-file "build/appimage/runtime-$2" \ --runtime-file "build/appimage/runtime-$2" \
--comp xz \ --comp xz \

View File

@ -3,12 +3,12 @@
set -e set -e
# ARM Toolchain File # ARM Toolchain File
ARM_TOOLCHAIN_FILE="$(pwd)/cmake/armhf-toolchain.cmake" ARM_TOOLCHAIN_FILE="$(pwd)/cmake/toolchain/armhf-toolchain.cmake"
# Setup # Setup
setup() { setup() {
# Find Toolchain # Find Toolchain
local toolchain_file="$(pwd)/cmake/${ARCH}-toolchain.cmake" local toolchain_file="$(pwd)/cmake/toolchain/${ARCH}-toolchain.cmake"
if [ ! -f "${toolchain_file}" ]; then if [ ! -f "${toolchain_file}" ]; then
echo "Invalid Architecture: ${ARCH}" > /dev/stderr echo "Invalid Architecture: ${ARCH}" > /dev/stderr
exit 1 exit 1