mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 12:14:24 +02:00
Add HTML5 support
This commit is contained in:
parent
fbb23661d3
commit
bb8d40df58
18 changed files with 284 additions and 31 deletions
|
@ -46,7 +46,7 @@ opts.Add(EnumVariable(
|
|||
'platform',
|
||||
'Target platform',
|
||||
host_platform,
|
||||
allowed_values=('linux', 'osx', 'windows'),
|
||||
allowed_values=('linux', 'javascript', 'osx', 'windows'),
|
||||
ignorecase=2
|
||||
))
|
||||
opts.Add(EnumVariable(
|
||||
|
@ -76,6 +76,7 @@ if env['platform'] == 'linux':
|
|||
|
||||
env['CC'] = 'gcc'
|
||||
env['CXX'] = 'g++'
|
||||
env['LIBSUFFIX'] = '.a'
|
||||
|
||||
env.Append(CCFLAGS=['-fPIC', '-Wwrite-strings'])
|
||||
env.Append(LINKFLAGS=["-Wl,-R'$$ORIGIN'"])
|
||||
|
@ -92,6 +93,28 @@ if env['platform'] == 'linux':
|
|||
env.Append(CCFLAGS=['-m32'])
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
|
||||
# Compile for HTML5.
|
||||
elif env['platform'] == 'javascript':
|
||||
env.Append(CPPDEFINES=['PLATFORM_JS'])
|
||||
|
||||
env['bits'] = '32'
|
||||
env['CC'] = 'emcc'
|
||||
env['CXX'] = 'em++'
|
||||
env['AR'] = 'emar'
|
||||
env['RANLIB'] = 'emranlib'
|
||||
env.Append(CPPFLAGS=['-s', 'SIDE_MODULE=1'])
|
||||
env.Append(LINKFLAGS=['-s', 'SIDE_MODULE=1'])
|
||||
env['SHOBJSUFFIX'] = '.bc'
|
||||
env['SHLIBSUFFIX'] = '.wasm'
|
||||
env['OBJPREFIX'] = ''
|
||||
env['OBJSUFFIX'] = '.bc'
|
||||
env['PROGPREFIX'] = ''
|
||||
env['PROGSUFFIX'] = ''
|
||||
env['LIBSUFFIX'] = '.bc'
|
||||
env['LIBPREFIXES'] = ['$LIBPREFIX']
|
||||
env['LIBSUFFIXES'] = ['$LIBSUFFIX']
|
||||
env.Replace(SHLINKFLAGS='$LINKFLAGS')
|
||||
env.Replace(SHLINKFLAGS='$LINKFLAGS')
|
||||
|
||||
# Compile for OSX.
|
||||
elif env['platform'] == 'osx':
|
||||
|
@ -99,6 +122,7 @@ elif env['platform'] == 'osx':
|
|||
|
||||
env['CC'] = 'clang'
|
||||
env['CXX'] = 'clang++'
|
||||
env['LIBSUFFIX'] = '.a'
|
||||
|
||||
if env['bits'] == '32':
|
||||
raise ValueError(
|
||||
|
@ -121,6 +145,7 @@ elif env['platform'] == 'osx':
|
|||
# Compile for Windows.
|
||||
elif env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
|
||||
env['LIBSUFFIX'] = '.lib'
|
||||
|
||||
# On Windows using MSVC.
|
||||
if host_platform == 'windows':
|
||||
|
@ -202,33 +227,42 @@ env.Append(LIBPATH=[
|
|||
'external/godot-cpp/bin/',
|
||||
'external/libtsm/build/bin/',
|
||||
])
|
||||
|
||||
env.Append(LIBS=[
|
||||
'libgodot-cpp.{}.{}.{}'.format(
|
||||
env.File('external/godot-cpp/bin/libgodot-cpp.{}.{}.{}{}'.format(
|
||||
env['platform'],
|
||||
env['target'],
|
||||
env['bits']
|
||||
),
|
||||
'libtsm.{}.{}.{}'.format(
|
||||
'wasm' if env['platform'] == 'javascript' else env['bits'],
|
||||
env['LIBSUFFIX'],
|
||||
)),
|
||||
env.File('external/libtsm/build/bin/libtsm.{}.{}.{}{}'.format(
|
||||
env['platform'],
|
||||
env['target'],
|
||||
env['bits']
|
||||
),
|
||||
env['bits'],
|
||||
env['LIBSUFFIX'],
|
||||
)),
|
||||
])
|
||||
|
||||
sources = []
|
||||
sources.append('src/libgodotxtermnative.cpp')
|
||||
sources.append('src/terminal.cpp')
|
||||
|
||||
# Psuedoterminal not supported on windows yet.
|
||||
if env['platform'] != 'windows':
|
||||
# Psuedoterminal not supported on windows (yet) or HTML5.
|
||||
if env['platform'] != 'windows' and env['platform'] != 'javascript':
|
||||
sources.append('src/pseudoterminal.cpp')
|
||||
env.Append(LIBS=['util'])
|
||||
|
||||
if env['platform'] == 'linux':
|
||||
libsuffix = "a"
|
||||
suffix = "so"
|
||||
elif env['platform'] == 'javascript':
|
||||
libsuffix = "bc"
|
||||
suffix = "wasm"
|
||||
elif env['platform'] == 'windows':
|
||||
libsuffix = "lib"
|
||||
suffix = "dll"
|
||||
elif env['platform'] == 'osx':
|
||||
libsuffix = "a"
|
||||
suffix = "dylib"
|
||||
|
||||
library = env.SharedLibrary(
|
||||
|
|
|
@ -33,3 +33,7 @@ scons generate_bindings=yes -j$(nproc)
|
|||
# Build libgodot-xterm.
|
||||
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'
|
||||
|
||||
|
|
6
addons/godot_xterm/native/docker-compose.yaml
Normal file
6
addons/godot_xterm/native/docker-compose.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
services:
|
||||
javascript-build:
|
||||
build: misc/docker
|
||||
user: ${UID_GID}
|
||||
volumes:
|
||||
- .:/godot
|
2
addons/godot_xterm/native/external/godot-cpp
vendored
2
addons/godot_xterm/native/external/godot-cpp
vendored
|
@ -1 +1 @@
|
|||
Subproject commit b79a3b98b28e18bf981e2e2bd0b60faa23ef85f2
|
||||
Subproject commit b8eebe5eb61f1b22d2d829cccef264138b106cdb
|
|
@ -7,18 +7,18 @@ reloadable=true
|
|||
|
||||
[entry]
|
||||
|
||||
Server.64="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so"
|
||||
X11.64="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so"
|
||||
X11.32="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.32.so"
|
||||
HTML5.wasm32="res://addons/godot_xterm/native/bin/libgodot-xterm.javascript.32.wasm"
|
||||
OSX.64="res://addons/godot_xterm/native/bin/libgodot-xterm.osx.64.dylib"
|
||||
Windows.64="res://addons/godot_xterm/native/bin/libgodot-xterm.windows.64.dll"
|
||||
Windows.32="res://addons/godot_xterm/native/bin/libgodot-xterm.windows.32.dll"
|
||||
OSX.64="res://addons/godot_xterm/native/bin/libgodot-xterm.osx.64.dylib"
|
||||
X11.64="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so"
|
||||
X11.32="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.32.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Server.64=[ ]
|
||||
X11.64=[ ]
|
||||
X11.32=[ ]
|
||||
HTML5.wasm32=[ ]
|
||||
OSX.64=[ ]
|
||||
Windows.64=[ ]
|
||||
Windows.32=[ ]
|
||||
OSX.64=[ ]
|
||||
X11.64=[ ]
|
||||
X11.32=[ ]
|
||||
|
|
0
addons/godot_xterm/native/misc/.gdignore
Normal file
0
addons/godot_xterm/native/misc/.gdignore
Normal file
12
addons/godot_xterm/native/misc/docker/Dockerfile
Normal file
12
addons/godot_xterm/native/misc/docker/Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
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
|
7
addons/godot_xterm/native/misc/docker/build.sh
Normal file
7
addons/godot_xterm/native/misc/docker/build.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
source /emsdk/emsdk_env.sh
|
||||
export EM_CACHE=/godot/.emcache
|
||||
cd /godot/external/godot-cpp
|
||||
scons platform=javascript -j$(nproc)
|
||||
cd /godot
|
||||
scons platform=javascript -j$(nproc)
|
Loading…
Add table
Add a link
Reference in a new issue