Skip to content

Commit c36673c

Browse files
committed
GITHUB: Prepare image to be used in github actions to create a Windows release.
1 parent ff0e268 commit c36673c

3 files changed

Lines changed: 98 additions & 15 deletions

File tree

.github/workflows/build-image.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build MinGW cross-compile image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'Dockerfile'
9+
- 'deps/**'
10+
- 'patch/**'
11+
- 'entry.sh'
12+
- 'functions.sh'
13+
- '.gitmodules'
14+
- 'pywine'
15+
- '.github/workflows/build-image.yml'
16+
workflow_dispatch:
17+
18+
env:
19+
IMAGE: ghcr.io/swi-prolog/swipl-mingw-build
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
28+
steps:
29+
- name: Free disk space
30+
uses: jlumbroso/free-disk-space@main
31+
with:
32+
tool-cache: true
33+
android: true
34+
dotnet: true
35+
haskell: true
36+
large-packages: true
37+
docker-images: false
38+
swap-storage: true
39+
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
submodules: recursive
44+
45+
- name: Log in to GHCR
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Set up Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Build and push image
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
push: true
60+
tags: |
61+
${{ env.IMAGE }}:latest
62+
${{ env.IMAGE }}:sha-${{ github.sha }}
63+
cache-from: type=registry,ref=${{ env.IMAGE }}:cache
64+
cache-to: type=registry,ref=${{ env.IMAGE }}:cache,mode=max

entry.sh

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22

33
export SWIPL_SOURCE_DIR=/home/swipl/src/swipl-devel
4-
cd $SWIPL_SOURCE_DIR
54

65
unset DISPLAY
76
unset WAYLAND_DISPLAY
@@ -19,13 +18,31 @@ if [ ! -d "$WINEPREFIX/system.reg" ]; then
1918
wineboot -u
2019
fi
2120

22-
if [ ! -f VERSION ]; then
23-
echo "Can not find SWI-Prolog source. Please edit SWIPLSRC in Makefile"
24-
echo "and re-try"
25-
exit 1
26-
fi
21+
# Clone the SWI-Prolog source tree into the container. Used by the
22+
# GitHub Action so the build never touches the host filesystem and we
23+
# do not have to worry about UID/GID mapping or SELinux labels.
24+
clone_swipl() {
25+
local url=$1 ref=$2
26+
27+
if [ -z "$url" ] || [ -z "$ref" ]; then
28+
echo "--win64-from-git requires URL and REF arguments" >&2
29+
exit 1
30+
fi
31+
32+
mkdir -p "$(dirname "$SWIPL_SOURCE_DIR")"
33+
rm -rf "$SWIPL_SOURCE_DIR"
34+
git clone --recurse-submodules --shallow-submodules \
35+
--branch "$ref" --depth 1 \
36+
"$url" "$SWIPL_SOURCE_DIR"
37+
}
2738

2839
if [ -z "$*" ]; then
40+
if [ ! -f "$SWIPL_SOURCE_DIR/VERSION" ]; then
41+
echo "Can not find SWI-Prolog source. Please edit SWIPLSRC in Makefile"
42+
echo "and re-try"
43+
exit 1
44+
fi
45+
cd "$SWIPL_SOURCE_DIR"
2946
echo "Starting interactive shell for cross-compiling SWI-Prolog"
3047
echo "Commands:"
3148
echo ""
@@ -42,15 +59,23 @@ else
4259
while [ ! -z "$1" -a $done = false ]; do
4360
case "$1" in
4461
--win64)
62+
cd "$SWIPL_SOURCE_DIR"
4563
build_win64
4664
shift
4765
;;
4866
--update)
67+
cd "$SWIPL_SOURCE_DIR"
4968
update_win64
5069
shift
5170
;;
71+
--win64-from-git)
72+
clone_swipl "$2" "$3"
73+
shift 3
74+
cd "$SWIPL_SOURCE_DIR"
75+
build_win64
76+
;;
5277
*)
53-
echo "Options: --win64"
78+
echo "Options: --win64 | --update | --win64-from-git URL REF"
5479
exit 1
5580
done=true
5681
esac

functions.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Shell functions for common tasks
22

3-
# Running to many jobs concurrently under wine that access a lot of
4-
# files causes wineserver to generate timeouts which shows as files
5-
# claimed missing while they are not.
6-
73
jobs=$(($(nproc)/2))
84
nopts="-j $jobs"
95

@@ -43,8 +39,7 @@ build_win64()
4339
mkdir $dir
4440
( cd $dir
4541
config_win64 PGO
46-
timeout -k 2m 1h ninja $nopts
47-
timeout -k 2m 1h ninja $nopts
42+
ninja $nopts
4843
cpack
4944
)
5045
}
@@ -56,8 +51,7 @@ update_win64()
5651
export JAVA_HOME="$JAVA_HOME64"
5752

5853
( cd $dir
59-
timeout -k 1m 2m ninja $nopts
60-
timeout -k 1m 2m ninja $nopts
54+
ninja $nopts
6155
)
6256
}
6357

0 commit comments

Comments
 (0)