diff --git a/CMakeLists.txt b/CMakeLists.txt index bcab323..b665a2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 3.13.0) +cmake_minimum_required(VERSION 3.16.0) # Specify Options option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE) -option(MCPI_BUNDLE_ARMHF_SYSROOT "Whether To Include An ARMHF Sysroot" ${MCPI_IS_MIXED_BUILD}) +set(MCPI_BUILD_MODE "both" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code; \"both\" = Build All Code As ARM") +set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "both" "arm" "native") +option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE) +option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE) +# Server/Headless Builds option(MCPI_SERVER_MODE "Server Mode" FALSE) option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE}) +# ARMHF Sysroot +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") +# Media Layer 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_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE) @@ -12,10 +20,22 @@ else() set(MCPI_USE_MEDIA_LAYER_PROXY FALSE) set(MCPI_USE_GLES1_COMPATIBILITY_LAYER FALSE) endif() -set(MCPI_BUILD_MODE "both" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code; \"both\" = Build All Code As ARM") -set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "both" "arm" "native") -option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE) -option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE) +# App ID +set(DEFAULT_APP_ID "com.thebrokenrail.MCPIReborn") +if(MCPI_SERVER_MODE) + string(APPEND DEFAULT_APP_ID "Server") +else() + string(APPEND DEFAULT_APP_ID "Client") +endif() +set(MCPI_APP_ID "${DEFAULT_APP_ID}" CACHE STRING "App ID") +# App Title +set(DEFAULT_APP_TITLE "Minecraft: Pi Edition: Reborn") +if(MCPI_SERVER_MODE) + string(APPEND DEFAULT_APP_TITLE " (Server)") +else() + string(APPEND DEFAULT_APP_TITLE " (Client)") +endif() +set(MCPI_APP_TITLE "${DEFAULT_APP_TITLE}" CACHE STRING "App Title") # Configure Build Mode if(MCPI_BUILD_MODE STREQUAL "arm") @@ -40,9 +60,9 @@ include(cmake/util.cmake) # Specify Variant Name set(MCPI_VARIANT_NAME "minecraft-pi-reborn") if(MCPI_SERVER_MODE) - set(MCPI_VARIANT_NAME "${MCPI_VARIANT_NAME}-server") + string(APPEND MCPI_VARIANT_NAME "-server") else() - set(MCPI_VARIANT_NAME "${MCPI_VARIANT_NAME}-client") + string(APPEND MCPI_VARIANT_NAME "-client") endif() # Specify Installation Paths @@ -105,31 +125,14 @@ add_definitions(-D_GNU_SOURCE) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 11) -# Specify Constants -if(MCPI_SERVER_MODE) - add_definitions(-DMCPI_SERVER_MODE) -endif() -if(MCPI_HEADLESS_MODE) - add_definitions(-DMCPI_HEADLESS_MODE) -endif() -if(MCPI_IS_APPIMAGE_BUILD) - add_definitions(-DMCPI_IS_APPIMAGE_BUILD) -endif() -if(MCPI_BUNDLE_ARMHF_SYSROOT) - add_definitions(-DMCPI_BUNDLE_ARMHF_SYSROOT) -endif() -if(MCPI_USE_GLES1_COMPATIBILITY_LAYER) - add_definitions(-DMCPI_USE_GLES1_COMPATIBILITY_LAYER) -endif() - # Version set_property( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS VERSION ) -file(STRINGS VERSION VERSION) -add_definitions(-DVERSION="${VERSION}") +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" MCPI_VERSION) +file(TIMESTAMP "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" MCPI_VERSION_DATE "%Y-%m-%d" UTC) # Build libreborn add_subdirectory(libreborn) diff --git a/dependencies/armhf-sysroot/CMakeLists.txt b/dependencies/armhf-sysroot/CMakeLists.txt index bef09ba..4cf595c 100644 --- a/dependencies/armhf-sysroot/CMakeLists.txt +++ b/dependencies/armhf-sysroot/CMakeLists.txt @@ -1,7 +1,6 @@ project(armhf-sysroot) -# Allow Custom Sysroot -set(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT "" CACHE PATH "Custom Bundled ARMHF Sysroot") +# Check If Using Custom Sysroot if(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT) # Custom Sysroot set(SYSROOT_DIR "${MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT}") diff --git a/dependencies/minecraft-pi/CMakeLists.txt b/dependencies/minecraft-pi/CMakeLists.txt index ee796be..b7c4f72 100644 --- a/dependencies/minecraft-pi/CMakeLists.txt +++ b/dependencies/minecraft-pi/CMakeLists.txt @@ -14,7 +14,8 @@ FetchContent_Populate(minecraft-pi) # Install install( DIRECTORY "${minecraft-pi_SOURCE_DIR}/" - DESTINATION "${MCPI_INSTALL_DIR}" + DESTINATION "${MCPI_INSTALL_DIR}/game" USE_SOURCE_PERMISSIONS REGEX "api" EXCLUDE ) +install_symlink("game/minecraft-pi" "${MCPI_INSTALL_DIR}/minecraft-pi") diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt index f10a1d0..6da6bf3 100644 --- a/images/CMakeLists.txt +++ b/images/CMakeLists.txt @@ -8,3 +8,10 @@ if(NOT MCPI_SERVER_MODE) RENAME "titleBG.png" ) endif() + +# Icon +install( + FILES "icon.png" + DESTINATION "share/icons/hicolor/scalable/apps" + RENAME "${MCPI_APP_ID}.png" +) diff --git a/launcher/data/com.thebrokenrail.MCPIReborn.png b/images/icon.png similarity index 100% rename from launcher/data/com.thebrokenrail.MCPIReborn.png rename to images/icon.png diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 210e9c1..1a78a9c 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1,32 +1,107 @@ project(launcher) # Launcher -if(BUILD_NATIVE_COMPONENTS) - add_executable(launcher src/bootstrap.c src/patchelf.c src/crash-report.c) - if(MCPI_SERVER_MODE) - target_sources(launcher PRIVATE src/server/launcher.c) - else() - target_sources(launcher PRIVATE src/client/launcher.cpp) - endif() - target_link_libraries(launcher reborn-util) - # Install - install(TARGETS launcher DESTINATION "${MCPI_INSTALL_DIR}") - install_symlink("../${MCPI_INSTALL_DIR}/launcher" "bin/${MCPI_VARIANT_NAME}") - set(ICON_PATH "data/com.thebrokenrail.MCPIReborn.png") - set(ICON_TARGET_PATH "share/icons/hicolor/scalable/apps") - if(NOT MCPI_SERVER_MODE) - install(DIRECTORY "data/client/" DESTINATION ".") - install( - FILES "${ICON_PATH}" - DESTINATION "${ICON_TARGET_PATH}" - RENAME "com.thebrokenrail.MCPIRebornClient.png" - ) - else() - install(DIRECTORY "data/server/" DESTINATION ".") - install( - FILES "${ICON_PATH}" - DESTINATION "${ICON_TARGET_PATH}" - RENAME "com.thebrokenrail.MCPIRebornServer.png" - ) - endif() +add_executable(launcher src/bootstrap.c src/patchelf.c src/crash-report.c) +if(MCPI_SERVER_MODE) + target_sources(launcher PRIVATE src/server/launcher.c) +else() + target_sources(launcher PRIVATE src/client/launcher.cpp) endif() +target_link_libraries(launcher reborn-util) + +# Install +install(TARGETS launcher DESTINATION "${MCPI_INSTALL_DIR}") +install_symlink("../${MCPI_INSTALL_DIR}/launcher" "bin/${MCPI_VARIANT_NAME}") + +# Install Available Feature Flags List +if(NOT MCPI_SERVER_MODE) + install(FILES "src/client/available-feature-flags" DESTINATION "${MCPI_INSTALL_DIR}") +endif() + +# Install Desktop Entry +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop" + "[Desktop Entry]\n" + "Name=${MCPI_APP_TITLE}\n" + "Comment=Fun with Blocks\n" + "Icon=${MCPI_APP_ID}\n" + "Exec=${MCPI_VARIANT_NAME}\n" + "Type=Application\n" + "Categories=Game;\n" +) +if(MCPI_SERVER_MODE) + file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop" + "Terminal=true\n" + "NoDisplay=true\n" + ) +else() + file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop" + "Terminal=false\n" + "StartupNotify=false\n" + "StartupWMClass=${MCPI_APP_TITLE}\n" + ) +endif() +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop" + DESTINATION "share/applications" + RENAME "${MCPI_APP_ID}.desktop" +) + +# Install AppStream Metadata +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml" + "\n" + "\n" + " ${MCPI_APP_ID}\n" + " ${MCPI_APP_TITLE}\n" + " CC0-1.0\n" + " Fun with Blocks\n" + "

