Update build files and GitHub Actions workflow

This commit is contained in:
Leroy Hopson 2023-01-26 07:12:07 +13:00
parent 237a456f99
commit 2ba480b4da
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
15 changed files with 172 additions and 429 deletions

View file

@ -1,32 +0,0 @@
name: Cache dependencies
inputs:
platform:
required: true
target:
required: true
bits:
required: true
outputs:
cache-hit:
value: ${{ steps.cache.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Hash submodule revisions
id: hash
working-directory: addons/godot_xterm/native/thirdparty
shell: bash
run: |
cache_version=1 # Increment this number to invalidate the cache.
godot_cpp_rev=$(git ls-tree HEAD godot-cpp --object-only)
libuv_rev=$(git ls-tree HEAD libuv --object-only)
libtsm_rev=$(git ls-tree HEAD libtsm --object-only)
hash_cmd=$([[ $RUNNER_OS == 'Windows' ]] && echo 'sha1sum' || echo 'shasum')
hash_of_hashes=$(echo -n "$godot_cpp_rev$libuv_rev$libtsm_rev$cache_version" | $hash_cmd | head -c 40)
echo "::set-output name=hash::$hash_of_hashes"
- name: Cache submodules
uses: actions/cache@v3
id: cache
with:
path: addons/godot_xterm/native/thirdparty
key: thirdparty-${{ inputs.platform }}-${{ inputs.bits }}-${{ inputs.target }}-${{ steps.hash.outputs.hash }}

View file

@ -0,0 +1,44 @@
name: Cache dependencies
inputs:
platform:
required: true
target:
required: true
arch:
required: true
outputs:
cache-hit:
value: ${{ steps.cache.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Hash submodule revisions
id: hash
working-directory: addons/godot_xterm/native/thirdparty
shell: bash
run: |
godot_cpp_rev=$(git ls-tree HEAD godot-cpp --object-only)
libuv_rev=$(git ls-tree HEAD libuv --object-only)
libtsm_rev=$(git ls-tree HEAD libtsm --object-only)
hash_cmd=$([[ $RUNNER_OS == 'Windows' ]] && echo 'sha1sum' || echo 'shasum')
hash_of_hashes=$(echo -n "$godot_cpp_rev$libuv_rev$libtsm_rev" | $hash_cmd | head -c 40)
echo "hash=$hash_of_hashes" >> $GITHUB_OUTPUT
build_files_hash=${{ hashFiles('**/build.sh', '**/*.Dockerfile', '**/SConstruct', '**/*.yml') }}
echo "build-files-hash=$build_files_hash" >> $GITHUB_OUTPUT
- name: Cache submodules
uses: actions/cache@v3
id: cache
with:
path: addons/godot_xterm/native/thirdparty
key: thirdparty-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.target }}-${{ steps.hash.outputs.hash }}-${{ steps.hash.outputs.build-files-hash }}
restore-keys: |
thirdparty-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.target }}-${{ steps.hash.outputs.hash }}-
thirdparty-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.target }}-
- name: Scons cache
uses: actions/cache@v3
with:
path: "${{github.workspace}}/.scons-cache/"
key: scons-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.target }}-${{ steps.hash.outputs.hash }}-${{ steps.hash.outputs.build-files-hash }}
restore-keys: |
scons-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.target }}-${{ steps.hash.outputs.hash }}-
scons-${{ inputs.platform }}-${{ inputs.arch }}-${{ inputs.target }}-

View file

@ -0,0 +1,10 @@
name: Import assets
runs:
using: "composite"
steps:
- name: Import assets
shell: bash
run: |
# HACK: See https://github.com/godotengine/godot-proposals/issues/1362.
(for i in {1..4}; do godot --editor --headless & sleep 5 && .github/actions/import-assets/monitor_import.sh; done) || true

View file

