Enable compiling 64-bit on Windows using MSVC

Closes #5
This commit is contained in:
Leroy Hopson 2020-11-10 10:04:08 +07:00 committed by Leroy Hopson
parent 399acf00c7
commit 007182b117
11 changed files with 56 additions and 97 deletions

View file

@ -25,3 +25,22 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build for supported platforms on Ubuntu - name: Build for supported platforms on Ubuntu
run: docker-compose run build-ubuntu run: docker-compose run build-ubuntu
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: ilammy/msvc-dev-cmd@v1
- name: Install SCons software construction tool
run: choco install python3 && python -m pip install scons
- name: Build for Windows 64-bit using MSVC
run: |
cd addons/godot_xterm/native/external/godot-cpp
scons platform=windows target=release bits=64 generate_bindings=yes
cd ../../
scons platform=windows target=release bits=64
- uses: actions/upload-artifact@v2
with:
name: bin
path: addons/godot_xterm/native/bin/*.dll

2
.gitmodules vendored
View file

@ -3,4 +3,4 @@
url = https://github.com/godotengine/godot-cpp url = https://github.com/godotengine/godot-cpp
[submodule "addons/godot_xterm/libtsm"] [submodule "addons/godot_xterm/libtsm"]
path = addons/godot_xterm/native/external/libtsm path = addons/godot_xterm/native/external/libtsm
url = https://github.com/Aetf/libtsm url = https://github.com/lihop/libtsm

View file

@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added ### Added
- Support for Windows 64-bit. - Support for Windows 64-bit and compiling on Windows using MSVC.
### Changed ### Changed
- 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. - 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.

View file

@ -63,8 +63,12 @@ addons/godot_xterm/native/build.sh
#### Other Linux Distributions #### Other Linux Distributions
Will probably be similar to the above. When in doubt check the documentation in the submodule repos, the [build.sh] script, and the [SConstruct] file. Will probably be similar to the above. When in doubt check the documentation in the submodule repos, the [build.sh] script, and the [SConstruct] file.
### Windows
Compiling on Windows for 64-bit is supported using [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) version 2019, although other versions might work. See the [Godot documentation](https://docs.godotengine.org/en/stable/development/compiling/compiling_for_windows.html) for more information on setting up the development environment.
See the [github workflow file](.github/workflows/main.yml) for the commands that can be used to build the native libraries.
### Other Operating Systems ### Other Operating Systems
This plugin is not currently supported for other operating systems (e.g. MacOS, Windows). If you manage to build it on one of these platforms, please submit a PR for this readme. This plugin is not currently supported for other operating systems (i.e. MacOS). If you manage to build it on a different platform, please submit a PR for this readme.
## Usage ## Usage

View file

@ -14,56 +14,6 @@ import os
import sys import sys
import subprocess 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. # Try to detect the host platform automatically.
# This is used if no `platform` argument is passed. # This is used if no `platform` argument is passed.
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
@ -177,7 +127,17 @@ elif env['platform'] == 'osx':
elif env['platform'] == 'windows': elif env['platform'] == 'windows':
env.Append(CPPDEFINES=['PLATFORM_WINDOWS']) env.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
env.Append(CCFLAGS=['-Wwrite-strings']) # On Windows using MSVC.
if host_platform == 'windows':
env.Append(LINKFLAGS=['/W3', '/GR'])
if env['target'] == 'debug':
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++14', '-Wwrite-strings'])
env.Append(LINKFLAGS=[ env.Append(LINKFLAGS=[
'--static', '--static',
'-Wl,--no-undefined', '-Wl,--no-undefined',
@ -190,13 +150,6 @@ elif env['platform'] == 'windows':
elif env['target'] == 'release': elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3']) env.Append(CCFLAGS=['-O3'])
# On Windows.
if host_platform == 'windows':
env = env.Clone(tools=['mingw'])
env["SPAWN"] = mySpawn
# On Linux or MacOS.
elif host_platform == 'linux' or host_platform == 'osx':
if env['bits'] == '64': if env['bits'] == '64':
env['CC'] = 'x86_64-w64-mingw32-gcc' env['CC'] = 'x86_64-w64-mingw32-gcc'
env['CXX'] = 'x86_64-w64-mingw32-g++' env['CXX'] = 'x86_64-w64-mingw32-g++'

@ -1 +1 @@
Subproject commit f70e37982f382b03c6939dac3d5f814450bda253 Subproject commit 1f3ae2bc36236136b8ed328b0c64ed954beac33f

View file

@ -11,6 +11,7 @@ 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.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" 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" 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" OSX.64="res://addons/godot_xterm/native/bin/libgodot-xterm.osx.64.dylib"
[dependencies] [dependencies]
@ -19,4 +20,5 @@ Server.64=[ ]
X11.64=[ ] X11.64=[ ]
X11.32=[ ] X11.32=[ ]
Windows.64=[ ] Windows.64=[ ]
Windows.32=[ ]
OSX.64=[ ] OSX.64=[ ]

View file

View file

@ -8,28 +8,7 @@
using namespace godot; using namespace godot;
// Use xterm default for default color palette. const struct Terminal::cell Terminal::empty_cell = {{0, 0, 0, 0, 0}, {}};
const uint8_t Terminal::default_color_palette[TSM_COLOR_NUM][3] = {
[TSM_COLOR_BLACK] = {0x00, 0x00, 0x00},
[TSM_COLOR_RED] = {0x80, 0x00, 0x00},
[TSM_COLOR_GREEN] = {0x00, 0x80, 0x00},
[TSM_COLOR_YELLOW] = {0x80, 0x80, 0x00},
[TSM_COLOR_BLUE] = {0x00, 0x00, 0x80},
[TSM_COLOR_MAGENTA] = {0x80, 0x00, 0x80},
[TSM_COLOR_CYAN] = {0x00, 0x80, 0x80},
[TSM_COLOR_LIGHT_GREY] = {0xc0, 0xc0, 0xc0},
[TSM_COLOR_DARK_GREY] = {0x80, 0x80, 0x80},
[TSM_COLOR_LIGHT_RED] = {0xff, 0x00, 0x00},
[TSM_COLOR_LIGHT_GREEN] = {0x00, 0xff, 0x00},
[TSM_COLOR_LIGHT_YELLOW] = {0xff, 0xff, 0x00},
[TSM_COLOR_LIGHT_BLUE] = {0x00, 0x00, 0xff},
[TSM_COLOR_LIGHT_MAGENTA] = {0xff, 0x00, 0xff},
[TSM_COLOR_LIGHT_CYAN] = {0x00, 0xff, 0xff},
[TSM_COLOR_WHITE] = {0xff, 0xff, 0xff},
[TSM_COLOR_FOREGROUND] = {0xff, 0xff, 0xff},
[TSM_COLOR_BACKGROUND] = {0x00, 0x00, 0x00},
};
const std::map<std::pair<int64_t, int64_t>, uint32_t> Terminal::keymap = { const std::map<std::pair<int64_t, int64_t>, uint32_t> Terminal::keymap = {
@ -387,9 +366,6 @@ void Terminal::_draw()
void Terminal::update_color_palette() void Terminal::update_color_palette()
{ {
// Start with a copy of the default color palette
memcpy(color_palette, Terminal::default_color_palette, sizeof(Terminal::default_color_palette));
/* Generate color palette based on theme */ /* Generate color palette based on theme */
// Converts a color from the Control's theme to one that can // Converts a color from the Control's theme to one that can

View file

@ -20,7 +20,8 @@ namespace godot
{ {
char ch[5]; char ch[5];
struct tsm_screen_attr attr; struct tsm_screen_attr attr;
} empty_cell = {ch : {0, 0, 0, 0, 0}, attr : {}}; };
static const struct cell empty_cell;
public: public:
typedef std::vector<std::vector<struct cell>> Cells; typedef std::vector<std::vector<struct cell>> Cells;

View file

@ -130,6 +130,10 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
$Terminal.grab_focus() $Terminal.grab_focus()
scene.queue_free() scene.queue_free()
"Terminal": "Terminal":
if OS.get_name() == "Windows":
return OS.call_deferred("alert", "Psuedoterminal node currently"
+ " uses pty.h but needs to use either winpty or conpty"
+ " to work on Windows.", "Terminal not Supported on Windows")
var scene = item.scene.instance() var scene = item.scene.instance()
var pty = scene.get_node("Pseudoterminal") var pty = scene.get_node("Pseudoterminal")
get_tree().get_root().add_child(scene) get_tree().get_root().add_child(scene)