Skip to content

Commit f394d5b

Browse files
committed
add WSL to CI build
1 parent fec9127 commit f394d5b

File tree

8 files changed

+188
-10
lines changed

8 files changed

+188
-10
lines changed

.github/workflows/build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
'32_486-msvcrt_win98',
3535
]
3636
37+
wsl_branch = ['16', '15']
38+
wsl_profile = ['64_v2-mcf', '64_v2-ucrt']
39+
3740
sat_group = [
3841
{
3942
'name': '64-nt6x',
@@ -101,6 +104,8 @@ jobs:
101104
102105
print(f'branch={json.dumps(branch)}')
103106
print(f'profile={json.dumps(profile)}')
107+
print(f'wsl_branch={json.dumps(wsl_branch)}')
108+
print(f'wsl_profile={json.dumps(wsl_profile)}')
104109
print(f'release={json.dumps(release)}')
105110
print(f'prerelease={json.dumps(prerelease)}')
106111
print(f'release_xmake={json.dumps(release_xmake)}')
@@ -110,6 +115,8 @@ jobs:
110115
outputs:
111116
branch: ${{ steps.param.outputs.branch }}
112117
profile: ${{ steps.param.outputs.profile }}
118+
wsl_branch: ${{ steps.param.outputs.wsl_branch }}
119+
wsl_profile: ${{ steps.param.outputs.wsl_profile }}
113120
release: ${{ steps.param.outputs.release }}
114121
prerelease: ${{ steps.param.outputs.prerelease }}
115122
release_xmake: ${{ steps.param.outputs.release_xmake }}
@@ -168,6 +175,58 @@ jobs:
168175
branch: ${{ matrix.branch }}
169176
profile: ${{ matrix.profile }}
170177

178+
wsl_build_container:
179+
name: Build container (WSL)
180+
needs: [param]
181+
if: ${{ ! fromJson(needs.param.outputs.release) }}
182+
runs-on: windows-2025
183+
steps:
184+
- uses: actions/checkout@v4
185+
186+
- name: Build container (WSL)
187+
run: |
188+
Copy-Item -Path support/wsl/.wslconfig -Destination "$env:USERPROFILE/.wslconfig"
189+
190+
Invoke-WebRequest `
191+
-Uri https://cdimages.ubuntu.com/ubuntu-wsl/noble/daily-live/current/noble-wsl-amd64.wsl `
192+
-OutFile noble-wsl-amd64.wsl
193+
194+
wsl --import mingw-lite-buildenv . noble-wsl-amd64.wsl
195+
196+
wsl --distribution mingw-lite-buildenv --exec `
197+
apt update
198+
wsl --distribution mingw-lite-buildenv --exec `
199+
env DEBIAN_FRONTEND=noninteractive `
200+
apt-get install --no-install-recommends -y `
201+
autoconf automake build-essential cmake flex gettext libtool meson texinfo xmake `
202+
7zip ca-certificates curl file gawk libarchive-tools python3 python3-packaging zstd
203+
204+
wsl --distribution mingw-lite-buildenv --exec `
205+
sync
206+
wsl --shutdown
207+
208+
mkdir assets
209+
wsl --export mingw-lite-buildenv assets/buildenv.vhdx --format vhd
210+
211+
- uses: actions/upload-artifact@v4
212+
with:
213+
name: wsl-buildenv
214+
path: assets/buildenv.vhdx
215+
216+
wsl_build:
217+
name: Build (WSL)
218+
needs: [param, download_source, wsl_build_container]
219+
if: ${{ ! fromJson(needs.param.outputs.release) }}
220+
strategy:
221+
fail-fast: false
222+
matrix:
223+
branch: ${{ fromJson(needs.param.outputs.wsl_branch) }}
224+
profile: ${{ fromJson(needs.param.outputs.wsl_profile) }}
225+
uses: ./.github/workflows/wsl_build_single.yml
226+
with:
227+
branch: ${{ matrix.branch }}
228+
profile: ${{ matrix.profile }}
229+
171230
release:
172231
name: Release
173232
needs: [param, build]

.github/workflows/build_single.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,26 @@ jobs:
8282
8383
- uses: actions/checkout@v4
8484

85-
- uses: msys2/setup-msys2@v2
86-
with:
87-
msystem: ucrt64
88-
pacboy: python:p python-packaging:p
89-
9085
- uses: actions/download-artifact@v4
9186
with:
9287
name: mingw${{ inputs.profile }}-${{ inputs.branch }}
9388
path: dist
9489

90+
- name: Setup bsdtar
91+
run: |
92+
New-Item -ItemType Directory -Path assets -Force
93+
Invoke-WebRequest `
94+
-Uri https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-v1.5.7-win64.zip `
95+
-OutFile assets/zstd-v1.5.7-win64.zip
96+
Expand-Archive -Path assets/zstd-v1.5.7-win64.zip -DestinationPath assets
97+
$system32 = [Environment]::SystemDirectory
98+
Copy-Item -Path assets/zstd-v1.5.7-win64/zstd.exe -Destination "$system32/zstd.exe"
99+
New-Item -ItemType SymbolicLink -Path "$system32/bsdtar.exe" -Target tar.exe
100+
101+
- name: Install Python Package
102+
run: |
103+
pip install packaging
104+
95105
- name: Test
96-
shell: msys2 {0}
97106
run: |
98107
python test.py --branch ${{ inputs.branch }} --profile ${{ inputs.profile }} --build x86_64-w64-mingw32 -v
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build single (WSL)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
profile:
7+
required: true
8+
type: string
9+
branch:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: windows-2025
17+
18+
steps:
19+
- name: Configure Git
20+
run: |
21+
git config --global core.autocrlf false
22+
git config --global core.symlinks true
23+
24+
- uses: actions/checkout@v4
25+
26+
- name: Download source
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: src-${{ inputs.branch }}
30+
path: assets
31+
32+
- uses: actions/download-artifact@v4
33+
with:
34+
name: wsl-buildenv
35+
path: assets
36+
37+
- name: Setup bsdtar
38+
run: |
39+
New-Item -ItemType Directory -Path assets -Force
40+
Invoke-WebRequest `
41+
-Uri https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-v1.5.7-win64.zip `
42+
-OutFile assets/zstd-v1.5.7-win64.zip
43+
Expand-Archive -Path assets/zstd-v1.5.7-win64.zip -DestinationPath assets
44+
$system32 = [Environment]::SystemDirectory
45+
Copy-Item -Path assets/zstd-v1.5.7-win64/zstd.exe -Destination "$system32/zstd.exe"
46+
New-Item -ItemType SymbolicLink -Path "$system32/bsdtar.exe" -Target tar.exe
47+
48+
- name: Install Python Package
49+
run: |
50+
pip install packaging
51+
52+
- name: Build
53+
run: |
54+
Copy-Item -Path support/wsl/.wslconfig -Destination "$env:USERPROFILE/.wslconfig"
55+
56+
wsl --import-in-place mingw-lite-buildenv assets/buildenv.vhdx
57+
wsl --distribution mingw-lite-buildenv --exec `
58+
env XMAKE_ROOT=y `
59+
./main.py --branch ${{ inputs.branch }} --profile ${{ inputs.profile }}
60+
61+
- uses: actions/upload-artifact@v4
62+
with:
63+
name: wsl${{ inputs.profile }}-${{ inputs.branch }}
64+
path: dist
65+
66+
- name: Test
67+
run: |
68+
python test.py --branch ${{ inputs.branch }} --profile ${{ inputs.profile }} --build x86_64-w64-mingw32 -v

doc/wsl-buildenv.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ See [Microsoft Learn](https://learn.microsoft.com/en-us/windows/wsl/install).
2525
autoconf automake build-essential cmake flex gettext libtool meson texinfo xmake \
2626
7zip ca-certificates curl file gawk libarchive-tools python3 python3-packaging zstd
2727
```
28+
3. Set environment variables:
29+
```bash
30+
echo "export XMAKE_ROOT=y" >>~/.bashrc
31+
```
2832

2933
## Clone the Repository
3034

module/ABB.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from module.debug import shell_here
1111
from module.path import ProjectPaths
1212
from module.profile import BranchProfile
13-
from module.util import XMAKE_ARCH_MAP, add_objects_to_static_lib, ensure, overlayfs_ro
13+
from module.util import XMAKE_ARCH_MAP, add_objects_to_static_lib, ensure, overlayfs_ro, remove_info_main_menu
1414
from module.util import cflags_B, configure, make_custom, make_default, make_destdir_install
1515
from module.util import meson_build, meson_config, meson_flags_B, meson_install
1616
from module.util import xmake_build, xmake_config, xmake_install
@@ -78,6 +78,8 @@ def _binutils(ver: BranchProfile, paths: ProjectPaths, config: argparse.Namespac
7878
'install',
7979
], jobs = 1)
8080

81+
remove_info_main_menu(paths.layer_ABB.binutils)
82+
8183
license_dir = paths.layer_ABB.binutils / 'share/licenses/binutils'
8284
ensure(license_dir)
8385
for file in ['COPYING', 'COPYING3', 'COPYING.LIB', 'COPYING3.LIB']:
@@ -368,6 +370,8 @@ def _gcc(ver: BranchProfile, paths: ProjectPaths, config: argparse.Namespace):
368370
atomic_objects.append(wrapper_obj)
369371
add_objects_to_static_lib(f'{ver.target}-ar', libgcc_a, atomic_objects)
370372

373+
remove_info_main_menu(paths.layer_ABB.gcc)
374+
371375
license_dir = paths.layer_ABB.gcc / 'share/licenses/gcc'
372376
ensure(license_dir)
373377
for file in ['COPYING', 'COPYING3', 'COPYING.RUNTIME', 'COPYING.LIB', 'COPYING3.LIB']:
@@ -452,6 +456,8 @@ def _gdb(ver: BranchProfile, paths: ProjectPaths, config: argparse.Namespace):
452456
f.write('register_libstdcxx_printers(None)\n')
453457
f.write('end\n')
454458

459+
remove_info_main_menu(paths.layer_ABB.gdb)
460+
455461
# collision with binutils
456462
for info_file in ['bfd.info', 'ctf-spec.info', 'sframe-spec.info']:
457463
os.unlink(paths.layer_ABB.gdb / 'share/info' / info_file)
@@ -497,6 +503,8 @@ def _gmake(ver: BranchProfile, paths: ProjectPaths, config: argparse.Namespace):
497503
make_default(build_dir, config.jobs)
498504
make_destdir_install(build_dir, paths.layer_ABB.make)
499505

506+
remove_info_main_menu(paths.layer_ABB.make)
507+
500508
license_dir = paths.layer_ABB.make / 'share/licenses/make'
501509
ensure(license_dir)
502510
shutil.copy(paths.src_dir.make / 'COPYING', license_dir / 'COPYING')

module/util.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import shutil
66
import subprocess
77
from tempfile import TemporaryDirectory
8-
from typing import Iterable, List
8+
from typing import Iterable, List, Union
99

1010
from module.profile import ProfileInfo
1111

@@ -174,7 +174,7 @@ def meson_install(
174174
)
175175

176176
@contextmanager
177-
def overlayfs_ro(merged: Path | str, lower: list[Path]):
177+
def overlayfs_ro(merged: Union[Path, str], lower: list[Path]):
178178
try:
179179
if len(lower) == 1:
180180
subprocess.run([
@@ -197,8 +197,13 @@ def overlayfs_ro(merged: Path | str, lower: list[Path]):
197197
finally:
198198
subprocess.run(['umount', merged], check = False)
199199

200+
def remove_info_main_menu(prefix: Path):
201+
info_main_menu = prefix / 'share/info/dir'
202+
if info_main_menu.exists():
203+
info_main_menu.unlink()
204+
200205
@contextmanager
201-
def temporary_rw_overlay(path: Path | str):
206+
def temporary_rw_overlay(path: Union[Path, str]):
202207
with TemporaryDirectory() as tmp:
203208
try:
204209
shutil.copytree(path, tmp, dirs_exist_ok = True)

support/wsl/.wslconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
############################################
2+
## WSL 2 configuration (GHA windows-2025) ##
3+
############################################
4+
5+
[wsl2]
6+
7+
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners
8+
# memory: 12 GiB of 16 GiB
9+
memory=12GB
10+
11+
swap=0
12+
13+
guiApplications=false
14+
15+
nestedVirtualization=false
16+
17+
# storage: 12 GiB of 14 GiB
18+
defaultVhdSize=12GB
19+
20+
[experimental]
21+
22+
autoMemoryReclaim=gradual

test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def extract(path: Path, arx: Path):
3939
'-C', path.parent,
4040
'-xf', arx,
4141
'--no-same-owner',
42+
# workaround zstd pipe error with Windows `tar.exe`
43+
# https://github.com/libarchive/libarchive/issues/2512
44+
'--ignore-zeros',
4245
], check = True)
4346

4447
def prepare_test_binary(ver: BranchProfile, paths: ProjectPaths):

0 commit comments

Comments
 (0)