Minecraft: Pi Edition Modding Project.

NOTE: This is not verified by, affiliated with, or supported by Mojang or Microsoft.

\n" + " https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn\n" + " ${MCPI_APP_ID}.desktop\n" + " \n" + " com.thebrokenrail.MCPIRebornClient.desktop\n" + " \n" + " LicenseRef-proprietary\n" + " TheBrokenRail & Mojang AB\n" + " \n" + " moderate\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " intense\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " none\n" + " \n" + " \n" + " \n" + " \n" +) +if(NOT MCPI_SERVER_MODE) + file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml" + " \n" + " \n" + " https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn/raw/branch/master/images/start.png\n" + " \n" + " \n" + ) +endif() +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml" + "
\n" +) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/appstream.xml" + DESTINATION "share/metainfo" + RENAME "${MCPI_APP_ID}.appdata.xml" +) diff --git a/launcher/data/client/share/applications/com.thebrokenrail.MCPIRebornClient.desktop b/launcher/data/client/share/applications/com.thebrokenrail.MCPIRebornClient.desktop deleted file mode 100755 index 3ad70d1..0000000 --- a/launcher/data/client/share/applications/com.thebrokenrail.MCPIRebornClient.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Name=Minecraft: Pi Edition: Reborn (Client) -Comment=Fun with Blocks -Icon=com.thebrokenrail.MCPIRebornClient -StartupNotify=false -StartupWMClass=Minecraft: Pi Edition: Reborn -Exec=minecraft-pi-reborn-client -Terminal=false -Type=Application -Categories=Game; diff --git a/launcher/data/client/share/metainfo/com.thebrokenrail.MCPIRebornClient.appdata.xml b/launcher/data/client/share/metainfo/com.thebrokenrail.MCPIRebornClient.appdata.xml deleted file mode 100644 index aa153eb..0000000 --- a/launcher/data/client/share/metainfo/com.thebrokenrail.MCPIRebornClient.appdata.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - com.thebrokenrail.MCPIRebornClient - Minecraft: Pi Edition: Reborn (Client) - CC0-1.0 - Fun with Blocks -

