From bdda1458c0048ab393e275d37cc0eb72bf26d76a Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Tue, 15 Jun 2021 13:54:35 +0700 Subject: [PATCH] Update files for javascript build and export Adds some files to making building and export for HTML5 more convenient. --- addons/godot_xterm/native/build.sh | 8 +++---- addons/godot_xterm/native/docker-compose.yaml | 14 ++++++++--- .../godot_xterm/native/misc/docker/Dockerfile | 12 ---------- .../godot_xterm/native/misc/docker/build.sh | 7 ------ addons/godot_xterm/native/shell.nix | 4 ++++ export_presets.cfg | 24 +++++++++++++++++++ .../native/misc => misc}/.gdignore | 0 misc/docker/Dockerfile | 4 ++++ misc/export_templates/build.sh | 23 ++++++++++++++++++ misc/export_templates/docker-compose.yaml | 12 ++++++++++ misc/export_templates/readme.txt | 1 + 11 files changed, 83 insertions(+), 26 deletions(-) delete mode 100644 addons/godot_xterm/native/misc/docker/Dockerfile delete mode 100644 addons/godot_xterm/native/misc/docker/build.sh create mode 100644 export_presets.cfg rename {addons/godot_xterm/native/misc => misc}/.gdignore (100%) create mode 100644 misc/docker/Dockerfile create mode 100755 misc/export_templates/build.sh create mode 100644 misc/export_templates/docker-compose.yaml create mode 100644 misc/export_templates/readme.txt diff --git a/addons/godot_xterm/native/build.sh b/addons/godot_xterm/native/build.sh index c6e393b..42959ad 100755 --- a/addons/godot_xterm/native/build.sh +++ b/addons/godot_xterm/native/build.sh @@ -2,7 +2,7 @@ set -e -# Get the absolute path to the directory this script is in. +#GODOT_DIR Get the absolute path to the directory this script is in. NATIVE_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" @@ -34,6 +34,6 @@ scons generate_bindings=yes -j$(nproc) cd ${NATIVE_DIR} scons -j$(nproc) -echo "To Build libgodot-xterm for javascript platform inside a docker container, run:" -echo 'UID_GID="$(id -u):$(id -g)" docker-compose run javascript-build' - +# Use Docker to build libgodot-xterm javascript. +UID_GID="0:0" docker-compose build javascript +UID_GID="$(id -u):$(id -g)" docker-compose run javascript diff --git a/addons/godot_xterm/native/docker-compose.yaml b/addons/godot_xterm/native/docker-compose.yaml index 3e80446..b1a9731 100644 --- a/addons/godot_xterm/native/docker-compose.yaml +++ b/addons/godot_xterm/native/docker-compose.yaml @@ -1,6 +1,14 @@ services: - javascript-build: - build: misc/docker + javascript: + build: ../../../misc/docker user: ${UID_GID} volumes: - - .:/godot + - .:/src + command: + - /bin/bash + - -c + - | + cd /src/thirdparty/godot-cpp + scons platform=javascript target=debug -j$$(nproc) + cd /src + scons platform=javascript target=debug -j$$(nproc) diff --git a/addons/godot_xterm/native/misc/docker/Dockerfile b/addons/godot_xterm/native/misc/docker/Dockerfile deleted file mode 100644 index 0809ac5..0000000 --- a/addons/godot_xterm/native/misc/docker/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM ponders/godot-cpp-ci - -RUN git clone https://github.com/emscripten-core/emsdk.git -WORKDIR emsdk -RUN ./emsdk install 2.0.10 -RUN ./emsdk activate 2.0.10 -RUN chmod -R 777 /emsdk -WORKDIR /godot -RUN apt-get update && apt-get install -y vim -COPY ./build.sh /build.sh -RUN chmod +x /build.sh -CMD /build.sh diff --git a/addons/godot_xterm/native/misc/docker/build.sh b/addons/godot_xterm/native/misc/docker/build.sh deleted file mode 100644 index 91c7795..0000000 --- a/addons/godot_xterm/native/misc/docker/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -source /emsdk/emsdk_env.sh -export EM_CACHE=/godot/.emcache -cd /godot/thirdparty/godot-cpp -scons platform=javascript -j$(nproc) -cd /godot -scons platform=javascript -j$(nproc) diff --git a/addons/godot_xterm/native/shell.nix b/addons/godot_xterm/native/shell.nix index 1793f5a..21a13b0 100644 --- a/addons/godot_xterm/native/shell.nix +++ b/addons/godot_xterm/native/shell.nix @@ -5,5 +5,9 @@ mkShell { scons cacert # Required for git clone on GithHub actions runner. + + # Used to build for javascript platform. + docker + docker-compose ]; } diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..7dc8a04 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,24 @@ +[preset.0] + +name="HTML5" +platform="HTML5" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="misc/*, addons/godot_xterm/native/thirdparty/*" +export_path="export/index.html" +script_export_mode=1 +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" +variant/export_type=2 +vram_texture_compression/for_desktop=true +vram_texture_compression/for_mobile=false +html/custom_html_shell="" +html/head_include="" +html/canvas_resize_policy=2 +html/experimental_virtual_keyboard=false diff --git a/addons/godot_xterm/native/misc/.gdignore b/misc/.gdignore similarity index 100% rename from addons/godot_xterm/native/misc/.gdignore rename to misc/.gdignore diff --git a/misc/docker/Dockerfile b/misc/docker/Dockerfile new file mode 100644 index 0000000..4aa55fc --- /dev/null +++ b/misc/docker/Dockerfile @@ -0,0 +1,4 @@ +# For convenient building of the library and gdnative export templates targeted at the javacript platform. +FROM emscripten/emsdk:2.0.10 +RUN apt-get update && apt-get install pkg-config python3 -y +RUN pip3 install scons diff --git a/misc/export_templates/build.sh b/misc/export_templates/build.sh new file mode 100755 index 0000000..e27b5cb --- /dev/null +++ b/misc/export_templates/build.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +# 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 [ ! -d "$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 + +# Debug +UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=debug javascript +mv godot/bin/godot.javascript.debug.gdnative.zip godot/bin/webassembly_gdnative_debug.zip + +### Release +UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=release javascript +mv godot/bin/godot.javascript.opt.gdnative.zip godot/bin/webassembly_gdnative_release.zip diff --git a/misc/export_templates/docker-compose.yaml b/misc/export_templates/docker-compose.yaml new file mode 100644 index 0000000..4f087bf --- /dev/null +++ b/misc/export_templates/docker-compose.yaml @@ -0,0 +1,12 @@ +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/readme.txt b/misc/export_templates/readme.txt new file mode 100644 index 0000000..d68e064 --- /dev/null +++ b/misc/export_templates/readme.txt @@ -0,0 +1 @@ +HTML5 GDNative export templates are not provided, this is just a convient script/docker-compose file for building them locally.