From 5f7dc2c2472c39553cd11fe3bf50704d5b662038 Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Mon, 1 Aug 2022 19:56:43 +1200 Subject: [PATCH] Use default export templates for HTML5 Changes Emscripten SDK version to match that used to compile the default export templates used by Godot 3.4 (in this case 2.0.25 as can be seen here: https://github.com/godotengine/build-containers/blob/3.4/Dockerfile.javascript). This means we no longer need to compile custom export templates when exporting HTML5 for Godot 3.4. Exports from other Godot versions may requiring compiling the GDNative library with a different version of the Emscripten SDK. --- .github/import_assets.tscn | 21 ++++++ .github/workflows/main.yml | 74 ++++++------------- .gitmodules | 3 - addons/godot_xterm/native/build.sh | 2 +- addons/godot_xterm/native/docker-compose.yaml | 4 +- .../godot_xterm/native/javascript.Dockerfile | 2 +- addons/godot_xterm/native/linux.Dockerfile | 2 +- addons/godot_xterm/native/src/terminal.cpp | 2 +- .../godot_xterm/native/thirdparty/godot-cpp | 2 +- docs/demo/.gitkeep | 0 export_presets.cfg | 4 +- misc/export_templates/build.sh | 41 ---------- misc/export_templates/docker-compose.yaml | 12 --- misc/export_templates/godot | 1 - misc/export_templates/readme.txt | 1 - 15 files changed, 52 insertions(+), 119 deletions(-) create mode 100644 .github/import_assets.tscn rename misc/docker/Dockerfile => addons/godot_xterm/native/javascript.Dockerfile (86%) create mode 100644 docs/demo/.gitkeep delete mode 100755 misc/export_templates/build.sh delete mode 100644 misc/export_templates/docker-compose.yaml delete mode 160000 misc/export_templates/godot delete mode 100644 misc/export_templates/readme.txt diff --git a/.github/import_assets.tscn b/.github/import_assets.tscn new file mode 100644 index 0000000..761ab2b --- /dev/null +++ b/.github/import_assets.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=2 format=2] + +[sub_resource type="GDScript" id=1] +script/source = "tool +extends Timer + +func _enter_tree(): + start() + +func _on_timeout(): + get_tree().quit(0) +" + +[node name="Timer" type="Timer"] +process_mode = 0 +wait_time = 10.0 +one_shot = true +autostart = true +script = SubResource( 1 ) + +[connection signal="timeout" from="." to="." method="_on_timeout"] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51bc704..a4eea62 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,10 @@ jobs: - name: Build godot-cpp bindings if: steps.cache-submodules.outputs.cache-hit != 'true' working-directory: addons/godot_xterm/native - run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} godot-cpp-linux + run: | + docker-compose build godot-cpp-linux + UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} godot-cpp-linux + - name: Build libuv if: steps.cache-submodules.outputs.cache-hit != 'true' working-directory: addons/godot_xterm/native @@ -100,7 +103,7 @@ jobs: if: ${{ matrix.platform == 'javascript' }} uses: mymindstorm/setup-emsdk@v11 with: - version: 3.1.5 + version: 2.0.25 actions-cache-folder: emsdk-cache-${{ matrix.target }} - name: Install additional javascript build dependencies if: ${{ matrix.platform == 'javascript' }} @@ -166,43 +169,9 @@ jobs: addons/godot_xterm/native/bin/*.dylib addons/godot_xterm/native/bin/*.dll - # GDNative HTML5 export templates aren't provided so we must build them - export_template: - name: 'Export Template' - runs-on: ubuntu-latest - strategy: - matrix: - target: [ release, debug ] - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Get godot submodule commit hash - shell: bash - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - echo ::set-env name=GODOT_COMMIT_HASH::$(git ls-tree HEAD misc/export_templates/godot -l | cut -d\ -f3) - - name: Cache export template - uses: actions/cache@v2 - id: cache-export-template - env: - cache-name: cache-export-template - with: - path: misc/export_templates/godot/bin - key: godot-${{ env.GODOT_COMMIT_HASH }}-${{ matrix.target }}-v${{ env.EXPORT_TEMPLATE_CACHE_VERSION }} - - name: Build template in docker container - if: steps.cache-export-template.outputs.cache-hit != 'true' - run: cd misc/export_templates && ./build.sh -t ${{ matrix.target }} - - name: Upload export template - uses: actions/upload-artifact@v2 - with: - name: html5-gdnative-export-templates - path: misc/export_templates/godot/bin/webassembly_gdnative_${{matrix.target}}.zip - html5_export: name: 'HTML5 Export' - needs: [ build_docker, build_native, export_template ] + needs: [ build_docker, build_native ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -210,28 +179,27 @@ jobs: submodules: recursive - name: Setup Godot uses: lihop/setup-godot@v1.0.1 + with: + export-templates: true - name: Install binary build artifacts uses: actions/download-artifact@v2 with: name: libgodot-xterm-release path: addons/godot_xterm/native/bin - - name: Install html5 export templates - uses: actions/download-artifact@v2 - with: - name: html5-gdnative-export-templates - path: misc/export_templates/godot/bin - - name: Create export directory - run: mkdir -p docs/demo + - name: Import assets + shell: bash + # The GodotXterm plugin will be disabled the first time we run the editor as resources that it depends + # (e.g. icons) will not have been imported yet so the plugin will fail to load. Without the plugin + # enabled resources imported by GodotXterm import plugins (e.g. .cast) will not be imported. Therefore, + # we need to re-enable the plugin by checking out project.godot and running the editor again. + run: godot --editor .github/import_assets.tscn && git checkout project.godot && godot --editor .github/import_assets.tscn - name: Export html5 - run: godot --export HTML5 - # FIXME: HTML5 Exports not properly exporting .cast files. - # So skip upload for now. - #- name: Upload export - # uses: actions/upload-artifact@v2 - # with: - # name: html5-demo - # path: docs/demo - + run: godot --no-window --export HTML5 + - name: Upload export + uses: actions/upload-artifact@v2 + with: + name: html5-demo + path: docs/demo test: name: 'Test' diff --git a/.gitmodules b/.gitmodules index 0942606..0d3c193 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,6 +10,3 @@ [submodule "addons/godot_xterm/native/thirdparty/libtsm"] path = addons/godot_xterm/native/thirdparty/libtsm url = https://github.com/lihop/libtsm -[submodule "misc/export_templates/godot"] - path = misc/export_templates/godot - url = https://github.com/godotengine/godot diff --git a/addons/godot_xterm/native/build.sh b/addons/godot_xterm/native/build.sh index d0a0659..5875e07 100755 --- a/addons/godot_xterm/native/build.sh +++ b/addons/godot_xterm/native/build.sh @@ -82,5 +82,5 @@ scons target=$target macos_arch=$(uname -m) disable_pty=$disable_pty -j$nproc # Use Docker to build libgodot-xterm javascript. if [ -x "$(command -v docker-compose)" ]; then UID_GID="0:0" TARGET=$target docker-compose build javascript - UID_GID="$(id -u):$(id -g)" TARGET=$target docker-compose run javascript + UID_GID="$(id -u):$(id -g)" TARGET=$target docker-compose run --rm javascript fi diff --git a/addons/godot_xterm/native/docker-compose.yaml b/addons/godot_xterm/native/docker-compose.yaml index 54f859d..9143453 100644 --- a/addons/godot_xterm/native/docker-compose.yaml +++ b/addons/godot_xterm/native/docker-compose.yaml @@ -1,6 +1,8 @@ services: javascript: - build: ../../../misc/docker + build: + context: . + dockerfile: javascript.Dockerfile user: ${UID_GID} volumes: - .:/src diff --git a/misc/docker/Dockerfile b/addons/godot_xterm/native/javascript.Dockerfile similarity index 86% rename from misc/docker/Dockerfile rename to addons/godot_xterm/native/javascript.Dockerfile index ca0c9d8..83efde8 100644 --- a/misc/docker/Dockerfile +++ b/addons/godot_xterm/native/javascript.Dockerfile @@ -1,4 +1,4 @@ # For convenient building of the library and gdnative export templates targeted at the javacript platform. -FROM emscripten/emsdk:3.1.5 +FROM emscripten/emsdk:2.0.25 RUN apt-get update && apt-get install pkg-config python3 -y RUN pip3 install scons diff --git a/addons/godot_xterm/native/linux.Dockerfile b/addons/godot_xterm/native/linux.Dockerfile index 4a0fd45..a957c95 100644 --- a/addons/godot_xterm/native/linux.Dockerfile +++ b/addons/godot_xterm/native/linux.Dockerfile @@ -3,5 +3,5 @@ FROM kroggen/ubuntu-16.04-gcc RUN apt-get update -y RUN apt-get install -y python3 python3-pip gcc-multilib g++-multilib -RUN pip3 install scons +RUN pip3 install scons==4.3.0 CMD scons platform=linux generate_bindings=yes target=${TARGET:-release} bits=${BITS:-64} -j$(nproc) diff --git a/addons/godot_xterm/native/src/terminal.cpp b/addons/godot_xterm/native/src/terminal.cpp index 0d67f81..ad45053 100644 --- a/addons/godot_xterm/native/src/terminal.cpp +++ b/addons/godot_xterm/native/src/terminal.cpp @@ -31,7 +31,7 @@ void Terminal::_populate_key_list() { #define GLOBAL_CONSTANT(VAR) GlobalConstants::VAR #else #define GLOBAL_CONSTANT(VAR) get_constant(#VAR) - const godot_dictionary _constants = godot_get_global_constants(); + const godot_dictionary _constants = godot::api->godot_get_global_constants(); const Dictionary *constants = (Dictionary *)&_constants; auto get_constant = [constants](std::string name) -> int64_t { diff --git a/addons/godot_xterm/native/thirdparty/godot-cpp b/addons/godot_xterm/native/thirdparty/godot-cpp index f9f6767..f4f6fac 160000 --- a/addons/godot_xterm/native/thirdparty/godot-cpp +++ b/addons/godot_xterm/native/thirdparty/godot-cpp @@ -1 +1 @@ -Subproject commit f9f6767722e17a1d690f7ce975e1e7f8065b61e2 +Subproject commit f4f6fac4c784da8c973ade0dbc64a9d8400ee247 diff --git a/docs/demo/.gitkeep b/docs/demo/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/export_presets.cfg b/export_presets.cfg index 10a7d1b..eca8422 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -13,8 +13,8 @@ script_encryption_key="" [preset.0.options] -custom_template/debug="./misc/export_templates/godot/bin/webassembly_gdnative_debug.zip" -custom_template/release="./misc/export_templates/godot/bin/webassembly_gdnative_release.zip" +custom_template/debug="" +custom_template/release="" variant/export_type=2 vram_texture_compression/for_desktop=true vram_texture_compression/for_mobile=false diff --git a/misc/export_templates/build.sh b/misc/export_templates/build.sh deleted file mode 100755 index 2bf7f70..0000000 --- a/misc/export_templates/build.sh +++ /dev/null @@ -1,41 +0,0 @@ -set -e - -# Parse args. -args=$@ -while [[ $# -gt 0 ]]; do - key="$1" - case $key in - -t|--target) - target="$2" - shift - shift - ;; - *) - echo "Usage: ./build.sh [-t|--target ]"; - exit 128 - shift - ;; - esac -done -# Set defaults. -target=${target:-debug} - -# Get the absolute path to the directory this script is in. -EXPORT_TEMPLATES_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - -# Update git submodules. -GODOT_DIR=${EXPORT_TEMPLATES_DIR}/godot -if [ -z "$(ls -A -- "$GODOT_DIR")" ]; then - cd ${EXPORT_TEMPLATES_DIR} - git submodule update --init --recursive -- $GODOT_DIR -fi - -# Use Docker to build HTML5 GDNative export templates. -UID_GID="0:0" docker-compose build javascript -UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=$target javascript - -if [ "$target" == "debug" ]; then - mv godot/bin/godot.javascript.debug.gdnative.zip godot/bin/webassembly_gdnative_debug.zip -else - mv godot/bin/godot.javascript.opt.gdnative.zip godot/bin/webassembly_gdnative_release.zip -fi diff --git a/misc/export_templates/docker-compose.yaml b/misc/export_templates/docker-compose.yaml deleted file mode 100644 index 4f087bf..0000000 --- a/misc/export_templates/docker-compose.yaml +++ /dev/null @@ -1,12 +0,0 @@ -services: - javascript: - build: ../docker - user: ${UID_GID} - volumes: - - ./godot:/src - command: - - /bin/bash - - -c - - | - cd src - scons platform=javascript tools=no gdnative_enabled=yes target=$${TARGET} -j$$(nproc) diff --git a/misc/export_templates/godot b/misc/export_templates/godot deleted file mode 160000 index 419e713..0000000 --- a/misc/export_templates/godot +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 419e713a29f20bd3351a54d1e6c4c5af7ef4b253 diff --git a/misc/export_templates/readme.txt b/misc/export_templates/readme.txt deleted file mode 100644 index d68e064..0000000 --- a/misc/export_templates/readme.txt +++ /dev/null @@ -1 +0,0 @@ -HTML5 GDNative export templates are not provided, this is just a convient script/docker-compose file for building them locally.