Fix Build On Ubuntu 22.04 & Bug Fixes
All checks were successful
minecraft-pi-reborn/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2022-05-11 18:24:03 -04:00
parent 524a390921
commit b59c580f6a
15 changed files with 105 additions and 32 deletions

View File

@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.13.0)
# Specify Options
option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE)
if(MCPI_IS_MIXED_BUILD)
option(MCPI_BUNDLE_ARMHF_SYSROOT "Whether To Include An ARMHF Sysroot" TRUE)
endif()
option(MCPI_SERVER_MODE "Server Mode" FALSE)
option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE})
if(NOT MCPI_HEADLESS_MODE)
@ -55,6 +58,11 @@ endif()
# Start Project
project(minecraft-pi-reborn)
# Sanity Check
if(BUILD_NATIVE_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT MCPI_IS_MIXED_BUILD)
message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
endif()
# Require ARM Compilation
if(USE_ARM32_TOOLCHAIN AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
message(FATAL_ERROR "ARM-Targeting Compiler Required")
@ -88,6 +96,10 @@ add_subdirectory(dependencies)
# Warnings
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0)
# Prevents False Positives
add_compile_options(-Wno-stringop-overflow)
endif()
add_link_options(-Wl,--no-undefined)
add_definitions(-D_GNU_SOURCE)
set(CMAKE_C_STANDARD 99)
@ -103,6 +115,9 @@ 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()
# Version
set_property(

View File

@ -21,6 +21,6 @@ if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_HEADLESS_MODE)
add_subdirectory(zenity)
endif()
# Sysroot
if(BUILD_ARM_COMPONENTS AND MCPI_IS_MIXED_BUILD)
if(BUILD_ARM_COMPONENTS AND MCPI_BUNDLE_ARMHF_SYSROOT)
add_subdirectory(armhf-sysroot)
endif()

View File

