Skip to content

Commit aa7f985

Browse files
authored
Update release-crosscompile.yml
1 parent f772e8c commit aa7f985

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

.github/workflows/release-crosscompile.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
workflow_dispatch:
77

88
jobs:
9+
# First, sync from the upstream repo into the mirror repository.
910
git-sync:
1011
runs-on: ubuntu-latest
1112
steps:
@@ -18,6 +19,7 @@ jobs:
1819
destination_branch: "mob"
1920
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
2021

22+
# Build Linux and Windows binaries.
2123
build-binaries:
2224
needs: git-sync
2325
runs-on: ubuntu-latest
@@ -39,23 +41,26 @@ jobs:
3941
gcc-mingw-w64-x86-64 \
4042
binutils-mingw-w64-x86-64 \
4143
mingw-w64-x86-64-dev \
42-
build-essential
44+
build-essential \
45+
wine64
4346
4447
- name: Build Linux host compiler
4548
run: |
49+
# Build using the native compiler (this binary will be used to run helper tools)
4650
./configure
4751
make
4852
mv tcc tcc-host
4953
5054
- name: Build Linux binary
5155
run: |
56+
# Reconfigure and rebuild to produce the native Linux executable.
5257
./configure
5358
make
5459
mv tcc tcc-linux
5560
5661
- name: Prepare Windows build environment
5762
run: |
58-
# Clean previous build artifacts but keep host compiler
63+
# Clean previous build artifacts (but keep the host compiler)
5964
make clean
6065
rm -f config.mak config.h
6166
@@ -66,17 +71,23 @@ jobs:
6671
--extra-cflags="-static" \
6772
--extra-ldflags="-static"
6873
69-
# Patch Makefile for cross-compilation
74+
# Patch the Makefile:
75+
# • Force the host-built compiler to be used when running helper tools.
76+
# • Use the cross-compiler for building Windows binaries.
77+
# • Add -DWIN32 for Windows builds.
7078
sed -i 's/^\(HOST_CC\s*=\s*\).*/\1.\/tcc-host/' Makefile
7179
sed -i 's/^\(CC\s*=\s*\).*/\1x86_64-w64-mingw32-gcc/' Makefile
7280
sed -i 's/\(CFLAGS\s*+=\)/\1 -DWIN32/' Makefile
7381
82+
# In case any Windows-built helper tool must be executed, patch the call to use Wine.
83+
sed -i 's|./c2str.exe|wine ./c2str.exe|' Makefile
84+
7485
- name: Build Windows binary
7586
run: |
76-
# First build helper tools with host compiler
87+
# First, build any helper tool (using the host compiler via the patched Makefile)
7788
make libtcc1.a
7889
79-
# Then build Windows executable
90+
# Then, build the Windows executable using the cross-compiler.
8091
make tcc
8192
mv tcc tcc-windows.exe
8293
@@ -88,6 +99,7 @@ jobs:
8899
tcc-linux
89100
tcc-windows.exe
90101
102+
# Create (or update) a GitHub release in the mirror repository containing both binaries.
91103
create-release:
92104
needs: build-binaries
93105
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)