Minecraft: Pi Edition Modding Project.

NOTE: This is not verified by, affiliated with, or supported by Mojang or Microsoft.

- https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn - - - https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn/raw/branch/master/images/start.png - - - com.thebrokenrail.MCPIRebornClient.desktop - - com.thebrokenrail.MCPIRebornClient.desktop - - LicenseRef-proprietary - TheBrokenRail & Mojang AB - - moderate - none - none - none - none - none - none - none - none - none - none - none - none - intense - none - none - none - none - none - none - -
- diff --git a/launcher/data/server/share/applications/com.thebrokenrail.MCPIRebornServer.desktop b/launcher/data/server/share/applications/com.thebrokenrail.MCPIRebornServer.desktop deleted file mode 100755 index 2da04fd..0000000 --- a/launcher/data/server/share/applications/com.thebrokenrail.MCPIRebornServer.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Minecraft: Pi Edition: Reborn (Server) -Comment=Fun with Blocks -Icon=com.thebrokenrail.MCPIRebornServer -Exec=minecraft-pi-reborn-server -Terminal=true -Type=Application -Categories=Game; -NoDisplay=true diff --git a/launcher/data/server/share/metainfo/com.thebrokenrail.MCPIRebornServer.appdata.xml b/launcher/data/server/share/metainfo/com.thebrokenrail.MCPIRebornServer.appdata.xml deleted file mode 100644 index 4efe8e8..0000000 --- a/launcher/data/server/share/metainfo/com.thebrokenrail.MCPIRebornServer.appdata.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - com.thebrokenrail.MCPIRebornServer - Minecraft: Pi Edition: Reborn (Server) - CC0-1.0 - Fun with Blocks -

