From 30b14612944a996e210690e712bdfc1049e846b8 Mon Sep 17 00:00:00 2001 From: Mew Pur Pur <85438892+MewPurPur@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:31:39 +0300 Subject: [PATCH] Oh this is SO pissing me off (#783) --- .github/workflows/dev-desktop.yml | 8 ++ .github/workflows/export-optimized.yml | 138 +++++++++---------------- EXPORT_WORKFLOW.md | 81 ++++++++++++--- 3 files changed, 125 insertions(+), 102 deletions(-) diff --git a/.github/workflows/dev-desktop.yml b/.github/workflows/dev-desktop.yml index ec38f938..ea451803 100644 --- a/.github/workflows/dev-desktop.yml +++ b/.github/workflows/dev-desktop.yml @@ -22,8 +22,10 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + - name: Set up Godot uses: ./.github/actions/set-up-godot + - name: Set up WINE and rcedit for Windows export run: | # Download rcedit and install wine. @@ -40,8 +42,10 @@ jobs: # Add wine and rcedit paths to Godot config. echo 'export/windows/wine = "/usr/bin/wine64"' >> ~/.config/godot/editor_settings-4.tres echo 'export/windows/rcedit = "/home/runner/.local/share/rcedit/rcedit-x64.exe"' >> ~/.config/godot/editor_settings-4.tres + - name: Export project uses: ./.github/actions/godot-export + - name: Upload Artifact uses: actions/upload-artifact@v4 with: @@ -60,16 +64,20 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + - name: Set up Godot uses: ./.github/actions/set-up-godot + - name: Export project uses: ./.github/actions/godot-export + - name: Make Linux export runnable run: | # Set run permission. chmod +x ~/build/${BUILD_NAME}/${PROJECT_NAME}.x86_64 cd ~/build tar zcvf ${BUILD_NAME}.tar.gz ${BUILD_NAME} + - name: Upload Artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/export-optimized.yml b/.github/workflows/export-optimized.yml index 07eb73ab..948a7dd3 100644 --- a/.github/workflows/export-optimized.yml +++ b/.github/workflows/export-optimized.yml @@ -4,15 +4,20 @@ on: workflow_dispatch: env: + GODOT_VERSION: 4.2.2 + PROJECT_NAME: GodSVG GODOT_REPO: https://github.com/godotengine/godot.git - GODOT_DIR: godot - BUILD_DIR: build GODOT_COMMIT_HASH: 15073af - BUILD_OPTIONS: "target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes" + BUILD_OPTIONS: target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes jobs: build-linux: + name: Export GodSVG for Linux runs-on: ubuntu-latest + env: + PLATFORM: "Linux/X11" + EXTENSION: "exe" + BUILD_NAME: "linux-64bit" steps: - name: Checkout repository uses: actions/checkout@v3 @@ -21,105 +26,64 @@ jobs: run: sudo apt install -y scons python3 - name: Clone Godot repository - run: git clone $GODOT_REPO $GODOT_DIR + run: git clone $GODOT_REPO godot - name: Checkout specific commit run: | - cd $GODOT_DIR + cd godot git fetch git checkout $GODOT_COMMIT_HASH - name: Build Godot template for Linux run: | - cd $GODOT_DIR - scons p=linuxbsd arch=x86_64 optimize=speed $BUILD_OPTIONS - mkdir -p ../$BUILD_DIR - cp bin/godot.linuxbsd.*.x86_64 ../$BUILD_DIR/godot_template_linux + cd godot + scons p=linuxbsd arch=x86_64 optimize=speed ${BUILD_OPTIONS} - - name: Lmofa - run: ls $BUILD_DIR - - - name: Upload Linux template - uses: actions/upload-artifact@v3 + - name: Upload artifact + uses: actions/upload-artifact@v4 with: - name: godot_template_linux - path: $BUILD_DIR/godot_template_linux + name: godot_template_linux.x86_64 + path: godot/bin/godot.linuxbsd.template_release.x86_64 + if-no-files-found: error retention-days: 1 build-windows: - runs-on: windows-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install dependencies - run: choco install scons - - - name: Clone Godot repository - run: git clone $GODOT_REPO $GODOT_DIR - - - name: Checkout specific commit - run: | - cd $GODOT_DIR - git fetch - git checkout $GODOT_COMMIT_HASH - - - name: Build Godot template for Windows - run: | - cd $GODOT_DIR - scons p=windows arch=x86_64 optimize=speed $BUILD_OPTIONS - cp bin/godot.windows.*.64 ../$BUILD_DIR/godot_template_windows - - - name: Upload Windows template - uses: actions/upload-artifact@v3 - with: - name: godot_template_windows - path: $BUILD_DIR/godot_template_windows - retention-days: 1 - - build-web: + name: Export GodSVG for Windows runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Install dependencies - run: sudo apt-get install -y scons python3 - - - name: Install Emscripten run: | - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install latest - ./emsdk activate latest - source ./emsdk_env.sh - shell: bash + sudo apt install -y scons python3 + sudo apt install -y g++-mingw-w64-x86-64-posix - name: Clone Godot repository - run: git clone $GODOT_REPO $GODOT_DIR + run: git clone $GODOT_REPO godot - name: Checkout specific commit run: | - cd $GODOT_DIR + cd godot git fetch git checkout $GODOT_COMMIT_HASH - - name: Build Godot template for Web + - name: Build Godot template for Windows run: | - cd $GODOT_DIR - source ../emsdk/emsdk_env.sh - scons p=web arch=wasm32 javascript_eval=no optimize=size $BUILD_OPTIONS - mkdir -p ../$BUILD_DIR/godot_template_web - cp bin/godot.javascript.opt.* ../$BUILD_DIR/godot_template_web + apt search mingw + cd godot + scons p=windows target=release_debug tools=no ${BUILD_OPTIONS} - - name: Upload Web template - uses: actions/upload-artifact@v3 + - name: Upload artifact + uses: actions/upload-artifact@v4 with: - name: godot_template_web - path: $BUILD_DIR/godot_template_web + name: godot_template_windows.exe + path: godot/bin/godot.windows.template_release.x86_64.exe + if-no-files-found: error retention-days: 1 build-macos: + name: Export GodSVG for MacOS runs-on: macos-latest steps: - name: Checkout repository @@ -129,48 +93,44 @@ jobs: run: brew install scons - name: Clone Godot repository - run: git clone $GODOT_REPO $GODOT_DIR + run: git clone $GODOT_REPO godot - name: Checkout specific commit run: | - cd $GODOT_DIR + cd godot git fetch git checkout $GODOT_COMMIT_HASH - name: Build Godot template for macOS (arm64 release) run: | - cd $GODOT_DIR - scons p=macos arch=arm64 optimize=speed $BUILD_OPTIONS - mkdir -p ../$BUILD_DIR - cp bin/godot.macos.template_release.arm64 ../$BUILD_DIR/godot_template_macos_release_arm64 + cd godot + scons p=macos arch=arm64 optimize=speed ${BUILD_OPTIONS} - name: Build Godot template for macOS (x86_64 release) run: | - cd $GODOT_DIR - scons p=macos arch=x86_64 optimize=speed $BUILD_OPTIONS - cp bin/godot.macos.template_release.x86_64 ../$BUILD_DIR/godot_template_macos_release_x86_64 + cd godot + scons p=macos arch=x86_64 optimize=speed ${BUILD_OPTIONS} - name: Combine binaries with lipo run: | - cd $BUILD_DIR - lipo -create godot.macos.template_release.arm64 godot.macos.template_release.x86_64 -output godot_template_macos_release_universal - chmod +x godot_template_macos_* + cd godot/bin + lipo -create godot.macos.template_release.x86_64 godot.macos.template_release.arm64 -output godot.macos.template_release.universal + chmod +x * - name: Prepare .app bundle run: | - cp -R ~/workspace/misc/dist/macos_template.app . + cd godot/bin + cp -R ../misc/dist/macos_template.app . mkdir -p macos_template.app/Contents/MacOS - cp godot_template_macos_debug_universal macos_template.app/Contents/MacOS/godot_macos_debug.universal - cp godot_template_macos_release_universal macos_template.app/Contents/MacOS/godot_macos_release.universal - chmod +x macos_template.app/Contents/MacOS/godot_macos* - - - name: Zip the .app bundle - run: zip -q -9 -r macos.zip macos_template.app + cp godot.macos.template_release.universal macos_template.app/Contents/MacOS/godot_macos_release.universal; + chmod +x macos_template.app/Contents/MacOS/godot_macos*; + zip -q -9 -r godot_template_macos.zip macos_template.app; - name: Upload macOS template uses: actions/upload-artifact@v3 with: - name: godot_template_macos - path: macos.zip + name: godot_template_macos.zip + path: godot/bin/godot_template_macos.zip + if-no-files-found: error retention-days: 1 diff --git a/EXPORT_WORKFLOW.md b/EXPORT_WORKFLOW.md index 97906a14..b77b2c16 100644 --- a/EXPORT_WORKFLOW.md +++ b/EXPORT_WORKFLOW.md @@ -1,12 +1,76 @@ -This is a tutorial on exporting with a custom template, which makes the executable smaller by removing unused features. It might be a bad way of doing things. I can only hope the open-sourcedness of the project will help polish up the workflow eventually. +This is a tutorial on exporting with a custom template, which makes the executable smaller by removing unused features. -## Initial setup +## Getting the export templates -This will be needed the first time. +- Go to the "Actions" tab on Github, find the "export-optimized" workflow, and run it. +- Get all of the export templates that are generated. +- Wait for it to finish. +- Open the workflow file and find the artifact. + +## Getting the export templates for Web + +I couldn't get Github actions to generate the web template, unfortunately. So the optimized export template has to be compiled manually. + +
+ +Here's how far I got: + +```yaml + build-web: + name: Export GodSVG for Web + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install dependencies + run: sudo apt-get install -y scons python3 + + - name: Install Emscripten + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install latest + ./emsdk activate latest + source ./emsdk_env.sh + shell: bash + + - name: Clone Godot repository + run: git clone $GODOT_REPO godot + + - name: Checkout specific commit + run: | + cd godot + git fetch + git checkout $GODOT_COMMIT_HASH + + - name: Build Godot template for Web + run: | + cd godot + source ../emsdk/emsdk_env.sh + scons p=web arch=wasm32 optimize=size lto=auto ${BUILD_OPTIONS} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: godot_template_web.zip + path: godot/bin/godot.web.template_release.wasm32.zip + if-no-files-found: error + retention-days: 1 +``` + +
- Clone or fork the Godot repository: https://github.com/godotengine/godot +- While in a CLI, go in the root folder of the Godot source code. - Set up scons. -- For each platform you want to export for, read the documentation on how to set up scons for it. For example, https://docs.godotengine.org/en/latest/contributing/development/compiling/compiling_for_windows.html#cross-compiling-for-windows-from-other-operating-systems explains how to setup the windows platform from Linux. Use `scons p=list` to check if the platform is set up. +- Sync the local repo. For a minor version, fetching its branch might be necessary, i.e. `git fetch upstream 4.2` +- Find the commit hash of the Godot version GodSVG is using: https://github.com/godotengine/godot/releases +- `git checkout ` +- Read the documentation on how to set up scons for web: https://docs.godotengine.org/en/latest/contributing/development/compiling/compiling_for_web.html +- Use `scons p=list` to check if the web platform is set up. +- `scons p=web arch=wasm32 target=template_release lto=full production=yes dev_build=no optimize=size deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes` +- Wait for it to finish. The template will be in the bin directory, but avoid moving it inside the GodSVG project. ## Exporting @@ -15,20 +79,11 @@ This will be needed the first time. - Find the commit hash of the Godot version GodSVG is using: https://github.com/godotengine/godot/releases - `git checkout ` - Run the scons command; see below. -- Wait for the compilation to finish. The template will be in the bin directory, but avoid moving it inside the GodSVG project. For most platforms, to export, you'd need to find the relevant template in your file system to fill in the Custom Template field, then use "Export Project". For official web exports, after this is done, you'll get a lot of files. Normally, only `GodSVG.pck` and `GodSVG.wasm` need to be changed between builds. -## Commands - -- `scons p=linuxbsd arch=x86_64 target=template_release optimize=speed lto=full deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes` - -- `scons p=windows arch=x86_64 target=template_release optimize=speed lto=full deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes` - -- `scons p=web arch=wasm32 javascript_eval=no target=template_release lto=full production=yes dev_build=no optimize=size deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes` - ## Misc: `scons --help` on the godot source lists its modules.