Add Docker build for Linux

Adds support for building Linux binaries inside a docker container in
order to target an older version of GLIBC.

Updates GitHub Actions workflow to use it.

As a result the minimum version of GLIBC that Linux users need to have
installed on their system is 2.17 which was released in 2012.
This commit is contained in:
Leroy Hopson 2022-06-01 10:26:03 +07:00
parent 3670856851
commit 3fdc9ef27e
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
6 changed files with 111 additions and 27 deletions

View file

@ -17,18 +17,59 @@ env:
GODOT_CACHE_VERSION: 1
jobs:
build:
name: 'Build'
build_docker:
name: 'Build Docker (linux, ${{ matrix.target }}, ${{ matrix.bits }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [ release, debug ]
bits: [ 64, 32 ]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache submodules
uses: ./.github/actions/cache-submodules
id: cache-submodules
with:
platform: linux
target: ${{ matrix.target }}
bits: ${{ matrix.bits }}
- name: Pull docker images
run: docker-compose pull
working-directory: addons/godot_xterm/native
- name: Cache docker image layers
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
- name: Build godot-cpp bindings
if: steps.cache-submodules.outputs.cache-hit != 'true'
working-directory: addons/godot_xterm/native
run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} godot-cpp-linux
- name: Build libuv
if: steps.cache-submodules.outputs.cache-hit != 'true'
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
- name: Build libgodot-xterm
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
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: libgodot-xterm-${{ matrix.target }}
path: |
addons/godot_xterm/native/bin/*.so
build_native:
name: 'Build Native'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
platform: [ linux, javascript, osx, windows ]
platform: [ javascript, osx, windows ]
target: [ release, debug ]
bits: [ 64, 32 ]
include:
- platform: linux
os: ubuntu-latest
- platform: javascript
os: ubuntu-latest
- platform: osx
@ -59,40 +100,31 @@ jobs:
with:
path: addons/godot_xterm/native/.emcache
key: emsdk-cache-${{ matrix.target }}-v${{ env.EMSCRIPTEN_CACHE_VERSION }}
# Ubuntu-specific steps.
- name: Install ubuntu build dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update && sudo apt-get install -y scons gcc-multilib g++-multilib
# JavaScript-specific steps.
- name: Install javascript build dependencies
if: ${{ matrix.platform == 'javascript' }}
uses: mymindstorm/setup-emsdk@v11
with:
version: 3.1.5
actions-cache-folder: emsdk-cache-${{ matrix.target }}
# MacOS-specific steps.
- name: Install additional javascript build dependencies
if: ${{ matrix.platform == 'javascript' }}
run: sudo apt-get update && sudo apt-get install -y scons gcc-multilib g++-multilib
- name: Install additional macos build dependencies
if: ${{ matrix.os == 'macos-latest' }}
run: brew install scons
# Windows-specific steps.
- name: Install additional windows build dependencies
if: ${{ matrix.os == 'windows-latest' }}
run: python -m pip install scons
- uses: ilammy/msvc-dev-cmd@v1.9.0
- name: Setup MSVC command prompt
uses: ilammy/msvc-dev-cmd@v1.9.0
if: ${{ matrix.os == 'windows-latest' }}
with:
arch: win${{ matrix.bits }}
- name: Build godot-cpp bindings
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: |
cd addons/godot_xterm/native/thirdparty/godot-cpp
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2
- name: Setup cmake
if: steps.cache-submodules.outputs.cache-hit != 'true'
uses: jwlawson/actions-setup-cmake@v1.9
@ -125,23 +157,19 @@ jobs:
cd ..
fi
cmake --build build --config $TARGET
- name: Build libgodot-xterm
run: |
cd addons/godot_xterm/native
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} -j2
- name: Upload build artifacts
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: libgodot-xterm-${{ matrix.target }}
path: |
addons/godot_xterm/native/bin/*.so
addons/godot_xterm/native/bin/*.wasm
addons/godot_xterm/native/bin/*.dylib
addons/godot_xterm/native/bin/*.dll
# GDNative HTML5 export templates aren't provided so we must build them
export_template:
name: 'Export Template'
@ -198,7 +226,7 @@ jobs:
html5_export:
name: 'HTML5 Export'
needs: [ build, export_template ]
needs: [ build_docker, build_native, export_template ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -233,7 +261,7 @@ jobs:
test:
name: 'Test'
needs: [ install_plugins, build ]
needs: [ install_plugins, build_docker, build_native ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false

View file

@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`libgodot-xterm.osx.64.dylib` is now a universal binary that runs natively
on both x86_64 and arm64.
### Changed
- Linux binaries now support systems with older GLIBC versions. By building the
binaries inside a docker container with an older GLIBC version, the minimum
required GLIBC version is now 2.17 which was released in 2012.
### Fixed
- The `kill()` method of unix PTY node can now be called without error as the underlying
`pipe.close()` method of the gdnative library is now registered.

View file

@ -0,0 +1 @@
*

View file

@ -282,7 +282,7 @@ else:
else:
#sources.append('src/node_pty/win/conpty.cc')
env.Append(LIBS=[
env.File(f'thirdparty/libuv/build/{env["target"].capitalize()}/uv_a.lib'),
env.File('thirdparty/libuv/build/{}/uv_a.lib'.format(env["target"].capitalize())),
'Advapi32.lib',
'Iphlpapi.lib',
'user32.lib',

View file

@ -12,3 +12,46 @@ services:
scons platform=javascript target=$${TARGET:-debug} -j$$(nproc)
cd /src
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:
user: ${UID_GID}
build:
context: .
dockerfile: linux.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";
else
args="$$args -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_FLAGS=";
fi
pushd build
cmake .. $$args
popd
cmake --build build
libgodot-xterm-linux:
user: ${UID_GID}
build:
context: .
dockerfile: linux.Dockerfile
volumes:
- .:/godot-xterm
working_dir: /godot-xterm

View file

@ -0,0 +1,7 @@
# Uses an old version of Ubuntu in order to target an old version of GLIBC so users
# with older versions of GLIBC installed on their systems can use the library.
FROM kroggen/ubuntu-16.04-gcc
RUN apt-get update -y
RUN apt-get install -y python3 python3-pip gcc-multilib g++-multilib
RUN pip3 install scons
CMD scons platform=linux generate_bindings=yes target=${TARGET:-release} bits=${BITS:-64} -j$(nproc)