Minecraft: Pi Edition Modding Project.

NOTE: This is not verified by, affiliated with, or supported by Mojang or Microsoft.

- https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn - com.thebrokenrail.MCPIRebornServer.desktop - - com.thebrokenrail.MCPIRebornServer.desktop - - LicenseRef-proprietary - TheBrokenRail & Mojang AB - - moderate - none - none - none - none - none - none - none - none - none - none - none - none - intense - none - none - none - none - none - none - -
- diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index 506fa35..39df191 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -157,7 +157,7 @@ void pre_bootstrap(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-v") == 0) { // Print - printf("Reborn v%s\n", VERSION); + printf("Reborn v%s\n", MCPI_VERSION); fflush(stdout); exit(EXIT_SUCCESS); } diff --git a/launcher/data/client/lib/minecraft-pi-reborn-client/available-feature-flags b/launcher/src/client/available-feature-flags similarity index 100% rename from launcher/data/client/lib/minecraft-pi-reborn-client/available-feature-flags rename to launcher/src/client/available-feature-flags diff --git a/launcher/src/client/launcher.cpp b/launcher/src/client/launcher.cpp index b24649c..a3ba00c 100644 --- a/launcher/src/client/launcher.cpp +++ b/launcher/src/client/launcher.cpp @@ -106,12 +106,15 @@ static void run_command_and_set_env(const char *env_name, const char *command[]) } // Use Zenity To Set Environmental Variable +#define DIALOG_TITLE "Launcher" static void run_zenity_and_set_env(const char *env_name, std::vector command) { // Create Full Command std::vector full_command; full_command.push_back("zenity"); + full_command.push_back("--title"); + full_command.push_back(DIALOG_TITLE); full_command.push_back("--name"); - full_command.push_back(GUI_TITLE); + full_command.push_back(MCPI_APP_TITLE); full_command.insert(full_command.end(), command.begin(), command.end()); // Convert To C Array const char *full_command_array[full_command.size() + 1]; diff --git a/launcher/src/crash-report.c b/launcher/src/crash-report.c index 03e465d..8d609b8 100644 --- a/launcher/src/crash-report.c +++ b/launcher/src/crash-report.c @@ -21,7 +21,7 @@ static void show_report(const char *log_filename) { const char *command[] = { "zenity", "--title", DIALOG_TITLE, - "--name", GUI_TITLE, + "--name", MCPI_APP_TITLE, "--width", CRASH_REPORT_DIALOG_WIDTH, "--height", CRASH_REPORT_DIALOG_HEIGHT, "--text-info", diff --git a/libreborn/CMakeLists.txt b/libreborn/CMakeLists.txt index 5d2258b..6f713b0 100644 --- a/libreborn/CMakeLists.txt +++ b/libreborn/CMakeLists.txt @@ -1,8 +1,14 @@ project(libreborn) -add_library(reborn-util STATIC src/util/elf.c src/util/exec.c src/util/string.c src/util/util.c) -target_include_directories(reborn-util PUBLIC include) +# Config +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/libreborn") +configure_file(include/libreborn/config.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/libreborn/config.h" ESCAPE_QUOTES @ONLY) +# Util +add_library(reborn-util STATIC src/util/elf.c src/util/exec.c src/util/string.c src/util/util.c) +target_include_directories(reborn-util PUBLIC include PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include") + +# Patch if(BUILD_ARM_COMPONENTS) add_library(reborn-patch SHARED src/patch/patch.c) target_link_libraries(reborn-patch dl pthread reborn-util) diff --git a/libreborn/include/libreborn/config.h b/libreborn/include/libreborn/config.h deleted file mode 100644 index 596d4fd..0000000 --- a/libreborn/include/libreborn/config.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define GUI_TITLE "Minecraft: Pi Edition: Reborn" diff --git a/libreborn/include/libreborn/config.h.in b/libreborn/include/libreborn/config.h.in new file mode 100644 index 0000000..cb738eb --- /dev/null +++ b/libreborn/include/libreborn/config.h.in @@ -0,0 +1,9 @@ +#pragma once + +#cmakedefine MCPI_SERVER_MODE +#cmakedefine MCPI_HEADLESS_MODE +#cmakedefine MCPI_IS_APPIMAGE_BUILD +#cmakedefine MCPI_BUNDLE_ARMHF_SYSROOT +#cmakedefine MCPI_USE_GLES1_COMPATIBILITY_LAYER +#cmakedefine MCPI_APP_TITLE "@MCPI_APP_TITLE@" +#cmakedefine MCPI_VERSION "@MCPI_VERSION@" diff --git a/libreborn/include/libreborn/libreborn.h b/libreborn/include/libreborn/libreborn.h index 35766b0..dcb514d 100644 --- a/libreborn/include/libreborn/libreborn.h +++ b/libreborn/include/libreborn/libreborn.h @@ -1,6 +1,6 @@ #pragma once -#include "config.h" +#include #include "log.h" #include "util.h" #include "string.h" diff --git a/mods/src/chat/ui.c b/mods/src/chat/ui.c index bb83205..7a7385b 100644 --- a/mods/src/chat/ui.c +++ b/mods/src/chat/ui.c @@ -34,7 +34,7 @@ static void *chat_thread(__attribute__((unused)) void *nop) { const char *command[] = { "zenity", "--title", DIALOG_TITLE, - "--name", GUI_TITLE, + "--name", MCPI_APP_TITLE, "--entry", "--text", "Enter Chat Message:", NULL diff --git a/mods/src/compat/compat.c b/mods/src/compat/compat.c index 30d3f58..fad37fe 100644 --- a/mods/src/compat/compat.c +++ b/mods/src/compat/compat.c @@ -20,7 +20,7 @@ // Custom Title HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) { ensure_SDL_WM_SetCaption(); - (*real_SDL_WM_SetCaption)(GUI_TITLE, icon); + (*real_SDL_WM_SetCaption)(MCPI_APP_TITLE, icon); } // Mouse Cursor Is Always Invisible In Vanilla MCPI diff --git a/mods/src/game-mode/ui.cpp b/mods/src/game-mode/ui.cpp index da483df..046869d 100644 --- a/mods/src/game-mode/ui.cpp +++ b/mods/src/game-mode/ui.cpp @@ -89,7 +89,7 @@ static void *create_world_thread(__attribute__((unused)) void *nop) { const char *command[] = { "zenity", "--title", DIALOG_TITLE, - "--name", GUI_TITLE, + "--name", MCPI_APP_TITLE, "--entry", "--text", "Enter World Name:", "--entry-text", DEFAULT_WORLD_NAME, @@ -116,7 +116,7 @@ static void *create_world_thread(__attribute__((unused)) void *nop) { const char *command[] = { "zenity", "--title", DIALOG_TITLE, - "--name", GUI_TITLE, + "--name", MCPI_APP_TITLE, "--list", "--radiolist", "--width", GAME_MODE_DIALOG_SIZE, @@ -149,7 +149,7 @@ static void *create_world_thread(__attribute__((unused)) void *nop) { const char *command[] = { "zenity", "--title", DIALOG_TITLE, - "--name", GUI_TITLE, + "--name", MCPI_APP_TITLE, "--entry", "--only-numerical", "--text", "Enter Seed (Leave Blank For Random):", diff --git a/mods/src/version/version.cpp b/mods/src/version/version.cpp index ca310a1..4b2760c 100644 --- a/mods/src/version/version.cpp +++ b/mods/src/version/version.cpp @@ -9,7 +9,7 @@ char *version_get() { static char *version = NULL; // Load if (version == NULL) { - safe_asprintf(&version, "%s / Reborn v" VERSION, *minecraft_pi_version); + safe_asprintf(&version, "%s / Reborn v" MCPI_VERSION, *minecraft_pi_version); } // Return return version;