From 58a6706cf924caec9b659dd7914431b768c1d8f9 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 15 Nov 2024 15:26:33 -0500 Subject: [PATCH] Some Updates --- CMakeLists.txt | 6 ++-- cmake/cpack/appimage.cmake | 9 ++---- cmake/options/prebuilt-armhf-toolchain.cmake | 8 +++-- cmake/util/embed-resource.cmake | 9 ++++-- cmake/util/util.cmake | 4 +-- dependencies/LIEF/src | 2 +- dependencies/runtime/src | 2 +- media-layer/core/CMakeLists.txt | 18 ++++++----- media-layer/trampoline/CMakeLists.txt | 9 +++++- scripts/install-dependencies.sh | 34 +++++++++++++------- symbols/CMakeLists.txt | 17 ++++------ 11 files changed, 68 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee2c9b6e9d..4c090fb19d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,7 @@ -cmake_minimum_required(VERSION 3.17.0) +cmake_minimum_required(VERSION 3.24.0) # Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0) - cmake_policy(SET CMP0135 NEW) -endif() +cmake_policy(SET CMP0135 NEW) # Core Options include(cmake/options/core-options.cmake) diff --git a/cmake/cpack/appimage.cmake b/cmake/cpack/appimage.cmake index f8011d6a0c..fb4eaa1139 100644 --- a/cmake/cpack/appimage.cmake +++ b/cmake/cpack/appimage.cmake @@ -1,4 +1,4 @@ -# Downlaod AppImage Runtime +# Download AppImage Runtime set(RUNTIME_ARCH "unknown") if(CPACK_MCPI_ARCH STREQUAL "armhf") set(RUNTIME_ARCH "armhf") @@ -16,7 +16,7 @@ file(DOWNLOAD list(GET DOWNLOAD_STATUS 0 STATUS_CODE) list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE) if(NOT STATUS_CODE EQUAL 0) - message(FATAL_ERROR "Unable To Downlopad AppImage Runtime: ${ERROR_MESSAGE}") + message(FATAL_ERROR "Unable To Download AppImage Runtime: ${ERROR_MESSAGE}") else() message(STATUS "Downloaded AppImage Runtime: ${RUNTIME}") endif() @@ -41,11 +41,8 @@ execute_process( "${CPACK_TEMPORARY_DIRECTORY}" "${CPACK_PACKAGE_FILE_NAME}.AppImage" WORKING_DIRECTORY "${CPACK_PACKAGE_DIRECTORY}" - RESULT_VARIABLE APPIMAGETOOL_RESULT + COMMAND_ERROR_IS_FATAL ANY ) -if(NOT APPIMAGETOOL_RESULT EQUAL 0) - message(FATAL_ERROR "Unable Package AppImage") -endif() # Rename ZSync File file(RENAME "${CPACK_PACKAGE_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}.AppImage.zsync" "${CPACK_PACKAGE_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME_ZSYNC}.AppImage.zsync") diff --git a/cmake/options/prebuilt-armhf-toolchain.cmake b/cmake/options/prebuilt-armhf-toolchain.cmake index 06cbc0aa6a..5c756ff3d3 100644 --- a/cmake/options/prebuilt-armhf-toolchain.cmake +++ b/cmake/options/prebuilt-armhf-toolchain.cmake @@ -52,7 +52,11 @@ if("${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc" IS_NEWER_THAN "${sysroot_ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*") foreach(file IN LISTS files) - execute_process(COMMAND "${toolchain_dir}/bin/arm-none-linux-gnueabihf-strip" "${file}" RESULT_VARIABLE ret) + execute_process( + COMMAND "${toolchain_dir}/bin/arm-none-linux-gnueabihf-strip" "${file}" + RESULT_VARIABLE ret + ERROR_QUIET + ) # Check Result if(NOT ret EQUAL 0) # Delete Invalid Files @@ -66,7 +70,7 @@ endif() function(install_arm_sysroot) file(GLOB_RECURSE files LIST_DIRECTORIES FALSE RELATIVE "${sysroot_dir}" "${sysroot_dir}/*") foreach(file IN LISTS files) - get_filename_component(parent "${file}" DIRECTORY) + cmake_path(GET file PARENT_PATH parent) install(PROGRAMS "${sysroot_dir}/${file}" DESTINATION "${MCPI_INSTALL_DIR}/sysroot/${parent}") endforeach() endfunction() diff --git a/cmake/util/embed-resource.cmake b/cmake/util/embed-resource.cmake index 63379f0599..8f864f7ea2 100644 --- a/cmake/util/embed-resource.cmake +++ b/cmake/util/embed-resource.cmake @@ -5,8 +5,11 @@ file(READ "${EMBED_IN}" data HEX) string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," data "${data}") # Get C Name -get_filename_component(name "${EMBED_IN}" NAME) -string(MAKE_C_IDENTIFIER "${name}" name) +cmake_path(GET EMBED_OUT STEM name) # Write Data -file(WRITE "${EMBED_OUT}" "#include \nconst unsigned char ${name}[] = {${data}};\nconst size_t ${name}_len = sizeof (${name});\n") +file(WRITE "${EMBED_OUT}" + "#include \n" + "const unsigned char ${name}[] = {${data}};\n" + "const size_t ${name}_len = sizeof (${name});\n" +) diff --git a/cmake/util/util.cmake b/cmake/util/util.cmake index ae67a4a38d..75c7d8b720 100644 --- a/cmake/util/util.cmake +++ b/cmake/util/util.cmake @@ -1,6 +1,6 @@ # Symlink Function function(install_symlink target link) - get_filename_component(parent "${link}" DIRECTORY) + cmake_path(GET link PARENT_PATH parent) if(parent STREQUAL "") set(parent ".") endif() @@ -13,7 +13,7 @@ endfunction() set(util_list_dir "${CMAKE_CURRENT_LIST_DIR}") function(embed_resource target file) # Get C Name - get_filename_component(name "${file}" NAME) + cmake_path(GET file FILENAME name) string(MAKE_C_IDENTIFIER "${name}" name) # Add Command add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c" diff --git a/dependencies/LIEF/src b/dependencies/LIEF/src index bae887e095..f4d68357cb 160000 --- a/dependencies/LIEF/src +++ b/dependencies/LIEF/src @@ -1 +1 @@ -Subproject commit bae887e095d87e756d1bf4aa4f95a97693a97b62 +Subproject commit f4d68357cb51fc251555e69e2679f5bb11af75ea diff --git a/dependencies/runtime/src b/dependencies/runtime/src index bf46eaf1c5..b42021ba5d 160000 --- a/dependencies/runtime/src +++ b/dependencies/runtime/src @@ -1 +1 @@ -Subproject commit bf46eaf1c596fa34c760f26ea5eab679c3e66336 +Subproject commit b42021ba5d45c29e22cbdd887e2fae5a1c1334a1 diff --git a/media-layer/core/CMakeLists.txt b/media-layer/core/CMakeLists.txt index efa72a28d9..3fcc565c07 100644 --- a/media-layer/core/CMakeLists.txt +++ b/media-layer/core/CMakeLists.txt @@ -25,12 +25,14 @@ install(TARGETS media-layer-core-real DESTINATION "${MCPI_LIB_DIR}") # Link find_library(OPENAL_LIBRARY NAMES openal REQUIRED) target_link_libraries(media-layer-core-real - PUBLIC media-layer-headers - PUBLIC reborn-util - PRIVATE "${OPENAL_LIBRARY}" - PRIVATE m - PRIVATE glfw - PUBLIC GLESv1_CM - PRIVATE LIB_LIEF - PUBLIC dl + PUBLIC + media-layer-headers + reborn-util + GLESv1_CM + dl + PRIVATE + "${OPENAL_LIBRARY}" + m + glfw + LIB_LIEF ) diff --git a/media-layer/trampoline/CMakeLists.txt b/media-layer/trampoline/CMakeLists.txt index 0a33a77429..19952507ab 100644 --- a/media-layer/trampoline/CMakeLists.txt +++ b/media-layer/trampoline/CMakeLists.txt @@ -14,7 +14,14 @@ if(BUILD_NATIVE_COMPONENTS) elseif(BUILD_ARM_COMPONENTS) # Guest Component add_library(media-layer-core SHARED src/guest/guest.cpp ${MEDIA_LAYER_TRAMPOLINE_SRC}) - target_link_libraries(media-layer-core PUBLIC media-layer-headers PRIVATE reborn-util PRIVATE trampoline-headers PRIVATE rt) + target_link_libraries(media-layer-core + PUBLIC + media-layer-headers + PRIVATE + reborn-util + trampoline-headers + rt + ) target_compile_definitions(media-layer-core PRIVATE -DMEDIA_LAYER_TRAMPOLINE_GUEST) # Install if(MCPI_USE_MEDIA_LAYER_TRAMPOLINE) diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index edf297b065..74b12959eb 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -9,6 +9,26 @@ if [ "$(id -u)" -eq 0 ]; then } fi +# Setup Backports +CODENAME="$(. /etc/os-release && echo "${VERSION_CODENAME}")" +BACKPORTS='' +if [ "${CODENAME}" = 'bullseye' ]; then + BACKPORTS="${CODENAME}-backports" + echo "deb http://deb.debian.org/debian ${BACKPORTS} main" | sudo tee "/etc/apt/sources.list.d/${BACKPORTS}.list" > /dev/null + BACKPORTS="/${BACKPORTS}" +fi + +# Variables +MODE="$1" +ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')" + +# Add ARM Repository +sudo dpkg --add-architecture "${ARCH}" + +# Update APT +sudo apt-get update +sudo apt-get dist-upgrade -y + # Run APT install_pkg() { sudo apt-get install --no-install-recommends -y "$@" @@ -19,10 +39,11 @@ run_build() { install_pkg \ `# Build System` \ git \ - cmake \ + "cmake${BACKPORTS}" \ ninja-build \ python3 \ python3-venv \ + "python3-tomli${BACKPORTS}" \ `# Host Dependencies Needed For Compile` \ libwayland-bin \ `# Compiler` \ @@ -84,16 +105,5 @@ run_example_mods() { gcc-arm-linux-gnueabihf } -# Variables -MODE="$1" -ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')" - -# Add ARM Repository -sudo dpkg --add-architecture "${ARCH}" - -# Update APT -sudo apt-get update -sudo apt-get dist-upgrade -y - # Install Packages "run_${MODE}" "${ARCH}" diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index da35d97763..d632290d07 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -214,18 +214,18 @@ set(HEADER_OUTPUT_FILE "${HEADER_OUTPUT_DIR}/minecraft.h") # Generated Source Files set(SRC_OUTPUT_FILES "") -foreach(FILE IN LISTS SRC) - get_filename_component(FILE_EXT "${FILE}" EXT) - if(FILE_EXT STREQUAL ".def") - get_filename_component(FILE "${FILE}" NAME_WE) - list(APPEND SRC_OUTPUT_FILES "${SRC_OUTPUT_DIR}/${FILE}.cpp") +foreach(file IN LISTS SRC) + cmake_path(GET file EXTENSION file_ext) + if(file_ext STREQUAL ".def") + cmake_path(GET file STEM file) + list(APPEND SRC_OUTPUT_FILES "${SRC_OUTPUT_DIR}/${file}.cpp") endif() endforeach() # Generate set(INPUT_FILES "") -foreach(FILE IN LISTS SRC) - list(APPEND INPUT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}") +foreach(file IN LISTS SRC) + list(APPEND INPUT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${file}") endforeach() set(OUTPUT_FILES ${SRC_OUTPUT_FILES} "${HEADER_OUTPUT_FILE}") add_custom_command( @@ -239,9 +239,6 @@ add_custom_command( # Build add_library(symbols SHARED ${OUTPUT_FILES}) -# Speed Up Compilation -#target_precompile_headers(symbols PRIVATE "${HEADER_OUTPUT_FILE}") - # Show In IDE add_custom_target(symbols-src DEPENDS "${SRC_OUTPUT_FILE}" "${HEADER_OUTPUT_FILE}"