mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-10 04:40:25 +01:00
Add support for Windows 64-bit
Tested on NixOS, Ubuntu and Arch Linux. Not yet able to compile for Windows 32-bit on NixOS or on Windows itself. Part of #5
This commit is contained in:
parent
fc60c366e6
commit
630e0104d5
10 changed files with 328 additions and 110 deletions
|
@ -5,8 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
- Support for Windows 64-bit.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Updated build script (`addons/godot_xterm/native/build.sh`). Git submodules will now be initialized if they haven't already. Moved nix-shell related stuff to a seperate shell.nix file so the same build command can be used on all Linux based OSes.
|
- Updated build script. `./build.sh` will create a debug build of the gdnative library for the current platform. `./build.sh release-all` will create release build of the gdnative library for every supported platform.
|
||||||
- Positioned background rect at 0,0 so it is no longer offset if a margin is added when Terminal is a child of a Container node.
|
- Positioned background rect at 0,0 so it is no longer offset if a margin is added when Terminal is a child of a Container node.
|
||||||
- Removed all pre-compiled binaries using BFG [Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/), thus re-writing git history.
|
- Removed all pre-compiled binaries using BFG [Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/), thus re-writing git history.
|
||||||
|
|
||||||
|
|
11
README.md
11
README.md
|
@ -13,6 +13,17 @@ Terminal emulator for Godot using GDNative and [libtsm](https://github.com/Aetf/
|
||||||
|
|
||||||
![Screenshot of Main Menu Scene](./docs/screenshot.png)
|
![Screenshot of Main Menu Scene](./docs/screenshot.png)
|
||||||
|
|
||||||
|
## Supported Platforms
|
||||||
|
|
||||||
|
### Confirmed:
|
||||||
|
- Linux 64-bit (primarily developed/tested on this platform)
|
||||||
|
- Windows 64-bit
|
||||||
|
|
||||||
|
### Planned/untested:
|
||||||
|
- Linux 32-bit
|
||||||
|
- Windows 32-bit
|
||||||
|
- MacOS 64-bit
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
**Important**: It is recommended that you build the native binaries before opening this demo project, otherwise the Godot editor will automatically modify the example scenes when it can't find the native libs, such that they won't work when the files _are_ in place.
|
**Important**: It is recommended that you build the native binaries before opening this demo project, otherwise the Godot editor will automatically modify the example scenes when it can't find the native libs, such that they won't work when the files _are_ in place.
|
||||||
|
|
|
@ -1,118 +1,294 @@
|
||||||
#!python
|
#!/usr/bin/env python
|
||||||
import os, subprocess
|
"""
|
||||||
|
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
|
||||||
|
Copyright (c) 2017-2020 GodotNativeTools
|
||||||
|
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 sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
def decode_utf8(x):
|
||||||
|
return x
|
||||||
|
else:
|
||||||
|
import codecs
|
||||||
|
def decode_utf8(x):
|
||||||
|
return codecs.utf_8_decode(x)[0]
|
||||||
|
|
||||||
|
# Workaround for MinGW. See:
|
||||||
|
# http://www.scons.org/wiki/LongCmdLinesOnWin32
|
||||||
|
if (os.name=="nt"):
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def mySubProcess(cmdline,env):
|
||||||
|
#print "SPAWNED : " + cmdline
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
|
||||||
|
data, err = proc.communicate()
|
||||||
|
rv = proc.wait()
|
||||||
|
if rv:
|
||||||
|
print("=====")
|
||||||
|
print(err.decode("utf-8"))
|
||||||
|
print("=====")
|
||||||
|
return rv
|
||||||
|
|
||||||
|
def mySpawn(sh, escape, cmd, args, env):
|
||||||
|
|
||||||
|
newargs = ' '.join(args[1:])
|
||||||
|
cmdline = cmd + " " + newargs
|
||||||
|
|
||||||
|
rv=0
|
||||||
|
if len(cmdline) > 32000 and cmd.endswith("ar") :
|
||||||
|
cmdline = cmd + " " + args[1] + " " + args[2] + " "
|
||||||
|
for i in range(3,len(args)) :
|
||||||
|
rv = mySubProcess( cmdline + args[i], env )
|
||||||
|
if rv :
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
rv = mySubProcess( cmdline, env )
|
||||||
|
|
||||||
|
return rv
|
||||||
|
|
||||||
|
def add_sources(sources, dir, extension):
|
||||||
|
for f in os.listdir(dir):
|
||||||
|
if f.endswith('.' + extension):
|
||||||
|
sources.append(dir + '/' + f)
|
||||||
|
|
||||||
|
|
||||||
|
# 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('./external/libtsm/build', './external/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)
|
||||||
|
|
||||||
# Gets the standard flags CC, CCX, etc.
|
opts.Add(EnumVariable(
|
||||||
env = DefaultEnvironment()
|
'platform',
|
||||||
|
'Target platform',
|
||||||
|
host_platform,
|
||||||
|
allowed_values=('linux', 'osx', 'windows'),
|
||||||
|
ignorecase=2
|
||||||
|
))
|
||||||
|
opts.Add(EnumVariable(
|
||||||
|
'bits',
|
||||||
|
'Target platform bits',
|
||||||
|
'64' if is64 else '32',
|
||||||
|
('32', '64')
|
||||||
|
))
|
||||||
|
opts.Add(EnumVariable(
|
||||||
|
'target',
|
||||||
|
'Compilation target',
|
||||||
|
'debug',
|
||||||
|
allowed_values=('debug', 'release'),
|
||||||
|
ignorecase=2
|
||||||
|
))
|
||||||
|
|
||||||
|
opts.Update(env)
|
||||||
|
Help(opts.GenerateHelpText(env))
|
||||||
|
|
||||||
# Add PATH to environment so scons can find commands such as g++, etc.
|
# Add PATH to environment so scons can find commands such as g++, etc.
|
||||||
env.AppendENVPath('PATH', os.getenv('PATH'))
|
env.AppendENVPath('PATH', os.getenv('PATH'))
|
||||||
|
|
||||||
# Define our options
|
# Generate godot-cpp bindings.
|
||||||
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
|
# Options such as platform, target, etc. will be forwarded to the godot-cpp SConscript.
|
||||||
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
|
ARGUMENTS['generate_bindings'] = True
|
||||||
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
|
SConscript('external/godot-cpp/SConstruct')
|
||||||
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
|
|
||||||
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'bin/'))
|
|
||||||
opts.Add(PathVariable('target_name', 'The library name.', 'libgodotxtermnative', PathVariable.PathAccept))
|
|
||||||
|
|
||||||
# Local dependency paths, adapt them to your setup
|
|
||||||
godot_headers_path = "external/godot-cpp/godot_headers/"
|
|
||||||
cpp_bindings_path = "external/godot-cpp/"
|
|
||||||
cpp_library = "libgodot-cpp"
|
|
||||||
libtsm_path = "external/libtsm/"
|
|
||||||
|
|
||||||
# only support 64 at this time..
|
# Compile for Linux.
|
||||||
bits = 64
|
if env['platform'] == 'linux':
|
||||||
|
env.Append(CPPDEFINES=['PLATFORM_LINUX'])
|
||||||
|
|
||||||
# Updates the environment with the option variables.
|
|
||||||
opts.Update(env)
|
|
||||||
|
|
||||||
# Process some arguments
|
|
||||||
if env['use_llvm']:
|
|
||||||
env['CC'] = 'clang'
|
|
||||||
env['CXX'] = 'clang++'
|
|
||||||
else:
|
|
||||||
env['CC'] = 'gcc'
|
env['CC'] = 'gcc'
|
||||||
env['CXX'] = 'g++'
|
env['CXX'] = 'g++'
|
||||||
|
|
||||||
if env['p'] != '':
|
env.Append(CCFLAGS=['-fPIC', '-Wwrite-strings'])
|
||||||
env['platform'] = env['p']
|
env.Append(LINKFLAGS=["-Wl,-R'$$ORIGIN'"])
|
||||||
|
|
||||||
if env['platform'] == '':
|
if env['target'] == 'debug':
|
||||||
print("No valid target platform selected.")
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
quit();
|
elif env['target'] == 'release':
|
||||||
|
env.Append(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
# For the reference:
|
if env['bits'] == '64':
|
||||||
# - CCFLAGS are compilation flags shared between C and C++
|
env.Append(CCFLAGS=['-m64'])
|
||||||
# - CFLAGS are for C-specific compilation flags
|
env.Append(LINKFLAGS=['-m64'])
|
||||||
# - CXXFLAGS are for C++-specific compilation flags
|
elif env['bits'] == '32':
|
||||||
# - CPPFLAGS are for pre-processor flags
|
env.Append(CCFLAGS=['-m32'])
|
||||||
# - CPPDEFINES are for pre-processor defines
|
env.Append(LINKFLAGS=['-m32'])
|
||||||
# - LINKFLAGS are for linking flags
|
|
||||||
|
|
||||||
|
# Compile for OSX.
|
||||||
|
elif env['platform'] == 'osx':
|
||||||
|
env.Append(CPPDEFINES=['PLATFORM_OSX'])
|
||||||
|
|
||||||
|
env['CC'] = 'clang'
|
||||||
|
env['CXX'] = 'clang++'
|
||||||
|
|
||||||
|
if env['bits'] == '32':
|
||||||
|
raise ValueError(
|
||||||
|
'Only 64-bit builds are supported for the macOS target.'
|
||||||
|
)
|
||||||
|
|
||||||
# Check our platform specifics
|
|
||||||
if env['platform'] == "osx":
|
|
||||||
env['target_path'] += 'osx/'
|
|
||||||
cpp_library += '.osx'
|
|
||||||
env.Append(CCFLAGS=['-arch', 'x86_64'])
|
env.Append(CCFLAGS=['-arch', 'x86_64'])
|
||||||
env.Append(CXXFLAGS=['-std=c++17'])
|
env.Append(LINKFLAGS=[
|
||||||
env.Append(LINKFLAGS=['-arch', 'x86_64'])
|
'-arch',
|
||||||
if env['target'] in ('debug', 'd'):
|
'x86_64',
|
||||||
env.Append(CCFLAGS=['-g', '-O2'])
|
'-Wl,-undefined,dynamic_lookup',
|
||||||
else:
|
])
|
||||||
env.Append(CCFLAGS=['-g', '-O3'])
|
|
||||||
|
|
||||||
elif env['platform'] in ('x11', 'linux'):
|
if env['target'] == 'debug':
|
||||||
env['target_path'] += 'x11/'
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
cpp_library += '.linux'
|
elif env['target'] == 'release':
|
||||||
env.Append(CCFLAGS=['-fPIC', '-shared'])
|
env.Append(CCFLAGS=['-O3'])
|
||||||
env.Append(CXXFLAGS=['-std=c++17', '-shared', '-pthread'])
|
|
||||||
if env['target'] in ('debug', 'd'):
|
|
||||||
env.Append(CCFLAGS=['-g3', '-Og'])
|
|
||||||
else:
|
|
||||||
env.Append(CCFLAGS=['-g', '-O3'])
|
|
||||||
|
|
||||||
elif env['platform'] == "windows":
|
|
||||||
env['target_path'] += 'win64/'
|
|
||||||
cpp_library += '.windows'
|
|
||||||
# This makes sure to keep the session environment variables on windows,
|
|
||||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
|
||||||
env.Append(ENV=os.environ)
|
|
||||||
|
|
||||||
env.Append(CPPDEFINES=['WIN32', '_WIN32', '_WINDOWS', '_CRT_SECURE_NO_WARNINGS'])
|
# Compile for Windows.
|
||||||
env.Append(CCFLAGS=['-W3', '-GR'])
|
elif env['platform'] == 'windows':
|
||||||
if env['target'] in ('debug', 'd'):
|
env.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
|
||||||
env.Append(CPPDEFINES=['_DEBUG'])
|
|
||||||
env.Append(CCFLAGS=['-EHsc', '-MDd', '-ZI'])
|
|
||||||
env.Append(LINKFLAGS=['-DEBUG'])
|
|
||||||
else:
|
|
||||||
env.Append(CPPDEFINES=['NDEBUG'])
|
|
||||||
env.Append(CCFLAGS=['-O2', '-EHsc', '-MD'])
|
|
||||||
|
|
||||||
if env['target'] in ('debug', 'd'):
|
env.Append(CCFLAGS=['-Wwrite-strings'])
|
||||||
cpp_library += '.debug'
|
env.Append(LINKFLAGS=[
|
||||||
else:
|
'--static',
|
||||||
cpp_library += '.release'
|
'-Wl,--no-undefined',
|
||||||
|
'-static-libgcc',
|
||||||
|
'-static-libstdc++',
|
||||||
|
])
|
||||||
|
|
||||||
cpp_library += '.' + str(bits)
|
if env['target'] == 'debug':
|
||||||
|
env.Append(CCFLAGS=['-Og', '-g'])
|
||||||
|
elif env['target'] == 'release':
|
||||||
|
env.Append(CCFLAGS=['-O3'])
|
||||||
|
|
||||||
# make sure our binding library is properly includes
|
# On Windows.
|
||||||
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/', libtsm_path + 'src/tsm', libtsm_path + 'external'])
|
if host_platform == 'windows':
|
||||||
env.Append(LIBPATH=[cpp_bindings_path + 'bin/', libtsm_path + 'build/src/tsm'])
|
env = env.Clone(tools=['mingw'])
|
||||||
env.Append(LIBS=[cpp_library, 'tsm', 'util']) # Note util used by pseudoterminal, tsm used by terminal.
|
env["SPAWN"] = mySpawn
|
||||||
|
|
||||||
|
# On Linux or MacOS.
|
||||||
|
elif host_platform == 'linux' or host_platform == 'osx':
|
||||||
|
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('external/libtsm/build/src'),
|
||||||
|
Delete('external/libtsm/build/external'),
|
||||||
|
Copy('external/libtsm/build/src', 'external/libtsm/src'),
|
||||||
|
Copy('external/libtsm/build/external', 'external/libtsm/external'),
|
||||||
|
])
|
||||||
|
|
||||||
|
env.Append(CPPPATH=[
|
||||||
|
'external/libtsm/src/shared',
|
||||||
|
'external/libtsm/external',
|
||||||
|
])
|
||||||
|
|
||||||
# tweak this if you want to use different folders, or more folders, to store your source code in.
|
|
||||||
env.Append(CPPPATH=['src/'])
|
|
||||||
sources = []
|
sources = []
|
||||||
sources.append(Glob('src/*.c'))
|
sources.append('external/libtsm/build/src/shared/shl-htable.c')
|
||||||
sources.append(Glob('src/*.cpp'))
|
sources.append(Glob('external/libtsm/build/src/tsm/*.c'))
|
||||||
|
sources.append(Glob('external/libtsm/build/external/wcwidth/*.c'))
|
||||||
|
|
||||||
|
libtsm = env.StaticLibrary(
|
||||||
|
target='external/libtsm/build/bin/libtsm.{}.{}.{}{}'.format(
|
||||||
|
env['platform'],
|
||||||
|
env['target'],
|
||||||
|
env['bits'],
|
||||||
|
env['LIBSUFFIX']
|
||||||
|
), source=sources
|
||||||
|
)
|
||||||
|
Default(libtsm)
|
||||||
|
|
||||||
|
|
||||||
library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources)
|
# Build libgodot-xterm.
|
||||||
|
#env.Append(CCFLAGS=['-std=c++14'])
|
||||||
|
|
||||||
|
env.Append(CPPPATH=[
|
||||||
|
'src/',
|
||||||
|
'external/libtsm/build/src/tsm',
|
||||||
|
'external/godot-cpp/include/',
|
||||||
|
'external/godot-cpp/include/core/',
|
||||||
|
'external/godot-cpp/include/gen/',
|
||||||
|
'external/godot-cpp/godot_headers/'
|
||||||
|
])
|
||||||
|
env.Append(LIBPATH=[
|
||||||
|
'external/godot-cpp/bin/',
|
||||||
|
'external/libtsm/build/bin/',
|
||||||
|
])
|
||||||
|
env.Append(LIBS=[
|
||||||
|
'libgodot-cpp.{}.{}.{}'.format(
|
||||||
|
env['platform'],
|
||||||
|
env['target'],
|
||||||
|
env['bits']
|
||||||
|
),
|
||||||
|
'libtsm.{}.{}.{}'.format(
|
||||||
|
env['platform'],
|
||||||
|
env['target'],
|
||||||
|
env['bits']
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
|
sources = []
|
||||||
|
sources.append('src/libgodotxtermnative.cpp')
|
||||||
|
sources.append('src/terminal.cpp')
|
||||||
|
|
||||||
|
# Psuedoterminal not supported on windows yet.
|
||||||
|
if env['platform'] != 'windows':
|
||||||
|
sources.append('src/pseudoterminal.cpp')
|
||||||
|
env.Append(LIBS=['util'])
|
||||||
|
|
||||||
|
if env['platform'] == 'linux':
|
||||||
|
suffix = "so"
|
||||||
|
elif env['platform'] == 'windows':
|
||||||
|
suffix = "dll"
|
||||||
|
elif env['platform'] == 'osx':
|
||||||
|
suffix = "dylib"
|
||||||
|
|
||||||
|
library = env.SharedLibrary(
|
||||||
|
target='bin/libgodot-xterm.{}.{}.{}'.format(
|
||||||
|
env['platform'],
|
||||||
|
env['bits'],
|
||||||
|
suffix,
|
||||||
|
), source=sources
|
||||||
|
)
|
||||||
Default(library)
|
Default(library)
|
||||||
|
|
||||||
# Generates help for the -h scons option.
|
|
||||||
Help(opts.GenerateHelpText(env))
|
|
||||||
|
|
|
@ -1,37 +1,47 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
||||||
# Get the absolute path to the directory this script is in.
|
# 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 )"
|
||||||
|
|
||||||
|
|
||||||
# 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}
|
||||||
nix-shell shell.nix --pure --run "./build.sh"
|
nix-shell --pure --command "./build.sh $1"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build libtsm.
|
|
||||||
|
# Update git submodules.
|
||||||
LIBTSM_DIR=${NATIVE_DIR}/external/libtsm
|
LIBTSM_DIR=${NATIVE_DIR}/external/libtsm
|
||||||
if [ ! -d "$LIBTSM_DIR" ]; then
|
if [ ! -d "$LIBTSM_DIR" ]; then
|
||||||
cd ${NATIVE_DIR}
|
cd ${NATIVE_DIR}
|
||||||
git submodule update --init --recursive -- $LIBTSM_DIR
|
git submodule update --init --recursive -- $LIBTSM_DIR
|
||||||
fi
|
fi
|
||||||
cd $LIBTSM_DIR
|
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
cmake -DBUILD_SHARED_LIBS=n ..
|
|
||||||
make
|
|
||||||
|
|
||||||
# Build godot-cpp.
|
|
||||||
GODOT_CPP_DIR=${NATIVE_DIR}/external/godot-cpp
|
GODOT_CPP_DIR=${NATIVE_DIR}/external/godot-cpp
|
||||||
if [ ! -d "${GODOT_CPP_DIR}" ]; then
|
if [ ! -d "${GODOT_CPP_DIR}" ]; then
|
||||||
cd ${NATIVE_DIR}
|
cd ${NATIVE_DIR}
|
||||||
git submodule update --init --recursive -- $GODOT_CPP_DIR
|
git submodule update --init --recursive -- $GODOT_CPP_DIR
|
||||||
fi
|
fi
|
||||||
cd $GODOT_CPP_DIR
|
|
||||||
scons platform=linux generate_bindings=yes -j12
|
|
||||||
|
|
||||||
# Build godotxtermnative.
|
|
||||||
|
# Build libgodot-xterm.
|
||||||
cd ${NATIVE_DIR}
|
cd ${NATIVE_DIR}
|
||||||
scons platform=linux
|
case $1 in
|
||||||
|
"release-all")
|
||||||
|
# Cross-compile release build for all platforms.
|
||||||
|
scons platform=linux bits=64 target=release -j$(nproc)
|
||||||
|
if [ $IN_NIX_SHELL ]; then
|
||||||
|
nix-shell --pure --argstr system i686-linux --run 'scons platform=linux bits=32 target=release -j$(nproc)'
|
||||||
|
fi
|
||||||
|
scons platform=windows bits=64 target=release -j$(nproc)
|
||||||
|
#scons platform=windows bits=32 target=release -j$(nproc)
|
||||||
|
#scons platform=osx bits=64 target=release -j$(nproc)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Default: Compile debug build for the current platform.
|
||||||
|
scons -j$(nproc)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
0
addons/godot_xterm/native/dist/.gdignore
vendored
0
addons/godot_xterm/native/dist/.gdignore
vendored
|
@ -1 +0,0 @@
|
||||||
fc0f54c9d43467a3d3e389c4a656f4fa8431a3a4
|
|
|
@ -7,10 +7,16 @@ reloadable=true
|
||||||
|
|
||||||
[entry]
|
[entry]
|
||||||
|
|
||||||
X11.64="res://addons/godot_xterm/native/bin/x11/libgodotxtermnative.so"
|
Server.64="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so"
|
||||||
Server.64="res://addons/godot_xterm/native/bin/x11/libgodotxtermnative.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"
|
||||||
|
Windows.64="res://addons/godot_xterm/native/bin/libgodot-xterm.windows.64.dll"
|
||||||
|
OSX.64="res://addons/godot_xterm/native/bin/libgodot-xterm.osx.64.dylib"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
X11.64=[ ]
|
|
||||||
Server.64=[ ]
|
Server.64=[ ]
|
||||||
|
X11.64=[ ]
|
||||||
|
X11.32=[ ]
|
||||||
|
Windows.64=[ ]
|
||||||
|
OSX.64=[ ]
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
with (import <nixpkgs> {});
|
# Use --argstr system i686-linux to build for 32-bit linux.
|
||||||
|
{ system ? builtins.currentSystem }:
|
||||||
|
with (import <nixpkgs> {
|
||||||
|
inherit system;
|
||||||
|
});
|
||||||
mkShell {
|
mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
binutils.bintools
|
binutils.bintools
|
||||||
cmake
|
cmake
|
||||||
git
|
git
|
||||||
libxkbcommon
|
libxkbcommon
|
||||||
|
nix
|
||||||
pkg-config
|
pkg-config
|
||||||
scons
|
scons
|
||||||
|
] ++ lib.optionals (system == builtins.currentSystem) [
|
||||||
|
# Additional dependencies for cross-compiling for Windows and OSX.
|
||||||
|
clang
|
||||||
|
pkgsCross.mingwW64.buildPackages.gcc
|
||||||
|
pkgsCross.mingw32.buildPackages.gcc
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
|
||||||
#include "pseudoterminal.h"
|
#include "pseudoterminal.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o)
|
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +18,7 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
|
||||||
godot::Godot::nativescript_init(handle);
|
godot::Godot::nativescript_init(handle);
|
||||||
|
|
||||||
godot::register_tool_class<godot::Terminal>();
|
godot::register_tool_class<godot::Terminal>();
|
||||||
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_OSX)
|
||||||
godot::register_class<godot::Pseudoterminal>();
|
godot::register_class<godot::Pseudoterminal>();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ services:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./dockerfiles/nixos
|
dockerfile: ./dockerfiles/nixos
|
||||||
command: /src/addons/godot_xterm/native/build.sh
|
command: /src/addons/godot_xterm/native/build.sh release-all
|
||||||
build-ubuntu:
|
build-ubuntu:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
|
Loading…
Reference in a new issue