mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-10 04:40:25 +01:00
Use default export templates for HTML5
Changes Emscripten SDK version to match that used to compile the default export templates used by Godot 3.5 (in this case 3.1.14 as can be seen here: https://github.com/godotengine/build-containers/blob/3.5/Dockerfile.javascript). This means we no longer need to compile custom export templates when exporting HTML5 for Godot 3.5. Exports from other Godot versions may requiring compiling the GDNative library with a different version of the Emscripten SDK. - Changes renderer from GLES3 -> GLES2 and reduces MSAA level to better support HTML5 export. - Updates GitHub Action to export HTML5 and upload as a build artifact. - Adds Cypress test to smoke test HTML5 export.
This commit is contained in:
parent
2fa2322d7c
commit
10b9764fb3
26 changed files with 4896 additions and 118 deletions
21
.github/import_assets.tscn
vendored
Normal file
21
.github/import_assets.tscn
vendored
Normal file
|
@ -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"]
|
86
.github/workflows/main.yml
vendored
86
.github/workflows/main.yml
vendored
|
@ -102,7 +102,7 @@ jobs:
|
||||||
if: ${{ matrix.platform == 'javascript' }}
|
if: ${{ matrix.platform == 'javascript' }}
|
||||||
uses: mymindstorm/setup-emsdk@v11
|
uses: mymindstorm/setup-emsdk@v11
|
||||||
with:
|
with:
|
||||||
version: 3.1.5
|
version: 3.1.14
|
||||||
actions-cache-folder: emsdk-cache-${{ matrix.target }}
|
actions-cache-folder: emsdk-cache-${{ matrix.target }}
|
||||||
- name: Install additional javascript build dependencies
|
- name: Install additional javascript build dependencies
|
||||||
if: ${{ matrix.platform == 'javascript' }}
|
if: ${{ matrix.platform == 'javascript' }}
|
||||||
|
@ -168,43 +168,9 @@ jobs:
|
||||||
addons/godot_xterm/native/bin/*.dylib
|
addons/godot_xterm/native/bin/*.dylib
|
||||||
addons/godot_xterm/native/bin/*.dll
|
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:
|
html5_export:
|
||||||
name: 'HTML5 Export'
|
name: 'HTML5 Export'
|
||||||
needs: [ build_docker, build_native, export_template ]
|
needs: [ build_docker, build_native ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
@ -217,23 +183,39 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: libgodot-xterm-release
|
name: libgodot-xterm-release
|
||||||
path: addons/godot_xterm/native/bin
|
path: addons/godot_xterm/native/bin
|
||||||
- name: Install html5 export templates
|
- name: Import assets
|
||||||
uses: actions/download-artifact@v2
|
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 --no-window --export HTML5
|
||||||
|
- name: NPM cache
|
||||||
|
uses: c-hive/gha-npm-cache@v1
|
||||||
with:
|
with:
|
||||||
name: html5-gdnative-export-templates
|
directory: test/html5
|
||||||
path: misc/export_templates/godot/bin
|
- name: Smoke test HTML5 export
|
||||||
- name: Create export directory
|
shell: bash
|
||||||
run: mkdir -p docs/demo
|
working-directory: test/html5
|
||||||
- name: Export html5
|
run: |
|
||||||
run: godot --export HTML5
|
npm ci
|
||||||
# FIXME: HTML5 Exports not properly exporting .cast files.
|
npx serve ../../docs/demo -p 3000 &
|
||||||
# So skip upload for now.
|
npx cypress run
|
||||||
#- name: Upload export
|
- name: Upload cypress artifacts (on failure)
|
||||||
# uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
# with:
|
if: ${{ failure() }}
|
||||||
# name: html5-demo
|
with:
|
||||||
# path: docs/demo
|
name: cypress-artifacts
|
||||||
|
path: |-
|
||||||
|
test/html5/cypress/screenshots
|
||||||
|
test/html5/cypress/videos
|
||||||
|
- name: Upload export
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: html5-demo
|
||||||
|
path: docs/demo
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: 'Test'
|
name: 'Test'
|
||||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -7,6 +7,3 @@
|
||||||
[submodule "addons/godot_xterm/native/thirdparty/libtsm"]
|
[submodule "addons/godot_xterm/native/thirdparty/libtsm"]
|
||||||
path = addons/godot_xterm/native/thirdparty/libtsm
|
path = addons/godot_xterm/native/thirdparty/libtsm
|
||||||
url = https://github.com/lihop/libtsm
|
url = https://github.com/lihop/libtsm
|
||||||
[submodule "misc/export_templates/godot"]
|
|
||||||
path = misc/export_templates/godot
|
|
||||||
url = https://github.com/godotengine/godot
|
|
||||||
|
|
|
@ -82,5 +82,5 @@ scons target=$target macos_arch=$(uname -m) disable_pty=$disable_pty -j$nproc
|
||||||
# Use Docker to build libgodot-xterm javascript.
|
# Use Docker to build libgodot-xterm javascript.
|
||||||
if [ -x "$(command -v docker-compose)" ]; then
|
if [ -x "$(command -v docker-compose)" ]; then
|
||||||
UID_GID="0:0" TARGET=$target docker-compose build javascript
|
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
|
fi
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
services:
|
services:
|
||||||
javascript:
|
javascript:
|
||||||
build: ../../../misc/docker
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: javascript.Dockerfile
|
||||||
user: ${UID_GID}
|
user: ${UID_GID}
|
||||||
volumes:
|
volumes:
|
||||||
- .:/src
|
- .:/src
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# For convenient building of the library and gdnative export templates targeted at the javacript platform.
|
# For convenient building of the library and gdnative export templates targeted at the javacript platform.
|
||||||
FROM emscripten/emsdk:3.1.5
|
FROM emscripten/emsdk:3.1.14
|
||||||
RUN apt-get update && apt-get install pkg-config python3 -y
|
RUN apt-get update && apt-get install pkg-config python3 -y
|
||||||
RUN pip3 install scons
|
RUN pip3 install scons
|
|
@ -31,7 +31,7 @@ void Terminal::_populate_key_list() {
|
||||||
#define GLOBAL_CONSTANT(VAR) GlobalConstants::VAR
|
#define GLOBAL_CONSTANT(VAR) GlobalConstants::VAR
|
||||||
#else
|
#else
|
||||||
#define GLOBAL_CONSTANT(VAR) get_constant(#VAR)
|
#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;
|
const Dictionary *constants = (Dictionary *)&_constants;
|
||||||
|
|
||||||
auto get_constant = [constants](std::string name) -> int64_t {
|
auto get_constant = [constants](std::string name) -> int64_t {
|
||||||
|
|
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
|
|
||||||
## [Unreleased](https://github.com/lihop/godot-xterm/compare/v2.2.0...HEAD)
|
## [Unreleased](https://github.com/lihop/godot-xterm/compare/v2.2.0...HEAD)
|
||||||
|
### Changed
|
||||||
|
- Custom export templates are no longer required when exporting to HTML5 from Godot v3.5.x.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Removed support for deprecated theme item names.
|
- Removed support for deprecated theme item names.
|
||||||
- Removed deprecated get_master() method of PTY.
|
- Removed deprecated get_master() method of PTY.
|
||||||
|
|
|
@ -91,7 +91,8 @@ Are you using GodotXterm in your project and want it listed here? Please [open a
|
||||||
## Supported Godot Versions
|
## Supported Godot Versions
|
||||||
|
|
||||||
GodotXterm aims to support the current stable release of Godot, but may lag slightly.
|
GodotXterm aims to support the current stable release of Godot, but may lag slightly.
|
||||||
Currently, Godot versions 3.5.x and 3.4.x are supported.
|
Currently, Godot versions 3.5.x and 3.4.x are supported, but custom export templates
|
||||||
|
are required for HTML5 exports from versions < 3.5.
|
||||||
Versions 3.3.x are no longer officially supported but *may* work if the GDNative libraries are
|
Versions 3.3.x are no longer officially supported but *may* work if the GDNative libraries are
|
||||||
compiled using an older version of godot-cpp.
|
compiled using an older version of godot-cpp.
|
||||||
|
|
||||||
|
|
0
docs/demo/.gitkeep
Normal file
0
docs/demo/.gitkeep
Normal file
|
@ -13,8 +13,8 @@ script_encryption_key=""
|
||||||
|
|
||||||
[preset.0.options]
|
[preset.0.options]
|
||||||
|
|
||||||
custom_template/debug="./misc/export_templates/godot/bin/webassembly_gdnative_debug.zip"
|
custom_template/debug=""
|
||||||
custom_template/release="./misc/export_templates/godot/bin/webassembly_gdnative_release.zip"
|
custom_template/release=""
|
||||||
variant/export_type=2
|
variant/export_type=2
|
||||||
vram_texture_compression/for_desktop=true
|
vram_texture_compression/for_desktop=true
|
||||||
vram_texture_compression/for_mobile=false
|
vram_texture_compression/for_mobile=false
|
||||||
|
|
|
@ -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 <release|debug>]";
|
|
||||||
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
|
|
|
@ -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)
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 419e713a29f20bd3351a54d1e6c4c5af7ef4b253
|
|
|
@ -1 +0,0 @@
|
||||||
HTML5 GDNative export templates are not provided, this is just a convient script/docker-compose file for building them locally.
|
|
|
@ -40,6 +40,6 @@ enabled=PoolStringArray( "res://addons/godot_xterm/plugin.cfg" )
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
quality/driver/driver_name="GLES2"
|
||||||
quality/filters/anisotropic_filter_level=16
|
quality/filters/anisotropic_filter_level=16
|
||||||
quality/filters/msaa=4
|
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
|
|
0
test/html5/.gdignore
Normal file
0
test/html5/.gdignore
Normal file
4
test/html5/.gitignore
vendored
Normal file
4
test/html5/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
cypress-visual-screenshots/
|
||||||
|
cypress/screenshots/
|
||||||
|
cypress/videos/
|
||||||
|
node_modules/
|
BIN
test/html5/cypress-visual-screenshots/baseline/smoke_test.cy-menu.png
Executable file
BIN
test/html5/cypress-visual-screenshots/baseline/smoke_test.cy-menu.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
10
test/html5/cypress.config.js
Normal file
10
test/html5/cypress.config.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
const { defineConfig } = require("cypress");
|
||||||
|
const getCompareSnapshotsPlugin = require('cypress-image-diff-js/dist/plugin');
|
||||||
|
|
||||||
|
module.exports = defineConfig({
|
||||||
|
e2e: {
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
getCompareSnapshotsPlugin(on, config);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
21
test/html5/cypress/e2e/smoke_test.cy.js
Normal file
21
test/html5/cypress/e2e/smoke_test.cy.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Cypress.on('window:before:load', win => {
|
||||||
|
cy.spy(win.console, 'error')
|
||||||
|
cy.spy(win.console, 'warn')
|
||||||
|
cy.spy(win.console, 'log')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('GodotXterm HTML5 export', () => {
|
||||||
|
it('Loads and runs without error', () => {
|
||||||
|
cy.visit('http://localhost:3000')
|
||||||
|
cy.compareSnapshot('menu', 0.9, {
|
||||||
|
limit: 100, delay: 200, timeout: 20000,
|
||||||
|
})
|
||||||
|
cy.get('body').type('{downArrow}{enter}')
|
||||||
|
cy.get('body').type('window.console.log("It works!"){enter}')
|
||||||
|
cy.window().then(win => {
|
||||||
|
cy.expect(win.console.error).to.have.callCount(0)
|
||||||
|
cy.expect(win.console.warn).to.have.callCount(0)
|
||||||
|
cy.expect(win.console.log).to.be.calledWith("It works!")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
2
test/html5/cypress/support/commands.js
Normal file
2
test/html5/cypress/support/commands.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import compareSnapshotCommand from 'cypress-image-diff-js/dist/command';
|
||||||
|
compareSnapshotCommand();
|
1
test/html5/cypress/support/e2e.js
Normal file
1
test/html5/cypress/support/e2e.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import './commands'
|
4764
test/html5/package-lock.json
generated
Normal file
4764
test/html5/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
11
test/html5/package.json
Normal file
11
test/html5/package.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"start": "npx serve ../../docs/demo",
|
||||||
|
"test": "npx cypress run"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"cypress": "^10.4.0",
|
||||||
|
"cypress-image-diff-js": "^1.21.1",
|
||||||
|
"serve": "^14.0.1"
|
||||||
|
}
|
||||||
|
}
|
14
test/html5/shell.nix
Normal file
14
test/html5/shell.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
cypress
|
||||||
|
nodejs-16_x
|
||||||
|
xsel
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
export CYPRESS_INSTALL_BINARY=0
|
||||||
|
export CYPRESS_RUN_BINARY=${pkgs.cypress}/bin/Cypress
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue