Add option to build inside docker container

This allows us to target older versions of GLIBC.
This commit is contained in:
Leroy Hopson 2022-05-03 12:44:40 +07:00
parent ded2ced89b
commit 6b512bd525
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
7 changed files with 100 additions and 15 deletions

View file

@ -19,8 +19,56 @@ env:
LIBUV_CACHE_VERSION: 1
jobs:
build:
name: 'Build'
build_docker:
name: 'Build Docker'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [ release, debug ]
bits: [ 64, 32 ]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Get godot-cpp submodule commit hash
shell: bash
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo ::set-env name=GODOT_CPP_COMMIT_HASH::$(git ls-tree HEAD addons/godot_xterm/native/thirdparty/godot-cpp -l | cut -d\ -f3)
- name: Cache godot-cpp bindings
uses: actions/cache@v2
id: cache
env:
cache-name: cache-godot-cpp
with:
path: addons/godot_xterm/native/thirdparty/godot-cpp
key: godot-cpp-${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.bits }}-${{ env.GODOT_CPP_COMMIT_HASH }}-v${{ env.GODOT_CPP_CACHE_VERSION }}
- name: Get libuv submodule commit hash
shell: bash
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo ::set-env name=LIBUV_COMMIT_HASH::$(git ls-tree HEAD addons/godot_xterm/native/thirdparty/libuv -l | cut -d\ -f3)
# Build inside docker container in order to target older GLIBC versions.
- name: Run build script
run: |
cd addons/godot_xterm/native
/bin/bash ./build.sh --target ${{ matrix.target }} --bits ${{ matrix.bits }} --docker
- name: Upload build artifacts
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
@ -154,10 +202,10 @@ jobs:
- name: Upload build artifacts
uses: actions/upload-artifact@v2
if: ${{ matrix.platform != 'linux' }}
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
@ -219,7 +267,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
@ -254,7 +302,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

@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `--docker` option to `build.sh` script, in order to build Linux binaries inside a docker container with an older GLIBC version.
### Changed
- GitHub Actions workflow to build Linux debug/release binaries inside docker container in order to target older GLIBC versions.
### Fixed
- Registered `pipe.close()` method, so `kill()` can be called when using unix PTY node.

View file

@ -0,0 +1 @@
*

View file

@ -0,0 +1,4 @@
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

View file

@ -277,7 +277,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

@ -11,26 +11,43 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
-b|--bits)
bits="$2"
shift
shift
;;
--disable-pty)
disable_pty="yes"
shift
;;
--docker)
docker="yes"
shift
;;
*)
echo "Usage: ./build.sh [-t|--target <release|debug>] [--disable_pty]";
echo "Usage: ./build.sh [-t|--target <release|debug>] [-b|--bits <32|64>] [--disable_pty] [--docker]";
exit 128
shift
;;
esac
done
# Set defaults.
target=${target:-debug}
bits=${bits:-64}
disable_pty=${disable_pty:-no}
nproc=$(nproc || sysctl -n hw.ncpu)
#GODOT_DIR 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 )"
if [ -n "$docker" ]; then
# Run build script inside docker container.
cd ${NATIVE_DIR}
UID_GID="0:0" TARGET=$target BITS=$bits docker-compose build linux
UID_GID="$(id -u):$(id -g)" TARGET=$target BITS=$bits docker-compose run linux
exit 0
fi
# Run script inside a nix shell if it is available.
if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then
@ -39,7 +56,6 @@ if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then
exit
fi
# Update git submodules.
updateSubmodules() {
eval $1=$2 # E.g LIBUV_DIR=${NATIVE_DIR}/thirdparty/libuv
@ -54,15 +70,14 @@ updateSubmodules LIBUV_DIR ${NATIVE_DIR}/thirdparty/libuv
updateSubmodules LIBTSM_DIR ${NATIVE_DIR}/thirdparty/libtsm
updateSubmodules GODOT_CPP_DIR ${NATIVE_DIR}/thirdparty/godot-cpp
# Build godot-cpp bindings.
cd ${GODOT_CPP_DIR}
echo "scons generate_bindings=yes target=$target -j$nproc"
scons generate_bindings=yes target=$target -j$nproc
scons generate_bindings=yes target=$target bits=$bits -j$nproc
# Build libuv as a static library.
cd ${LIBUV_DIR}
mkdir build || true
mkdir -p build
cd build
args="-DCMAKE_BUILD_TYPE=$target -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE"
if [ "$target" == "release" ]; then
@ -70,13 +85,14 @@ if [ "$target" == "release" ]; then
else
args="$args -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL"
fi
if [[ "$bits" -eq 32 ]]; then args="$args -DCMAKE_SYSTEM_PROCESSOR=i686 -DCMAKE_C_FLAGS=-m32"; fi
cmake .. $args
cd ..
cmake --build build --config $target -j$nproc
cmake --build build --config $target
# Build libgodot-xterm.
cd ${NATIVE_DIR}
scons target=$target disable_pty=$disable_pty -j$nproc
scons target=$target bits=$bits disable_pty=$disable_pty -j$nproc
# Use Docker to build libgodot-xterm javascript.
if [ -x "$(command -v docker-compose)" ]; then

View file

@ -12,3 +12,14 @@ services:
scons platform=javascript target=$${TARGET:-debug} -j$$(nproc)
cd /src
scons platform=javascript target=$${TARGET:-debug} -j$$(nproc)
linux:
build: .
user: ${UID_GID}
volumes:
- .:/src
command:
- /bin/bash
- -c
- |
cd /src
/bin/bash ./build.sh --target ${TARGET} --bits ${BITS}