@ -0,0 +1,10 @@
#!/bin/sh
# Source: https://github.com/godotengine/godot/pull/68461#issuecomment-1328177902
while [ "$(printf "%.0f\n" $(top -n 1 -b | awk '/^%Cpu/{print $2}'))" -gt 10 ];
do
echo "$(top -n 1 -b | awk '/^%Cpu/{print $2}')";
done
echo "Finished importing. Killing godot editor process";
kill -9 $(pgrep -o godot)

View file

@ -1,21 +0,0 @@
[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"]

View file

@ -5,24 +5,17 @@ on:
schedule: # Build and test daily. schedule: # Build and test daily.
- cron: 0 11 * * * - cron: 0 11 * * *
env:
# Caches should be automatically invalidated when versions change,
# but invalidation can be forced by incrementing these numbers.
EMSCRIPTEN_CACHE_VERSION: 1
EXPORT_TEMPLATE_CACHE_VERSION: 1
GODOT_CACHE_VERSION: 1
jobs: jobs:
build_docker: build_docker:
name: 'Build Docker (linux, ${{ matrix.target }}, ${{ matrix.bits }})' name: 'Build Docker'
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
target: [ release, debug ] target: [ release, debug ]
bits: [ 64, 32 ] arch: [ x86_64, x86_32 ]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Cache submodules - name: Cache submodules
@ -31,34 +24,31 @@ jobs:
with: with:
platform: linux platform: linux
target: ${{ matrix.target }} target: ${{ matrix.target }}
bits: ${{ matrix.bits }} arch: ${{ matrix.arch }}
- name: Pull docker images - name: Pull docker images
run: docker-compose pull run: docker-compose pull
working-directory: addons/godot_xterm/native working-directory: addons/godot_xterm/native
- name: Cache docker image layers - name: Cache docker image layers
uses: satackey/action-docker-layer-caching@v0 uses: jpribyl/action-docker-layer-caching@v0.1.1
continue-on-error: true continue-on-error: true
- name: Build godot-cpp bindings - name: Ensure scons cache exists
if: steps.cache-submodules.outputs.cache-hit != 'true' run: mkdir -p ${{github.workspace}}/.scons-cache
working-directory: addons/godot_xterm/native
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 - name: Build libuv
if: steps.cache-submodules.outputs.cache-hit != 'true' if: steps.cache-submodules.outputs.cache-hit != 'true'
working-directory: addons/godot_xterm/native working-directory: addons/godot_xterm/native
run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} libuv-linux run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e ARCH=${{ matrix.arch }} -v ${{github.workspace}}/.scons-cache:/scons-cache libuv-linux
- name: Build libgodot-xterm - name: Build libgodot-xterm
working-directory: addons/godot_xterm/native working-directory: addons/godot_xterm/native
run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} libgodot-xterm-linux run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e ARCH=${{ matrix.arch }} -v ${{github.workspace}}/.scons-cache:/scons-cache libgodot-xterm-linux
- name: Upload binaries - name: Upload binaries
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: libgodot-xterm-${{ matrix.target }} name: libgodot-xterm-${{ matrix.target }}
path: | path: |
addons/godot_xterm/native/bin/*.so addons/godot_xterm/native/bin/*.so
build_native: build_native:
if: false # Temporarily disabled.
name: 'Build Native' name: 'Build Native'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
@ -80,7 +70,7 @@ jobs:
- platform: osx - platform: osx
bits: 32 # Only 64-bit supported on macOS. bits: 32 # Only 64-bit supported on macOS.
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Cache submodules - name: Cache submodules
@ -92,12 +82,14 @@ jobs:
bits: ${{ matrix.bits }} bits: ${{ matrix.bits }}
- name: Cache emscripten - name: Cache emscripten
if: ${{ matrix.platform == 'javascript' }} if: ${{ matrix.platform == 'javascript' }}
uses: actions/cache@v2 uses: actions/cache@v3
env: env:
cache-name: cache-emscripten cache-name: cache-emscripten
with: with:
path: addons/godot_xterm/native/.emcache path: addons/godot_xterm/native/.emcache
key: emsdk-cache-${{ matrix.target }}-v${{ env.EMSCRIPTEN_CACHE_VERSION }} key: emsdk-cache-${{ matrix.target }}-${{ hashFiles('**/*.c*', '**/*.h*') }}
restore-keys: |
emsdk-cache-${{ matrix.target }}-
- name: Install javascript build dependencies - name: Install javascript build dependencies
if: ${{ matrix.platform == 'javascript' }} if: ${{ matrix.platform == 'javascript' }}
uses: mymindstorm/setup-emsdk@v11 uses: mymindstorm/setup-emsdk@v11
@ -160,7 +152,7 @@ jobs:
cd addons/godot_xterm/native cd addons/godot_xterm/native
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} -j2 scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} -j2
- name: Upload binaries - name: Upload binaries
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: libgodot-xterm-${{ matrix.target }} name: libgodot-xterm-${{ matrix.target }}
path: | path: |
@ -169,27 +161,23 @@ jobs:
addons/godot_xterm/native/bin/*.dll addons/godot_xterm/native/bin/*.dll
html5_export: html5_export:
if: false # Temporarily disabled.
name: 'HTML5 Export' name: 'HTML5 Export'
needs: [ build_docker, build_native ] needs: [ build_docker, build_native ]
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup Godot - name: Setup Godot
uses: lihop/setup-godot@v2 uses: lihop/setup-godot@4aad9daa7dd81c11329c4b54fdc26dbd39eea7d6
with: with:
export-templates: true export-templates: true
- name: Install binary build artifacts - name: Install binary build artifacts
uses: actions/download-artifact@v2 uses: actions/download-artifact@v3
with: with:
name: libgodot-xterm-release name: libgodot-xterm-release
path: addons/godot_xterm/native/bin path: addons/godot_xterm/native/bin
- name: Import assets - name: Import assets
uses: nick-fields/retry@v2 uses: ./.github/actions/import-assets
with:
command: godot --editor .github/import_assets.tscn
retry_on: error
timeout_minutes: 5
max_attempts: 6
- name: Export HTML5 - name: Export HTML5
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
with: with:
@ -209,7 +197,7 @@ jobs:
npx serve ../../docs/demo -p 3000 & npx serve ../../docs/demo -p 3000 &
npx cypress run npx cypress run
- name: Upload cypress artifacts (on failure) - name: Upload cypress artifacts (on failure)
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
if: ${{ failure() }} if: ${{ failure() }}
with: with:
name: cypress-artifacts name: cypress-artifacts
@ -217,52 +205,48 @@ jobs:
test/html5/cypress/screenshots test/html5/cypress/screenshots
test/html5/cypress/videos test/html5/cypress/videos
- name: Upload export - name: Upload export
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: html5-demo name: html5-demo
path: docs/demo path: docs/demo
test: test:
name: 'Test' name: 'Test'
needs: [ build_docker, build_native ] needs: [ build_docker ] #, build_native ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ windows-2022, macos-12, ubuntu-22.04 ] os: [ ubuntu-22.04 ] #, macos-12, windows-2022 ] Temporarily disabled.
bits: [ 64, 32 ] bits: [ 64, 32 ]
godot_version: [ 'v3.4.5-stable', 'v3.5-stable' ] godot_version: [ 'v4.0-beta14' ]
exclude: exclude:
- os: macos-12 - os: macos-12
bits: 32 bits: 32
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup Godot - name: Setup Godot
uses: lihop/setup-godot@v2 uses: lihop/setup-godot@4aad9daa7dd81c11329c4b54fdc26dbd39eea7d6
with: with:
version: ${{ matrix.godot_version }} version: ${{ matrix.godot_version }}
bits: ${{ matrix.bits }} bits: ${{ matrix.bits }}
- name: Install binary build artifacts - name: Install release binary build artifacts
uses: actions/download-artifact@v2 uses: actions/download-artifact@v3
with: with:
name: libgodot-xterm-release name: libgodot-xterm-release
path: addons/godot_xterm/native/bin path: addons/godot_xterm/native/bin
- name: Run tests - name: Install debug binary build artifacts
uses: nick-fields/retry@v2 uses: actions/download-artifact@v3
with: with:
shell: bash name: libgodot-xterm-debug
command: godot --no-window -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.ci.json path: addons/godot_xterm/native/bin
retry_on: error - name: Import assets
timeout_minutes: 5 uses: ./.github/actions/import-assets
max_attempts: 6 - name: Run tests
run: godot -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.ci.json
- name: Run unix tests - name: Run unix tests
if: ${{ matrix.os != 'windows-2022' }} if: ${{ matrix.os != 'windows-2022' }}
uses: nick-fields/retry@v2 run: godot -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.unix.json
with:
command: godot --no-window -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.unix.json
retry_on: error
timeout_minutes: 5
max_attempts: 6
# Git archive should only include addons/godot_xterm directory. # Git archive should only include addons/godot_xterm directory.
@ -270,14 +254,14 @@ jobs:
name: 'Check Archive' name: 'Check Archive'
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Create git archive - name: Create git archive
run: git archive -o archive.zip HEAD run: git archive -o archive.zip HEAD
- name: Extract archive - name: Extract archive
run: mkdir -p /tmp/unzipped && unzip archive.zip -d /tmp/unzipped run: mkdir -p /tmp/unzipped && unzip archive.zip -d /tmp/unzipped
- name: Check that archive only contains addons directory - name: Check that archive only contains addons/godot_xterm directory
run: | run: |
shopt -s nullglob dotglob shopt -s nullglob dotglob
ls -lR /tmp/unzipped ls -lR /tmp/unzipped
@ -304,11 +288,12 @@ jobs:
name: 'Check Code Format' name: 'Check Code Format'
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-python@v2 - uses: actions/setup-python@v4
with: with:
python-version: 3.x python-version: 3.x
- name: GDFormat Check cache: 'pip'
run: | - name: Install python dependencies
python -m pip install -r requirements.txt run: pip install -r requirements.txt
gdformat -c . - name: GDScript format check
run: gdformat -c .

View file

@ -3,4 +3,7 @@
entry_symbol = "godot_xterm_library_init" entry_symbol = "godot_xterm_library_init"
[libraries] [libraries]
linux.debug.x86_64 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so" linux.debug.x86_64 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_release.x86_64.so"
linux.debug.x86_32 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_debug.x86_32.so"
linux.release.x86_32 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_release.x86_32.so"

View file

@ -1,287 +1,40 @@
#!/usr/bin/env python #!/usr/bin/env python
"""
This file is modified version of the godot-cpp SConstruct file: https://github.com/godotengine/godot-cpp/blob/master/SConstruct
which is published under the following license:
MIT License # SPDX-FileCopyrightText: 2020-2023 Leroy Hopson <godot-xterm@leroy.geek.nz>
Copyright (c) 2017-2020 GodotNativeTools # SPDX-License-Identifier: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import os import os
import sys import sys
import subprocess
EnsureSConsVersion(4, 0) env = SConscript("./thirdparty/godot-cpp/SConstruct")
env['ENV'] = os.environ
# Try to detect the host platform automatically.
# This is used if no `platform` argument is passed.
if sys.platform.startswith('linux'):
host_platform = 'linux'
elif sys.platform == 'darwin':
host_platform = 'osx'
elif sys.platform == 'win32' or sys.platform == 'msys':
host_platform = 'windows'
else:
raise ValueError(
'Could not detect platform automatically, please specify with '
'platform=<platform>'
)
VariantDir('./thirdparty/libtsm/build', './thirdparty/libtsm/src', duplicate=0)
env = Environment(ENV = os.environ)
is64 = sys.maxsize > 2**32
if (
env['TARGET_ARCH'] == 'amd64' or
env['TARGET_ARCH'] == 'emt64' or
env['TARGET_ARCH'] == 'x86_64' or
env['TARGET_ARCH'] == 'arm64-v8a'
):
is64 = True
opts = Variables([], ARGUMENTS) opts = Variables([], ARGUMENTS)
opts.Add(EnumVariable(
'platform',
'Target platform',
host_platform,
allowed_values=('linux', 'javascript', 'osx', 'windows'),
ignorecase=2
))
opts.Add(EnumVariable(
'bits',
'Target platform bits',
'64' if is64 else '32',
('32', '64')
))
opts.Add(EnumVariable(
'target',
'Compilation target',
'editor',
allowed_values=('editor', 'release'),
ignorecase=2
))
opts.Add(EnumVariable("macos_arch", "Target macOS architecture",
"universal", ["universal", "x86_64", "arm64"]))
opts.Add(BoolVariable( opts.Add(BoolVariable(
'disable_pty', 'disable_pty',
'Disables the PTY and its dependencies (LibuvUtils and Pipe). Has no effect on platforms where PTY is not supported', 'Disables the PTY and its dependencies (LibuvUtils and Pipe). Has no effect on platforms where PTY is not supported',
False False
)) ))
opts.Update(env) opts.Update(env)
Help(opts.GenerateHelpText(env)) Help(opts.GenerateHelpText(env))
# Cache if SCONS_CACHE env var set.
scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path is not None:
CacheDir(scons_cache_path)
Decider("MD5")
print("caching to " + scons_cache_path)
exit
# Allows 32bit builds on windows 64bit.
if env['platform'] == 'windows':
if env['bits'] == '64':
env = Environment(TARGET_ARCH='amd64')
elif env['bits'] == '32':
env = Environment(TARGET_ARCH='x86')
opts.Update(env)
# Add PATH to environment so scons can find commands such as g++, etc.
env.AppendENVPath('PATH', os.getenv('PATH'))
# Compile for Linux.
if env['platform'] == 'linux':
env.Append(CPPDEFINES=['__linux__'])
env['CC'] = 'gcc'
env['CXX'] = 'g++'
env['LIBSUFFIX'] = '.a'
env.Append(CCFLAGS=['-fPIC', '-Wwrite-strings'])
env.Append(LINKFLAGS=["-Wl,-R'$$ORIGIN'", '-static-libstdc++'])
if env['target'] == 'editor':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
if env['bits'] == '64':
env.Append(CCFLAGS=['-m64'])
env.Append(LINKFLAGS=['-m64'])
elif env['bits'] == '32':
env.Append(CCFLAGS=['-m32'])
env.Append(LINKFLAGS=['-m32'])
# Compile for HTML5.
elif env['platform'] == 'javascript':
env.Append(CPPDEFINES=['__EMSCRIPTEN__'])
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'] = '.a'
env['LIBPREFIXES'] = ['$LIBPREFIX']
env['LIBSUFFIXES'] = ['$LIBSUFFIX']
env.Replace(SHLINKFLAGS='$LINKFLAGS')
env.Replace(SHLINKFLAGS='$LINKFLAGS')
# Compile for OSX.
elif env['platform'] == 'osx':
env.Append(CPPDEFINES=['__APPLE__'])
env['CC'] = 'clang'
env['CXX'] = 'clang++'
env['LIBSUFFIX'] = '.a'
if env['bits'] == '32':
raise ValueError(
'Only 64-bit builds are supported for the osx platform.'
)
if env["macos_arch"] == "universal":
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
else:
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
env.Append(LINKFLAGS=['-Wl,-undefined,dynamic_lookup'])
if env['target'] == 'editor':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
# Compile for Windows.
elif env['platform'] == 'windows':
env.Append(CPPDEFINES=['__WIN32'])
env['LIBSUFFIX'] = '.lib'
# On Windows using MSVC.
if host_platform == 'windows':
if env['target'] == 'editor':
env.Append(CCFLAGS=['/Z7', '/Od', '/EHsc', '/D_DEBUG', '/MDd'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
# On Windows, Linux, or MacOS using MinGW.
elif host_platform == 'linux' or host_platform == 'osx':
env.Append(CCFLAGS=['-std=c++17', '-Wwrite-strings'])
env.Append(LINKFLAGS=[
'--static',
'-Wl,--no-undefined',
'-static-libgcc',
'-static-libstdc++',
])
if env['target'] == 'editor':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
if env['bits'] == '64':
env['CC'] = 'x86_64-w64-mingw32-gcc'
env['CXX'] = 'x86_64-w64-mingw32-g++'
env['AR'] = "x86_64-w64-mingw32-ar"
env['RANLIB'] = "x86_64-w64-mingw32-ranlib"
env['LINK'] = "x86_64-w64-mingw32-g++"
elif env['bits'] == '32':
env['CC'] = 'i686-w64-mingw32-gcc'
env['CXX'] = 'i686-w64-mingw32-g++'
env['AR'] = "i686-w64-mingw32-ar"
env['RANLIB'] = "i686-w64-mingw32-ranlib"
env['LINK'] = "i686-w64-mingw32-g++"
# Build libtsm as a static library.
Execute([
Delete('thirdparty/libtsm/build/src'),
Delete('thirdparty/libtsm/build/external'),
Copy('thirdparty/libtsm/build/src', 'thirdparty/libtsm/src'),
Copy('thirdparty/libtsm/build/external', 'thirdparty/libtsm/external'),
])
env.Append(CPPPATH=[
'thirdparty/libtsm/src/shared',
'thirdparty/libtsm/external',
])
sources = []
sources.append('thirdparty/libtsm/build/external/wcwidth/wcwidth.c')
sources.append('thirdparty/libtsm/build/src/shared/shl-htable.c')
sources.append(Glob('thirdparty/libtsm/build/src/tsm/*.c'))
libtsm = env.StaticLibrary(
target='thirdparty/libtsm/build/bin/libtsm.{}.{}.{}{}'.format(
env['platform'],
env['target'],
env['bits'],
env['LIBSUFFIX']
), source=sources
)
Default(libtsm)
# Build libgodot-xterm.
if env['platform'] != 'windows':
env.Append(CXXFLAGS=['-std=c++17'])
env.Append(CPPPATH=[ env.Append(CPPPATH=[
'src/', 'src/',
'thirdparty/libtsm/build/src/tsm', 'thirdparty/libtsm/src/tsm',
'thirdparty/libtsm/build/src/shared', 'thirdparty/libtsm/external',
'thirdparty/godot-cpp/gdextension', 'thirdparty/libtsm/src/shared',
'thirdparty/godot-cpp/include', 'thirdparty/libuv/include',
'thirdparty/godot-cpp/gen/include',
'thirdparty/libuv/src',
'thirdparty/libuv/include'
])
env.Append(LIBPATH=[
'thirdparty/godot-cpp/bin/',
'thirdparty/libtsm/build/bin/',
]) ])
env.Append(LIBS=[ sources = Glob('thirdparty/libtsm/src/tsm/*.c')
env.File('thirdparty/godot-cpp/bin/libgodot-cpp.{}.{}.{}{}'.format( sources.append([
env['platform'], 'thirdparty/libtsm/external/wcwidth/wcwidth.c',
env['target'], 'thirdparty/libtsm/src/shared/shl-htable.c',
'wasm' if env['platform'] == 'javascript' else env['macos_arch'] if ( 'src/register_types.cpp',
env['macos_arch'] != 'universal' and env['platform'] == 'osx') else 'x86_64', # FIXME use correct arch. 'src/constants.cpp',
env['LIBSUFFIX'], 'src/terminal.cpp',
)),
env.File('thirdparty/libtsm/build/bin/libtsm.{}.{}.{}{}'.format(
env['platform'],
env['target'],
env['bits'],
env['LIBSUFFIX'],
)),
]) ])
sources = []
sources.append('src/register_types.cpp')
sources.append('src/constants.cpp')
sources.append('src/terminal.cpp')
# PTY not supported on HTML5.
if env['disable_pty'] or env['platform'] == 'javascript': if env['disable_pty'] or env['platform'] == 'javascript':
env.Append(CPPDEFINES=['_PTY_DISABLED']) env.Append(CPPDEFINES=['_PTY_DISABLED'])
else: else:
@ -301,24 +54,13 @@ else:
'Ws2_32.lib', 'Ws2_32.lib',
]) ])
if env['platform'] == 'linux': env.Append(LINKFLAGS=['-static-libstdc++'])
libsuffix = "a"
suffix = "so"
elif env['platform'] == 'javascript':
libsuffix = "a"
suffix = "wasm"
elif env['platform'] == 'windows':
libsuffix = "lib"
suffix = "dll"
elif env['platform'] == 'osx':
libsuffix = "a"
suffix = "dylib"
library = env.SharedLibrary( library = env.SharedLibrary(
target='bin/libgodot-xterm.{}.{}.{}'.format( target='bin/libgodot-xterm{}{}'.format(
env['platform'], env['suffix'],
env['bits'], env['SHLIBSUFFIX'],
suffix,
), source=sources ), source=sources
) )
Default(library) Default(library)

View file

@ -1,4 +1,8 @@
#!/bin/sh #!/bin/sh
# SPDX-FileCopyrightText: 2020-2023 Leroy Hopson <godot-xterm@leroy.geek.nz>
# SPDX-License-Identifier: MIT
set -e set -e
# Parse args. # Parse args.
@ -16,25 +20,21 @@ while [[ $# -gt 0 ]]; do
shift shift
;; ;;
*) *)
echo "Usage: ./build.sh [-t|--target <release|editor>] [--disable_pty]"; echo "Usage: ./build.sh [-t|--target <release|debug>] [--disable_pty]";
exit 128 exit 128
shift shift
;; ;;
esac esac
done done
# Set defaults. # Set defaults.
target=${target:-editor} target=${target:-debug}
disable_pty=${disable_pty:-no} disable_pty=${disable_pty:-no}
nproc=$(nproc || sysctl -n hw.ncpu) nproc=$(nproc || sysctl -n hw.ncpu)
# 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 )" NATIVE_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# Cache built files.
export SCONS_CACHE=${NATIVE_DIR}/.cache
# Run script inside a nix shell if it is available. # Run script inside a nix shell if it is available.
if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then
cd ${NATIVE_DIR} cd ${NATIVE_DIR}
@ -42,7 +42,6 @@ if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then
exit exit
fi fi
# Update git submodules. # Update git submodules.
updateSubmodules() { updateSubmodules() {
eval $1=$2 # E.g LIBUV_DIR=${NATIVE_DIR}/thirdparty/libuv eval $1=$2 # E.g LIBUV_DIR=${NATIVE_DIR}/thirdparty/libuv
@ -57,11 +56,6 @@ updateSubmodules LIBUV_DIR ${NATIVE_DIR}/thirdparty/libuv
updateSubmodules LIBTSM_DIR ${NATIVE_DIR}/thirdparty/libtsm updateSubmodules LIBTSM_DIR ${NATIVE_DIR}/thirdparty/libtsm
updateSubmodules GODOT_CPP_DIR ${NATIVE_DIR}/thirdparty/godot-cpp updateSubmodules GODOT_CPP_DIR ${NATIVE_DIR}/thirdparty/godot-cpp
# Build godot-cpp bindings.
cd ${GODOT_CPP_DIR}
scons generate_bindings=yes macos_arch=$(uname -m) target=$target -j$nproc
# Build libuv as a static library. # Build libuv as a static library.
cd ${LIBUV_DIR} cd ${LIBUV_DIR}
mkdir build || true mkdir build || true
@ -79,7 +73,7 @@ cmake --build build --config $target -j$nproc
# Build libgodot-xterm. # Build libgodot-xterm.
cd ${NATIVE_DIR} cd ${NATIVE_DIR}
scons target=$target macos_arch=$(uname -m) disable_pty=$disable_pty -j$nproc scons target=template_$target arch=$(uname -m) disable_pty=$disable_pty
# 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

View file

@ -1,3 +1,4 @@
---
services: services:
javascript: javascript:
build: build:
@ -14,14 +15,6 @@ services:
scons platform=javascript target=$${TARGET:-debug} -j$$(nproc) scons platform=javascript target=$${TARGET:-debug} -j$$(nproc)
cd /src cd /src
scons platform=javascript target=$${TARGET:-debug} -j$$(nproc) scons platform=javascript target=$${TARGET:-debug} -j$$(nproc)
godot-cpp-linux:
user: ${UID_GID}
build:
context: .
dockerfile: linux.Dockerfile
volumes:
- ./thirdparty/godot-cpp:/godot-cpp
working_dir: /godot-cpp
libuv-linux: libuv-linux:
user: ${UID_GID} user: ${UID_GID}
build: build:
@ -35,12 +28,12 @@ services:
- -c - -c
- | - |
target=$${TARGET:-release} target=$${TARGET:-release}
bits=$${BITS:-'64'} arch=$${ARCH:-x86_64}
mkdir build 2>/dev/null ; mkdir build 2>/dev/null ;
args="-DCMAKE_BUILD_TYPE=$$target \ args="-DCMAKE_BUILD_TYPE=$$target \
-DBUILD_SHARED_LIBS=OFF \ -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE" -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE"
if [[ $$bits -eq 32 ]]; then if [[ $$arch == "x86_32" ]]; then
args="$$args -DCMAKE_SYSTEM_PROCESSOR=i686 -DCMAKE_C_FLAGS=-m32"; args="$$args -DCMAKE_SYSTEM_PROCESSOR=i686 -DCMAKE_C_FLAGS=-m32";
else else
args="$$args -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_FLAGS="; args="$$args -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_FLAGS=";
@ -57,3 +50,10 @@ services:
volumes: volumes:
- .:/godot-xterm - .:/godot-xterm
working_dir: /godot-xterm working_dir: /godot-xterm
environment:
- SCONS_CACHE=/scons-cache
command:
- /bin/bash
- -c
- |
scons target=template_$${TARGET:-debug} arch=$${ARCH:-x86_64}

View file

@ -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.14 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==4.4.0

View file

@ -2,6 +2,14 @@
# with older versions of GLIBC installed on their systems can use the library. # with older versions of GLIBC installed on their systems can use the library.
FROM kroggen/ubuntu-16.04-gcc FROM kroggen/ubuntu-16.04-gcc
RUN apt-get update -y RUN apt-get update -y
RUN apt-get install -y python3 python3-pip gcc-multilib g++-multilib RUN apt-get install -y software-properties-common
RUN pip3 install scons==4.3.0 RUN add-apt-repository -y ppa:jblgf0/python
CMD scons platform=linux generate_bindings=yes target=${TARGET:-release} bits=${BITS:-64} -j$(nproc) RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN apt-get update -y
RUN apt-get install -y curl gcc-9-multilib g++-9-multilib python3.7
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.7
RUN pip3 install scons==4.4.0
RUN ln -sf /usr/bin/gcc-9 /usr/bin/gcc
RUN ln -s /usr/bin/g++-9 /usr/bin/g++
VOLUME /scons-cache
CMD scons target=${TARGET:-template_release} arch=${ARCH:-x86_64}

@ -1 +1 @@
Subproject commit 151ea35c5fbb0254e0d3d29e230270b60852915f Subproject commit 19091138895d35e1ce69742889b8bfd82be57f17

@ -1 +1 @@
Subproject commit 0c2d956b3110b72d35951dbf38ef6ed71e4bda9a Subproject commit 0102bc2c5480773bf64c1edbdfb5d1ddb3b63954

View file

@ -1,8 +1,8 @@
colorama==0.4.5 colorama==0.4.5
docopt==0.6.2 docopt==0.6.2
future==0.18.2 future==0.18.2
gdtoolkit==3.4.0 git+https://github.com/Scony/godot-gdscript-toolkit@5f4405e1d5f47e581860103106c96a0504bdf74a
lark-parser==0.8.0 lark-parser==0.12.0
mando==0.6.4 mando==0.6.4
PyYAML==6.0 PyYAML==6.0
radon==5.1.0 radon==5.1.0