From 742ead51e133f1f4036ccd3603acff84ffc80d1f Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 9 Mar 2022 21:23:41 -0500 Subject: [PATCH] Vendor GLFW --- .gitignore | 1 + .gitmodules | 4 ++ CMakeLists.txt | 6 +-- Dockerfile | 1 - Dockerfile.build | 12 ++++++ Jenkinsfile | 4 +- dependencies/CMakeLists.txt | 14 +++++-- dependencies/glfw/CMakeLists.txt | 22 ++++++++++ dependencies/glfw/src | 1 + media-layer/core/CMakeLists.txt | 2 - scripts/ci/run.sh | 11 ----- scripts/ci/simulate.sh | 5 ++- scripts/generate-appimage-builder-yaml.js | 6 ++- scripts/install-dependencies.sh | 50 +++++++++++++++++------ scripts/package.sh | 3 ++ 15 files changed, 104 insertions(+), 38 deletions(-) create mode 100644 Dockerfile.build create mode 100644 dependencies/glfw/CMakeLists.txt create mode 160000 dependencies/glfw/src diff --git a/.gitignore b/.gitignore index bc57d619..cf0f95db 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ CMakeLists.txt.user AppImageBuilder.yml appimage-builder-cache AppDir +*.zsync diff --git a/.gitmodules b/.gitmodules index 82965c68..14e4370a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,7 @@ path = dependencies/zlib/src url = https://github.com/madler/zlib.git shallow = true +[submodule "dependencies/glfw/src"] + path = dependencies/glfw/src + url = https://github.com/glfw/glfw.git + shallow = true diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dec8934..c9a5fee1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,10 +74,8 @@ endif() # PIC set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) -# Buld LibPNG + ZLib + Download Minecraft: Pi Edition -if(BUILD_ARM_COMPONENTS) - add_subdirectory(dependencies) -endif() +# Buld Dependencies +add_subdirectory(dependencies) # Warnings add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference) diff --git a/Dockerfile b/Dockerfile index 12d5a5a5..9a0be196 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ RUN \ apt-get update && \ apt-get install -y tini sed && \ apt-get --fix-broken install -y && \ - rm -f /root/*.deb && \ rm -rf /var/lib/apt/lists/* # Copy AppImage diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 00000000..d1a0e68c --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,12 @@ +FROM buildpack-deps:bullseye + +# Setup +ENV ARM_PACKAGES_SUPPORTED=1 + +# Install +ADD ./scripts/install-dependencies.sh / +RUN \ + apt-get update && \ + apt-get install --no-install-recommends -y sudo && \ + /install-dependencies.sh && \ + rm -rf /var/lib/apt/lists/* diff --git a/Jenkinsfile b/Jenkinsfile index 4157a91e..21c52321 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stage('Debian Bullseye') { agent { docker { - image 'buildpack-deps:bullseye' + filename 'Dockerfile.build' args '-v /var/run/docker.sock:/var/run/docker.sock' } } @@ -15,7 +15,7 @@ pipeline { } post { success { - archiveArtifacts artifacts: 'out/*.deb', fingerprint: true + archiveArtifacts artifacts: 'out/*.AppImage*', fingerprint: true } } } diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index f9d1bc7c..764894ab 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -1,10 +1,18 @@ project(dependencies) # ZLib -add_subdirectory(zlib) +if(BUILD_ARM_COMPONENTS) + add_subdirectory(zlib) +endif() # LibPNG -add_subdirectory(libpng) +if(BUILD_ARM_COMPONENTS) + add_subdirectory(libpng) +endif() +# GLFW +if(BUILD_NATIVE_COMPONENTS) + add_subdirectory(glfw) +endif() # Minecraft: Pi Edition -if(NOT MCPI_OPEN_SOURCE_ONLY) +if(BUILD_ARM_COMPONENTS AND NOT MCPI_OPEN_SOURCE_ONLY) add_subdirectory(minecraft-pi) endif() diff --git a/dependencies/glfw/CMakeLists.txt b/dependencies/glfw/CMakeLists.txt new file mode 100644 index 00000000..6501429d --- /dev/null +++ b/dependencies/glfw/CMakeLists.txt @@ -0,0 +1,22 @@ +project(glfw) + +# Silence Warnings +add_compile_options(-w) + +## GLFW + +# Download +set(BUILD_SHARED_LIBS FALSE) +set(GLFW_BUILD_EXAMPLES FALSE) +set(GLFW_BUILD_TESTS FALSE) +set(GLFW_BUILD_DOCS FALSE) +set(GLFW_INSTALL FALSE) +set(GLFW_BUILD_WIN32 FALSE) +set(GLFW_BUILD_COCOA FALSE) +set(GLFW_BUILD_X11 TRUE) +set(GLFW_BUILD_WAYLAND TRUE) +set(GLFW_LIBRARY_TYPE "STATIC") +add_subdirectory(src EXCLUDE_FROM_ALL) + +# Ensure Build +add_custom_target(glfw-build ALL DEPENDS glfw) diff --git a/dependencies/glfw/src b/dependencies/glfw/src new file mode 160000 index 00000000..adc202d2 --- /dev/null +++ b/dependencies/glfw/src @@ -0,0 +1 @@ +Subproject commit adc202d2c3182ca6ad8344624941e56d8e0bc493 diff --git a/media-layer/core/CMakeLists.txt b/media-layer/core/CMakeLists.txt index bd2f4e74..31c7781b 100644 --- a/media-layer/core/CMakeLists.txt +++ b/media-layer/core/CMakeLists.txt @@ -22,8 +22,6 @@ if(TARGET media-layer-core) # Link target_link_libraries(media-layer-core media-layer-headers reborn-headers pthread dl) if(NOT MCPI_HEADLESS_MODE) - # Find GLFW - find_package(glfw3 3.3 REQUIRED) # Find FreeImage find_library(FREEIMAGE_LIBRARY NAMES freeimage libfreeimage.so.3 REQUIRED) # OpenAL diff --git a/scripts/ci/run.sh b/scripts/ci/run.sh index 37dba8cc..3aa84279 100755 --- a/scripts/ci/run.sh +++ b/scripts/ci/run.sh @@ -2,17 +2,6 @@ set -e -# Install sudo -apt-get update -apt-get install -y sudo - -# Prepare -export ARM_PACKAGES_SUPPORTED=1 - -# Install Dependencies -echo '==== Installing Dependencies ====' -./scripts/install-dependencies.sh - # Build/Package echo '==== Building & Packaging ====' ./scripts/package-all.sh diff --git a/scripts/ci/simulate.sh b/scripts/ci/simulate.sh index fddd7214..0250b212 100755 --- a/scripts/ci/simulate.sh +++ b/scripts/ci/simulate.sh @@ -2,5 +2,8 @@ set -e +# Build Docker Image +docker build -f Dockerfile.build -t minecraft-pi-reborn-build . + # Run -docker run --rm -v "$(pwd):/data" buildpack-deps:bullseye sh -c "cd /data; ./scripts/ci/run.sh" +docker run --rm -v "$(pwd):/data" -w '/data' -u '1000:1000' minecraft-pi-reborn-build ./scripts/ci/run.sh diff --git a/scripts/generate-appimage-builder-yaml.js b/scripts/generate-appimage-builder-yaml.js index d8571322..9c47928f 100755 --- a/scripts/generate-appimage-builder-yaml.js +++ b/scripts/generate-appimage-builder-yaml.js @@ -10,6 +10,7 @@ const arch = process.argv[3]; // Data const id = `com.thebrokenrail.MCPIReborn${mode === 'server' ? 'Server' : ''}`; 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 = 'bullseye'; @@ -26,10 +27,10 @@ const packages = [ 'libstdc++6' ]; if (mode === 'client') { + // GLFW's Dependencies Aren't Included As They Should Be Provided By The Host System packages.push( 'zenity', 'libcanberra-gtk3-module', - 'libglfw3', 'libfreeimage3', 'libopenal1' ); @@ -170,7 +171,8 @@ if (!appImageArch) { } const appImage = { arch: appImageArch, - file_name: `./out/${name}-${version}-${arch}.AppImage` + file_name: `./out/${name}-${version}-${arch}.AppImage`, + 'update-information': `zsync|${updateURL}` }; // Root diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index ddefd441..83e63038 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -24,29 +24,54 @@ queue_pkg() { PKG_QUEUE="${PKG_QUEUE} $@" } -# Install +# Build Tools queue_pkg \ git \ cmake \ ninja-build \ - libglfw3 libglfw3-dev \ - libfreeimage3 libfreeimage-dev \ crossbuild-essential-armhf \ gcc g++ \ - nodejs \ + nodejs + +# Dependencies +queue_pkg \ + libfreeimage3 libfreeimage-dev \ libopenal-dev \ qemu-user -# Install ARM Dependencies +# GLFW Dependencies +queue_pkg \ + libwayland-dev \ + libxkbcommon-dev \ + wayland-protocols \ + libx11-dev \ + libxcursor-dev \ + libxi-dev \ + libxinerama-dev \ + libxrandr-dev \ + libxext-dev + +# ARM Packages if [ ! -z "${ARM_PACKAGES_SUPPORTED}" ]; then + # Build Tools queue_pkg \ - libglfw3:armhf libglfw3-dev:armhf \ - libfreeimage3:armhf \ - libopenal-dev:armhf \ - libglfw3:arm64 libglfw3-dev:arm64 \ - libfreeimage3:arm64 \ - libopenal-dev:arm64 \ crossbuild-essential-arm64 + + # Dependencies + queue_pkg \ + libfreeimage3:armhf libfreeimage3:arm64 \ + libopenal-dev:armhf libopenal-dev:arm64 + + # GLFW Dependencies + queue_pkg \ + libwayland-dev:armhf libwayland-dev:arm64 \ + libxkbcommon-dev:armhf libxkbcommon-dev:arm64 \ + libx11-dev:armhf libx11-dev:arm64 \ + libxcursor-dev:armhf libxcursor-dev:arm64 \ + libxi-dev:armhf libxi-dev:arm64 \ + libxinerama-dev:armhf libxinerama-dev:arm64 \ + libxrandr-dev:armhf libxrandr-dev:arm64 \ + libxext-dev:armhf libxext-dev:arm64 fi # Install appimagetool Dependencies @@ -68,8 +93,9 @@ sudo apt-get install --no-install-recommends -y ${PKG_QUEUE} sudo mkdir -p /opt sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /opt/appimagetool # Workaround AppImage Issues With Docker -cd /opt; sudo chmod +x ./appimagetool; sed -i '0,/AI\x02/{s|AI\x02|\x00\x00\x00|}' ./appimagetool; sudo ./appimagetool --appimage-extract +cd /opt; sudo chmod +x ./appimagetool; sudo sed -i '0,/AI\x02/{s|AI\x02|\x00\x00\x00|}' ./appimagetool; sudo ./appimagetool --appimage-extract sudo mv /opt/squashfs-root /opt/appimagetool.AppDir +sudo rm -f /usr/local/bin/appimagetool sudo ln -s /opt/appimagetool.AppDir/AppRun /usr/local/bin/appimagetool # Install appimage-builder diff --git a/scripts/package.sh b/scripts/package.sh index dc2c9a26..15ebbb2d 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -7,3 +7,6 @@ set -e # Build/Package appimage-builder --recipe AppImageBuilder.yml + +# Move ZSync +mv "./minecraft-pi-reborn-$1-$(cat VERSION)-$2.AppImage.zsync" "./out/minecraft-pi-reborn-$1-latest-$2.AppImage.zsync"