@ -9,20 +9,10 @@ else()
# Download From APT
set(APT_PACKAGES "libc6" "libstdc++6")
# Reconfigure CMake If APT Data Is Changed
file(GLOB_RECURSE APT_FILES "apt/*")
foreach(APT_FILE IN LISTS APT_FILES)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS "${APT_FILE}"
)
endforeach()
# Copy To Binary Directory
set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt-build")
set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt")
file(REMOVE_RECURSE "${APT_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/apt/." DESTINATION "${APT_DIR}")
file(MAKE_DIRECTORY "${APT_DIR}")
# Make Directories
file(MAKE_DIRECTORY "${APT_DIR}/apt.conf.d")
file(MAKE_DIRECTORY "${APT_DIR}/preferences.d")
@ -30,6 +20,18 @@ else()
file(MAKE_DIRECTORY "${APT_DIR}/dpkg")
file(TOUCH "${APT_DIR}/dpkg/status")
# Create APT Sources
execute_process(
COMMAND "${CMAKE_SOURCE_DIR}/scripts/tools/get-apt-sources.sh"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE APT_SOURCES
RESULT_VARIABLE APT_SOURCES_RESULT
)
if(NOT APT_SOURCES_RESULT EQUAL 0)
message(FATAL_ERROR "Unable To Get APT Sources For ARMHF Sysroot")
endif()
file(WRITE "${APT_DIR}/sources.list" "${APT_SOURCES}")
# Create APT Config
string(CONCAT APT_CONFIG
"Dir \"${APT_DIR}\";\n"

View File

@ -1 +0,0 @@
deb https://deb.debian.org/debian/ sid main

@ -1 +1 @@
Subproject commit 7dfd84c458dfa12b351c932b8281b13faf7b50b9
Subproject commit 62e175ef9fae75335575964c845a302447c012c7

View File

@ -29,7 +29,7 @@ TRUE Close Current Screen On Death
FALSE Disable Raw Mouse Motion (Not Recommended)
TRUE Fix Furnace Not Checking Item Auxiliary
TRUE Improved Cursor Rendering
FALSE Disable V-Sync
TRUE Disable V-Sync
TRUE Fix Options Screen
TRUE Force Touch GUI Inventory
TRUE Fix Pause Menu

View File

@ -227,7 +227,7 @@ void bootstrap(int argc, char *argv[]) {
// Find Linker
char *linker = NULL;
// Select Linker
#ifndef __arm__
#ifdef MCPI_BUNDLE_ARMHF_SYSROOT
// Use ARM Sysroot Linker
safe_asprintf(&linker, "%s/sysroot/lib/ld-linux-armhf.so.3", binary_directory);
#else
@ -264,9 +264,9 @@ void bootstrap(int argc, char *argv[]) {
// Add Library Directory
safe_asprintf(&new_ld_path, "%s/lib", binary_directory);
// Add ARM Sysroot Libraries (Ensure Priority) (Ignroe On Actual ARM System)
#ifndef __arm__
string_append(&new_ld_path, ":%s/sysroot/lib/arm-linux-gnueabihf:%s/sysroot/usr/lib/arm-linux-gnueabihf", binary_directory, binary_directory);
// Add ARM Sysroot Libraries (Ensure Priority) (Ignore On Actual ARM System)
#ifdef MCPI_BUNDLE_ARMHF_SYSROOT
string_append(&new_ld_path, ":%s/sysroot/lib:%s/sysroot/lib/arm-linux-gnueabihf:%s/sysroot/usr/lib:%s/sysroot/usr/lib/arm-linux-gnueabihf", binary_directory, binary_directory, binary_directory, binary_directory);
#endif
// Add LD_LIBRARY_PATH

View File

@ -192,6 +192,8 @@ static void GameRenderer_render_injection(unsigned char *game_renderer, float pa
// Check If Cursor Should Render
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
// Fix GL Mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Get X And Y
float x = (*Mouse_getX)() * (*InvGuiScale);
float y = (*Mouse_getY)() * (*InvGuiScale);

View File

@ -51,8 +51,10 @@ static void Options_initDefaultValue_injection(unsigned char *options) {
(*Options_initDefaultValue)(options);
// Default Graphics Settings
#ifndef MCPI_SERVER_MODE
*(options + Options_fancy_graphics_property_offset) = 1;
*(options + Options_ambient_occlusion_property_offset) = 1;
#endif
// Store
stored_options = options;

View File

@ -91,7 +91,7 @@ static char *get_new_options_txt_path() {
#endif
// Modify Option Toggles
static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char *options_pane, unsigned char *unknown_object, std::string const& name, unsigned char *option) {
static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char *options_pane, uint32_t group_id, std::string const& name, unsigned char *option) {
// Modify
std::string new_name = name;
if (name == "Fancy Graphics") {
@ -116,7 +116,7 @@ static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char
}
// Call Original Method
(*OptionsPane_unknown_toggle_creating_function)(options_pane, unknown_object, new_name, option);
(*OptionsPane_unknown_toggle_creating_function)(options_pane, group_id, new_name, option);
}
// Add Missing Options To Options::getBooleanValue

View File

@ -54,6 +54,7 @@ static ServerProperties &get_server_properties() {
#define DEFAULT_PORT "19132"
#define DEFAULT_SEED ""
#define DEFAULT_FORCE_MOB_SPAWNING "false"
#define DEFAULT_PEACEFUL_MODE "false"
#define DEFAULT_WORLD_NAME "world"
#define DEFAULT_MAX_PLAYERS "4"
#define DEFAULT_WHITELIST "false"
@ -72,6 +73,10 @@ static void start_world(unsigned char *minecraft) {
// Log
INFO("Loading World: %s", world_name.c_str());
// Peaceful Mode
unsigned char *options = minecraft + Minecraft_options_property_offset;
*(int32_t *) (options + Options_game_difficulty_property_offset) = get_server_properties().get_bool("peaceful-mode", DEFAULT_PEACEFUL_MODE) ? 0 : 2;
// Specify Level Settings
LevelSettings settings;
settings.game_type = get_server_properties().get_int("game-mode", DEFAULT_GAME_MODE);
@ -461,6 +466,8 @@ static void server_init() {
properties_file_output << "seed=" DEFAULT_SEED "\n";
properties_file_output << "# Force Mob Spawning (false = Disabled, true = Enabled)\n";
properties_file_output << "force-mob-spawning=" DEFAULT_FORCE_MOB_SPAWNING "\n";
properties_file_output << "# Peaceful Mode (false = Disabled, true = Enabled)\n";
properties_file_output << "peaceful-mode=" DEFAULT_PEACEFUL_MODE "\n";
properties_file_output << "# World To Select\n";
properties_file_output << "world-name=" DEFAULT_WORLD_NAME "\n";
properties_file_output << "# Maximum Player Count\n";

View File

@ -3,7 +3,7 @@
set -e
# Generate
./scripts/generate-appimage-builder-yaml.js "$1" "$2"
./scripts/tools/generate-appimage-builder-yaml.js "$1" "$2"
# Build/Package
appimage-builder --recipe AppImageBuilder.yml

View File

@ -1,5 +1,8 @@
#!/usr/bin/env node
// Child Process
const child_process = require('child_process');
// Arguments
if (process.argv.length < 4) {
throw new Error('Invalid Arguments');
@ -12,8 +15,12 @@ const id = `com.thebrokenrail.MCPIReborn${mode === 'server' ? 'Server' : 'Client
const name = `minecraft-pi-reborn-${mode}`;
const updateURL = `https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/${name}-latest-${arch}.AppImage.zsync`;
// APT Data
const apt_distribution = 'sid';
// APT Sources
const apt_sources = child_process.execFileSync('./scripts/tools/get-apt-sources.sh', [], {encoding: 'utf-8'}).trim().split('\n');
const apt_sources_formatted = [];
for (const apt_source of apt_sources) {
apt_sources_formatted.push({sourceline: apt_source});
}
// Version
const fs = require('fs');
@ -58,11 +65,7 @@ const packageExclusions = [
// APT
const apt = {
arch: arch,
sources: [
{
sourceline: `deb [arch=${arch}] https://deb.debian.org/debian/ ${apt_distribution} main`
}
],
sources: apt_sources_formatted,
allow_unauthenticated: true,
include: packages,
exclude: packageExclusions
@ -113,7 +116,7 @@ const runtime = {
GTK_PATH: `\${APPDIR}/usr/lib/${triplet}/gtk-3.0`,
GTK_DATA_PREFIX: '${APPDIR}',
GTK_THEME: 'Default',
XDG_DATA_DIRS: '${APPDIR}/share:${APPDIR}/usr/share',
XDG_DATA_DIRS: '${APPDIR}/share:${APPDIR}/usr/share:/share:/usr/share',
APPDIR_LIBRARY_PATH: `\${APPDIR}/usr/lib/${triplet}:\${APPDIR}/usr/${triplet}/lib:\${APPDIR}/lib/${triplet}:\${APPDIR}/usr/lib:\${APPDIR}/usr/lib/${triplet}/gdk-pixbuf-2.0/2.10.0/loaders`,
APPDIR_MODULE_DIR: '/tmp/.minecraft-pi-tmp'
} : undefined,

View File

@ -0,0 +1,43 @@
#!/bin/sh
set -e
if [ ! -z "${MCPI_CUSTOM_APT_REPO}" ]; then
echo "${MCPI_CUSTOM_APT_REPO}"
exit 0
fi
ID="$(sed -n -e 's/^ID=//p' /etc/os-release)"
ID_LIKE="$(sed -n -e 's/^ID_LIKE=//p' /etc/os-release)"
VERSION_CODENAME="$(sed -n -e 's/^VERSION_CODENAME=//p' /etc/os-release)"
OUT=""
get_apt_sources() {
if [ "${1}" = "ubuntu" ]; then
OUT="deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME} main restricted
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME}-updates main restricted
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME} universe
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME}-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME} main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME}-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME} universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME}-updates universe"
elif [ "${1}" = "debian" ]; then
OUT="deb https://deb.debian.org/debian/ ${VERSION_CODENAME} main"
if [ "${VERSION_CODENAME}" != "sid" ] && [ "${VERSION_CODENAME}" != "unstable" ] && [ "${VERSION_CODENAME}" != "experimental" ]; then
OUT="${OUT}
deb https://deb.debian.org/debian/ ${VERSION_CODENAME}-updates main"
fi
fi
}
get_apt_sources "${ID}"
if [ -z "${OUT}" ]; then
get_apt_sources "${ID_LIKE}"
fi
if [ ! -z "${OUT}" ]; then
echo "${OUT}"
else
echo "Unsupported Distribution: ${ID}" 1>&2
exit 1
fi

View File

@ -835,7 +835,7 @@ static uint32_t OptionsFile_options_txt_path_property_offset = 0x0; // std::stri
// OptionsPane
typedef void (*OptionsPane_unknown_toggle_creating_function_t)(unsigned char *options_pane, unsigned char *unknown_object, std::string const& name, unsigned char *option);
typedef void (*OptionsPane_unknown_toggle_creating_function_t)(unsigned char *options_pane, uint32_t group_id, std::string const& name, unsigned char *option);
static OptionsPane_unknown_toggle_creating_function_t OptionsPane_unknown_toggle_creating_function = (OptionsPane_unknown_toggle_creating_function_t) 0x24470;
// Textures