mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-24 10:20:24 +01:00
Support building for Windows using MinGW compiler
- Adds docker support for building Windows binaries on Linux. - Update libuv to version 1.44.1. - Use MinGW compiled 64bit Windows binaries for distribution.
This commit is contained in:
parent
cceffd4edf
commit
e4fdf70bca
10 changed files with 115 additions and 36 deletions
2
.github/actions/cache-submodules/action.yaml
vendored
2
.github/actions/cache-submodules/action.yaml
vendored
|
@ -17,7 +17,7 @@ runs:
|
||||||
working-directory: addons/godot_xterm/native/thirdparty
|
working-directory: addons/godot_xterm/native/thirdparty
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cache_version=1 # Increment this number to invalidate the cache.
|
cache_version=2 # Increment this number to invalidate the cache.
|
||||||
godot_cpp_rev=$(git ls-tree HEAD godot-cpp --object-only)
|
godot_cpp_rev=$(git ls-tree HEAD godot-cpp --object-only)
|
||||||
libuv_rev=$(git ls-tree HEAD libuv --object-only)
|
libuv_rev=$(git ls-tree HEAD libuv --object-only)
|
||||||
libtsm_rev=$(git ls-tree HEAD libtsm --object-only)
|
libtsm_rev=$(git ls-tree HEAD libtsm --object-only)
|
||||||
|
|
22
.github/workflows/main.yml
vendored
22
.github/workflows/main.yml
vendored
|
@ -14,13 +14,17 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_docker:
|
build_docker:
|
||||||
name: 'Build Docker (linux, ${{ matrix.target }}, ${{ matrix.bits }})'
|
name: 'Build Docker (${{ matrix.platform }}, ${{ matrix.target }}, ${{ matrix.bits }})'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
platform: [ linux, windows ]
|
||||||
target: [ release, debug ]
|
target: [ release, debug ]
|
||||||
bits: [ 64, 32 ]
|
bits: [ 64, 32 ]
|
||||||
|
exclude:
|
||||||
|
- platform: windows
|
||||||
|
bits: 32 # 32-bit MinGW builds not currently working.
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
|
@ -29,7 +33,7 @@ jobs:
|
||||||
uses: ./.github/actions/cache-submodules
|
uses: ./.github/actions/cache-submodules
|
||||||
id: cache-submodules
|
id: cache-submodules
|
||||||
with:
|
with:
|
||||||
platform: linux
|
platform: ${{ matrix.platform }}
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
bits: ${{ matrix.bits }}
|
bits: ${{ matrix.bits }}
|
||||||
- name: Pull docker images
|
- name: Pull docker images
|
||||||
|
@ -42,20 +46,21 @@ jobs:
|
||||||
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: |
|
run: |
|
||||||
docker-compose build godot-cpp-linux
|
docker-compose build godot-cpp-${{ matrix.platform }}
|
||||||
UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} godot-cpp-linux
|
UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} godot-cpp-${{ matrix.platform }}
|
||||||
- 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 BITS=${{ matrix.bits }} libuv-${{ matrix.platform }}
|
||||||
- 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 BITS=${{ matrix.bits }} libgodot-xterm-${{ matrix.platform }}
|
||||||
- name: Upload binaries
|
- name: Upload binaries
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: libgodot-xterm-${{ matrix.target }}
|
name: libgodot-xterm-${{ matrix.target }}
|
||||||
path: |
|
path: |
|
||||||
|
addons/godot_xterm/native/bin/*.dll
|
||||||
addons/godot_xterm/native/bin/*.so
|
addons/godot_xterm/native/bin/*.so
|
||||||
|
|
||||||
build_native:
|
build_native:
|
||||||
|
@ -125,7 +130,7 @@ jobs:
|
||||||
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2
|
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2
|
||||||
- name: Setup cmake
|
- name: Setup cmake
|
||||||
if: steps.cache-submodules.outputs.cache-hit != 'true'
|
if: steps.cache-submodules.outputs.cache-hit != 'true'
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1
|
||||||
with:
|
with:
|
||||||
cmake-version: '3.23.2'
|
cmake-version: '3.23.2'
|
||||||
use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-latest' }}
|
use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-latest' }}
|
||||||
|
@ -160,13 +165,14 @@ 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
|
||||||
|
if: ${{ matrix.os != 'windows-latest' && matrix.bits != '64' }}
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: libgodot-xterm-${{ matrix.target }}
|
name: libgodot-xterm-${{ matrix.target }}
|
||||||
path: |
|
path: |
|
||||||
|
addons/godot_xterm/native/bin/*.dll
|
||||||
addons/godot_xterm/native/bin/*.wasm
|
addons/godot_xterm/native/bin/*.wasm
|
||||||
addons/godot_xterm/native/bin/*.dylib
|
addons/godot_xterm/native/bin/*.dylib
|
||||||
addons/godot_xterm/native/bin/*.dll
|
|
||||||
|
|
||||||
html5_export:
|
html5_export:
|
||||||
name: 'HTML5 Export'
|
name: 'HTML5 Export'
|
||||||
|
|
|
@ -62,6 +62,8 @@ opts.Add(EnumVariable(
|
||||||
allowed_values=('debug', 'release'),
|
allowed_values=('debug', 'release'),
|
||||||
ignorecase=2
|
ignorecase=2
|
||||||
))
|
))
|
||||||
|
opts.Add(BoolVariable("use_mingw",
|
||||||
|
"Use the MinGW compiler instead of MSVC - only effective on Windows", False))
|
||||||
opts.Add(EnumVariable("macos_arch", "Target macOS architecture",
|
opts.Add(EnumVariable("macos_arch", "Target macOS architecture",
|
||||||
"universal", ["universal", "x86_64", "arm64"]))
|
"universal", ["universal", "x86_64", "arm64"]))
|
||||||
opts.Add(BoolVariable(
|
opts.Add(BoolVariable(
|
||||||
|
@ -255,7 +257,7 @@ env.Append(LIBS=[
|
||||||
env['target'],
|
env['target'],
|
||||||
'wasm' if env['platform'] == 'javascript' else env['macos_arch'] if (
|
'wasm' if env['platform'] == 'javascript' else env['macos_arch'] if (
|
||||||
env['macos_arch'] != 'universal' and env['platform'] == 'osx') else env['bits'],
|
env['macos_arch'] != 'universal' and env['platform'] == 'osx') else env['bits'],
|
||||||
env['LIBSUFFIX'],
|
'.a' if env['use_mingw'] else env['LIBSUFFIX'],
|
||||||
)),
|
)),
|
||||||
env.File('thirdparty/libtsm/build/bin/libtsm.{}.{}.{}{}'.format(
|
env.File('thirdparty/libtsm/build/bin/libtsm.{}.{}.{}{}'.format(
|
||||||
env['platform'],
|
env['platform'],
|
||||||
|
@ -280,7 +282,18 @@ else:
|
||||||
sources.append('src/node_pty/unix/pty.cc')
|
sources.append('src/node_pty/unix/pty.cc')
|
||||||
env.Append(LIBS=['util', env.File('thirdparty/libuv/build/libuv_a.a')])
|
env.Append(LIBS=['util', env.File('thirdparty/libuv/build/libuv_a.a')])
|
||||||
else:
|
else:
|
||||||
|
#sources.append('src/node_pty/win/path_util.cc')
|
||||||
#sources.append('src/node_pty/win/conpty.cc')
|
#sources.append('src/node_pty/win/conpty.cc')
|
||||||
|
#sources.append('src/node_pty/win/winpty.cc')
|
||||||
|
if env['use_mingw'] and not env["disable_pty"]:
|
||||||
|
env.Append(LIBS=[
|
||||||
|
env.File('thirdparty/libuv/build/libuv.dll.a'),
|
||||||
|
'-lshlwapi'
|
||||||
|
])
|
||||||
|
Execute([
|
||||||
|
Copy('bin/libuv.dll', 'thirdparty/libuv/build/libuv.dll'),
|
||||||
|
])
|
||||||
|
else:
|
||||||
env.Append(LIBS=[
|
env.Append(LIBS=[
|
||||||
env.File('thirdparty/libuv/build/{}/uv_a.lib'.format(env["target"].capitalize())),
|
env.File('thirdparty/libuv/build/{}/uv_a.lib'.format(env["target"].capitalize())),
|
||||||
'Advapi32.lib',
|
'Advapi32.lib',
|
||||||
|
|
|
@ -36,7 +36,7 @@ services:
|
||||||
- |
|
- |
|
||||||
target=$${TARGET:-release}
|
target=$${TARGET:-release}
|
||||||
bits=$${BITS:-'64'}
|
bits=$${BITS:-'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"
|
||||||
|
@ -57,3 +57,57 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- .:/godot-xterm
|
- .:/godot-xterm
|
||||||
working_dir: /godot-xterm
|
working_dir: /godot-xterm
|
||||||
|
godot-cpp-windows:
|
||||||
|
user: ${UID_GID}
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: windows.Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./thirdparty/godot-cpp:/godot-cpp
|
||||||
|
working_dir: /godot-cpp
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
scons platform=windows use_mingw=yes generate_bindings=yes target=$${TARGET:-release} bits=$${BITS:-64} -j$$(nproc)
|
||||||
|
libuv-windows:
|
||||||
|
user: ${UID_GID}
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: windows.Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./thirdparty/libuv:/libuv
|
||||||
|
working_dir: /libuv
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
target=$${TARGET:-release}
|
||||||
|
bits=$${BITS:-'64'}
|
||||||
|
mkdir build 2>/dev/null
|
||||||
|
args="-DCMAKE_BUILD_TYPE=$$target \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE"
|
||||||
|
if [[ $$bits -eq 32 ]]; then
|
||||||
|
args="$$args -DCMAKE_SYSTEM_PROCESSOR=i686 -DCMAKE_C_FLAGS=-m32"
|
||||||
|
args="$$args -DCMAKE_TOOLCHAIN_FILE=/mingw-w64-i686.cmake"
|
||||||
|
else
|
||||||
|
args="$$args -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_FLAGS="
|
||||||
|
args="$$args -DCMAKE_TOOLCHAIN_FILE=/mingw-w64-x86_64.cmake"
|
||||||
|
fi
|
||||||
|
pushd build
|
||||||
|
cmake .. $$args
|
||||||
|
popd
|
||||||
|
cmake --build build
|
||||||
|
libgodot-xterm-windows:
|
||||||
|
user: ${UID_GID}
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: windows.Dockerfile
|
||||||
|
volumes:
|
||||||
|
- .:/godot-xterm
|
||||||
|
working_dir: /godot-xterm
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- scons platform=windows use_mingw=yes target=$${TARGET:-release} bits=$${BITS:-64} -j$$(nproc)
|
||||||
|
|
|
@ -18,7 +18,7 @@ X11.32="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.32.so"
|
||||||
|
|
||||||
HTML5.wasm32=[ ]
|
HTML5.wasm32=[ ]
|
||||||
OSX.64=[ ]
|
OSX.64=[ ]
|
||||||
Windows.64=[ ]
|
Windows.64=[ "res://addons/godot_xterm/native/bin/libuv.dll" ]
|
||||||
Windows.32=[ ]
|
Windows.32=[ ]
|
||||||
X11.64=[ ]
|
X11.64=[ ]
|
||||||
X11.32=[ ]
|
X11.32=[ ]
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
#include "node_pty/unix/pty.h"
|
#include "node_pty/unix/pty.h"
|
||||||
#endif
|
#endif // defined(__linux__) || defined(__APPLE__)
|
||||||
#if defined(__WIN32)
|
#if defined(__WIN32)
|
||||||
//#include "node_pty/win/conpty.h"
|
//#include "node_pty/win/conpty.h"
|
||||||
#endif
|
//#include "node_pty/win/winpty.h"
|
||||||
#endif
|
#endif // defined(__WIN32)
|
||||||
|
#endif // !defined(_PTY_DISABLED)
|
||||||
|
|
||||||
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) {
|
||||||
godot::Godot::gdnative_init(o);
|
godot::Godot::gdnative_init(o);
|
||||||
|
@ -31,6 +32,7 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
|
||||||
#endif
|
#endif
|
||||||
#if defined(__WIN32)
|
#if defined(__WIN32)
|
||||||
// godot::register_tool_class<godot::ConPTY>();
|
// godot::register_tool_class<godot::ConPTY>();
|
||||||
|
// godot::register_tool_class<godot::WinPTY>();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,16 @@
|
||||||
* Copyright (c) 2013-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
* Copyright (c) 2013-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
||||||
* Copyright (c) 2016, Daniel Imms (MIT License).
|
* Copyright (c) 2016, Daniel Imms (MIT License).
|
||||||
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
||||||
|
* Copyright (c) 2022, Leroy Hopson (MIT License).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Shlwapi.h> // PathCombine
|
|
||||||
#include <nan.h>
|
|
||||||
|
|
||||||
#include "path_util.h"
|
#include "path_util.h"
|
||||||
|
#include <shlwapi.h> // PathCombine
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace path_util {
|
namespace path_util {
|
||||||
|
|
||||||
const wchar_t *to_wstring(const Nan::Utf8String &str) {
|
const wchar_t *to_wstring(String str) { return str.unicode_str(); }
|
||||||
const char *bytes = *str;
|
|
||||||
unsigned int sizeOfStr = MultiByteToWideChar(CP_UTF8, 0, bytes, -1, NULL, 0);
|
|
||||||
wchar_t *output = new wchar_t[sizeOfStr];
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, bytes, -1, output, sizeOfStr);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool file_exists(std::wstring filename) {
|
bool file_exists(std::wstring filename) {
|
||||||
DWORD attr = ::GetFileAttributesW(filename.c_str());
|
DWORD attr = ::GetFileAttributesW(filename.c_str());
|
||||||
|
|
|
@ -2,18 +2,22 @@
|
||||||
* Copyright (c) 2013-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
* Copyright (c) 2013-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
||||||
* Copyright (c) 2016, Daniel Imms (MIT License).
|
* Copyright (c) 2016, Daniel Imms (MIT License).
|
||||||
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
||||||
|
* Copyright (c) 2022, Leroy Hopson (MIT License).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NODE_PTY_PATH_UTIL_H_
|
#ifndef NODE_PTY_PATH_UTIL_H_
|
||||||
#define NODE_PTY_PATH_UTIL_H_
|
#define NODE_PTY_PATH_UTIL_H_
|
||||||
|
|
||||||
#include <nan.h>
|
#include <String.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define MAX_ENV 65536
|
#define MAX_ENV 65536
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
namespace path_util {
|
namespace path_util {
|
||||||
|
|
||||||
const wchar_t *to_wstring(const Nan::Utf8String &str);
|
const wchar_t *to_wstring(String str);
|
||||||
bool file_exists(std::wstring filename);
|
bool file_exists(std::wstring filename);
|
||||||
std::wstring get_shell_path(std::wstring filename);
|
std::wstring get_shell_path(std::wstring filename);
|
||||||
|
|
||||||
|
|
2
addons/godot_xterm/native/thirdparty/libuv
vendored
2
addons/godot_xterm/native/thirdparty/libuv
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit f9ad802fa5dd5afe6730f8e00cfdbf98f1d7a969
|
Subproject commit e8b7eb6908a847ffbe6ab2eec7428e43a0aa53a2
|
6
addons/godot_xterm/native/windows.Dockerfile
Normal file
6
addons/godot_xterm/native/windows.Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FROM ubuntu:latest
|
||||||
|
RUN apt-get update -y
|
||||||
|
RUN apt-get install -y cmake mingw-w64 scons
|
||||||
|
RUN apt-get install -y wget && \
|
||||||
|
wget https://gist.githubusercontent.com/peterspackman/8cf73f7f12ba270aa8192d6911972fe8/raw/9d775cdff025ab12bdffe9e9a195e306a429bb86/mingw-w64-x86_64.cmake
|
||||||
|
RUN sed 's/x86_64-w64-mingw32/i686-w64-mingw32/g' /mingw-w64-x86_64.cmake > /mingw-w64-i686.cmake
|
Loading…
Reference in a new issue