Skip to content

Commit c1c64b4

Browse files
committed
-Add cross compilation docs & workflow
1 parent 7ea2f0a commit c1c64b4

3 files changed

Lines changed: 196 additions & 60 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Cross compile to windows from Linux
2+
3+
# There's || being used here and there because on github actions
4+
# it thinks those are fatal
5+
6+
on:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
container:
14+
image: archlinux:latest
15+
16+
steps:
17+
- name: Install base dependencies
18+
run: |
19+
pacman -Syu --noconfirm archlinux-keyring
20+
pacman -Syu --noconfirm base-devel sudo git clang lld make cmake extra-cmake-modules python wine wine-mono msitools ca-certificates libwbclient 7zip
21+
22+
- name: Create build user
23+
run: |
24+
useradd -m builder
25+
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
26+
27+
- name: Checkout repository
28+
uses: actions/checkout@v6
29+
with:
30+
submodules: recursive
31+
32+
- name: Fix permissions
33+
run: chown -R builder:builder .
34+
35+
- name: Build
36+
run: |
37+
sudo -u builder sh <<'EOF'
38+
set -ex
39+
trap 'echo "FAILED at line $LINENO (exit $?)" >&2' ERR
40+
export WINE=$(command -v wine64 || command -v wine || false)
41+
export WINDOWS_SDK_PATH="/opt/msvc"
42+
export PATH=$WINDOWS_SDK_PATH/bin/x86:$PATH
43+
export XDG_RUNTIME_DIR=/build/xdg
44+
sudo mkdir -p $WINDOWS_SDK_PATH $WINDOWS_SDK_PATH
45+
$WINE wineboot
46+
git clone https://aur.archlinux.org/msvc-wine-git.git
47+
cd msvc-wine-git
48+
makepkg -si --noconfirm
49+
cd ..
50+
51+
chmod +x third-party/common/linux/premake/premake5
52+
chmod +x third-party/deps/linux/7za/7za
53+
chmod +x third-party/deps/linux/cmake/bin/cmake
54+
55+
./third-party/common/linux/premake/premake5 --file=premake5-deps.lua --32-build --all-ext --all-build --custom-cmake=cmake --cmake-toolchain=$WINDOWS_SDK_PATH/cmake/toolchain-x86.cmake --custom-extractor=7z --j=$(nproc) --os=windows vs2026
56+
57+
echo "BUILDING X64"
58+
59+
export PATH=$WINDOWS_SDK_PATH/bin/x64:$PATH
60+
61+
./third-party/common/linux/premake/premake5 --file=premake5-deps.lua --64-build --all-ext --all-build --custom-cmake=cmake --cmake-toolchain=$WINDOWS_SDK_PATH/cmake/toolchain-x64.cmake --custom-extractor=7z --j=$(nproc) --os=windows vs2026
62+
63+
./third-party/common/linux/premake/premake5 --file=premake5.lua --genproto --os=windows vs2026 || true
64+
65+
cd build/project/vs2026/win
66+
/opt/msvc/bin/x86/msbuild '/nologo' '/v:n' '/p:Configuration=release,Platform=Win32' gbe.slnx || echo "MSBuild x86 failed (exit $?)"
67+
68+
echo "BUILDING X64"
69+
/opt/msvc/bin/x64/msbuild '/nologo' '/v:n' '/p:Configuration=release,Platform=x64' gbe.slnx || echo "MSBuild x64 failed (exit $?)"
70+
EOF
71+
72+
- name: Upload artifact/s
73+
uses: actions/upload-artifact@v7
74+
with:
75+
name: emu-win-cross-release
76+
path: |
77+
build/win/vs2026/release/

‎README.md‎

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
## :large_orange_diamond: **This is a fork**
2-
Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
2+
Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
33

44
### Feel free to make a PR.
55

66
---
77

8-
:red_circle:
8+
:red_circle:
99

10-
**This fork is not a takeover, not a resurrection of the original project, and not a replacement.**
11-
**This is just a fork, don't take it seriously.**
12-
**You are highly encouraged to fork/clone it and do whatever you want with it.**
10+
**This fork is not a takeover, not a resurrection of the original project, and not a replacement.**
11+
**This is just a fork, don't take it seriously.**
12+
**You are highly encouraged to fork/clone it and do whatever you want with it.**
1313

1414
:red_circle:
1515

1616
---
1717

1818
## **Compatibility**
19-
This fork is incompatible with the original repo, lots of things has changed and might be even broken.
20-
If something doesn't work, feel free to create a pull request with the appropriate fix, otherwise ignore this fork and use the original emu.
19+
This fork is incompatible with the original repo, lots of things has changed and might be even broken.
20+
If something doesn't work, feel free to create a pull request with the appropriate fix, otherwise ignore this fork and use the original emu.
2121

2222
---
2323

2424
## **Credits**
25-
Thanks to everyone contributing to this project in any way possible, we try to keep the [CHANGELOG.md](./CHANGELOG.md) updated with all the changes and their authors.
25+
Thanks to everyone contributing to this project in any way possible, we try to keep the [CHANGELOG.md](./CHANGELOG.md) updated with all the changes and their authors.
2626

27-
This project depends on many third-party libraries and tools, credits to them for their amazing work, you can find their listing here in [CREDITS.md](./CREDITS.md).
27+
This project depends on many third-party libraries and tools, credits to them for their amazing work, you can find their listing here in [CREDITS.md](./CREDITS.md).
2828

2929
---
3030

3131
# How to use the emu
32-
* **Always generate the interfaces file using the `generate_interfaces` tool.**
33-
* **If things don't work, try the `ColdClientLoader` setup.**
32+
* **Always generate the interfaces file using the `generate_interfaces` tool.**
33+
* **If things don't work, try the `ColdClientLoader` setup.**
3434

3535
You can find helper guides, scripts, and tools here:
3636

@@ -45,7 +45,7 @@ You can find helper guides, scripts, and tools here:
4545
* **[GSE-Generator](https://github.com/brunolee-GIT/GSE-Generator)**
4646
* **If you created a generator tool create a Feature PR**
4747

48-
You can also find instructions here in [README.release.md](./post_build/README.release.md)
48+
You can also find instructions here in [README.release.md](./post_build/README.release.md)
4949

5050
---
5151
---
@@ -71,28 +71,28 @@ You can also find instructions here in [README.release.md](./post_build/README.r
7171
* You need Windows 10 or 8.1 + WDK
7272
* Using Visual Studio, install `Visual Studio 2022 Community`: https://visualstudio.microsoft.com/vs/community/
7373
* Select the Workload `Desktop development with C++`
74-
* In the `Individual componenets` scroll to the buttom and select the **latest** version of `Windows XX SDK (XX.X...)`
74+
* In the `Individual componenets` scroll to the buttom and select the **latest** version of `Windows XX SDK (XX.X...)`
7575
For example `Windows 11 SDK (10.0.22621.0)`
76-
* Using `MSYS2` **this is currently experimental and will not work due to ABI differences**: https://www.msys2.org/
76+
* Using `MSYS2` **this is currently experimental and will not work due to ABI differences**: https://www.msys2.org/
7777
<details>
7878
<summary>steps</summary>
79-
80-
* To build 64-bit binaries use either the [environment](https://www.msys2.org/docs/environments/) `UCRT64` or `MINGW64` then install the GCC toolchain
81-
`UCRT64`
79+
80+
* To build 64-bit binaries use either the [environment](https://www.msys2.org/docs/environments/) `UCRT64` or `MINGW64` then install the GCC toolchain
81+
`UCRT64`
8282
```shell
8383
pacman -S mingw-w64-ucrt-x86_64-gcc
8484
```
85-
`MINGW64`
85+
`MINGW64`
8686
```shell
8787
pacman -S mingw-w64-i686-gcc
8888
```
89-
* To build 32-bit binaries use the environment `MINGW32` then install the GCC toolchain
89+
* To build 32-bit binaries use the environment `MINGW32` then install the GCC toolchain
9090
```shell
9191
pacman -S mingw-w64-i686-gcc
92-
```
93-
94-
</details>
95-
* Python 3.10 or above: https://www.python.org/downloads/windows/
92+
```
93+
94+
</details>
95+
* Python 3.10 or above: https://www.python.org/downloads/windows/
9696
After installation, make sure it works
9797
```batch
9898
python --version
@@ -127,16 +127,18 @@ You can also find instructions here in [README.release.md](./post_build/README.r
127127
sudo apt install -y "python3.12-dev"
128128
sudo apt install -y "python3.12-venv"
129129
sudo apt install -y python3-dev
130-
130+
131131
# make sure it works
132132
python3.12 --version
133133
```
134134

135+
### For cross compiling see [the docs](./dev.notes)
136+
135137
### **Building dependencies**
136138

137-
These are third party libraries needed to build the emu later, they are linked with the emu during its build process.
138-
You don't need to build these dependencies every time, they rarely get updated.
139-
The only times you'll need to rebuild them is either when their separete build folder was accedentally deleted, or when the dependencies were updated.
139+
These are third party libraries needed to build the emu later, they are linked with the emu during its build process.
140+
You don't need to build these dependencies every time, they rarely get updated.
141+
The only times you'll need to rebuild them is either when their separete build folder was accedentally deleted, or when the dependencies were updated.
140142

141143
<br/>
142144

@@ -147,10 +149,10 @@ Open CMD in the repo folder, then run the following
147149
set "CMAKE_GENERATOR=Visual Studio 18 2026"
148150
third-party\common\win\premake\premake5.exe --file=premake5-deps.lua --64-build --32-build --all-ext --all-build --verbose --os=windows vs2026
149151
```
150-
* To build using `MSYS2` **this is currently experimental and will not work due to ABI differences**
152+
* To build using `MSYS2` **this is currently experimental and will not work due to ABI differences**
151153
<details>
152154
<summary>steps</summary>
153-
155+
154156
*(Optional)* In both cases below, you can use `Clang` compiler instead of `GCC` by running these 2 commands in the same terminal instance
155157
```shell
156158
export CC="clang"
@@ -166,12 +168,12 @@ Open CMD in the repo folder, then run the following
166168
export CMAKE_GENERATOR="MSYS Makefiles"
167169
./third-party/common/win/premake/premake5.exe --file=premake5-deps.lua --32-build --all-ext --all-build --verbose --os=windows gmake2
168170
```
169-
170-
</details>
171+
172+
</details>
171173

172174
This will:
173-
* Extract all third party dependencies from the folder `third-party` into the folder `build\deps\win`
174-
* Build all dependencies
175+
* Extract all third party dependencies from the folder `third-party` into the folder `build\deps\win`
176+
* Build all dependencies
175177

176178
#### On Linux:
177179
Open a terminal in the repo folder
@@ -186,8 +188,8 @@ export CMAKE_GENERATOR="Unix Makefiles"
186188
./third-party/common/linux/premake/premake5 --file=premake5-deps.lua --64-build --32-build --all-ext --all-build --verbose --os=linux gmake2
187189
```
188190
This will:
189-
* Extract all third party dependencies from the folder `third-party` into the folder `build/deps/linux`
190-
* Build all dependencies (32-bit and 64-bit)
191+
* Extract all third party dependencies from the folder `third-party` into the folder `build/deps/linux`
192+
* Build all dependencies (32-bit and 64-bit)
191193

192194
---
193195

@@ -197,19 +199,19 @@ Open CMD in the repo folder, then run the following
197199
* For `Visual Studio 2022`
198200
```batch
199201
third-party\common\win\premake\premake5.exe --file=premake5.lua --genproto --os=windows vs2026
200-
```
201-
You can then go to the folder `build\project\vs2026\win` and open the produced `.sln` file in Visual Studio.
202-
Or, if you prefer to do it from command line, open the `Developer Command Prompt for VS 2026` inside the above folder, then:
202+
```
203+
You can then go to the folder `build\project\vs2026\win` and open the produced `.sln` file in Visual Studio.
204+
Or, if you prefer to do it from command line, open the `Developer Command Prompt for VS 2026` inside the above folder, then:
203205
```batch
204206
msbuild /nologo /v:n /p:Configuration=release,Platform=Win32 gbe.slnx
205207
206208
msbuild /nologo /v:n /p:Configuration=release,Platform=x64 gbe.slnx
207209
```
208-
209-
* For `MSYS2` **this is currently experimental and will not work due to ABI differences**
210+
211+
* For `MSYS2` **this is currently experimental and will not work due to ABI differences**
210212
<details>
211213
<summary>steps</summary>
212-
214+
213215
```shell
214216
./third-party/common/win/premake/premake5.exe --file=premake5.lua --genproto --os=windows gmake2
215217
@@ -219,7 +221,7 @@ Open CMD in the repo folder, then run the following
219221
```shell
220222
export CC="clang"
221223
export CXX="clang++"
222-
```
224+
```
223225
* 64-bit build (`UCRT64` or `MINGW64`)
224226
```shell
225227
make config=release_x64 -j 8 all
@@ -232,11 +234,11 @@ Open CMD in the repo folder, then run the following
232234
```shell
233235
make help
234236
```
235-
236-
</details>
237237

238-
This will build a release version of the emu in the folder `build\win\<toolchain>\release`
239-
An example script `build_win_premake.bat` is available, check it out
238+
</details>
239+
240+
This will build a release version of the emu in the folder `build\win\<toolchain>\release`
241+
An example script `build_win_premake.bat` is available, check it out
240242

241243
<br/>
242244

@@ -245,56 +247,56 @@ Open a terminal in the repo folder, then run the following
245247
```shell
246248
./third-party/common/linux/premake/premake5 --file=premake5.lua --genproto --os=linux gmake2
247249
cd ./build/project/gmake2/linux
248-
```
250+
```
249251
*(Optional)* You can use `Clang` compiler instead of `GCC` by running these 2 commands in the current terminal instance
250252
```shell
251253
export CC="clang"
252254
export CXX="clang++"
253-
```
255+
```
254256
Then run the following
255257
```shell
256258
make config=release_x32 -j 8 all
257259
make config=release_x64 -j 8 all
258-
```
260+
```
259261

260262
To see all possible build targets
261263
```shell
262264
make help
263-
```
265+
```
264266

265-
This will build a release version of the emu in the folder `build/linux/<toolchain>/release`
266-
An example script `build_linux_premake.sh` is available, check it out
267+
This will build a release version of the emu in the folder `build/linux/<toolchain>/release`
268+
An example script `build_linux_premake.sh` is available, check it out
267269

268270
---
269271

270272
## **Using Github CI as a builder**
271273

272-
This is really slow and mainly intended for the CI Workflow scripts, but you can use it as another outlet if you can't build locally.
274+
This is really slow and mainly intended for the CI Workflow scripts, but you can use it as another outlet if you can't build locally.
273275
**You have to fork the repo first**.
274276
275277
### Initial setup
276278
In your fork, open the `Settings` tab from the top, then:
277279
* From the left side panel select `Actions` -> `General`
278280
* In the section `Actions permissions` select `Allow all actions and reusable workflows`
279281
* Scroll down, and in the section `Workflow permissions` select `Read and write permissions`
280-
* *(Optional)* In the section `Artifact and log retention`, you can specify the amount of days to keep the build artifacts/archives.
281-
It is recommended to set a reasonable number like 3-4 days, otherwise you may consume your packages storage if you use Github as a builder frequently, more details here: https://docs.github.com/en/get-started/learning-about-github/githubs-plans
282+
* *(Optional)* In the section `Artifact and log retention`, you can specify the amount of days to keep the build artifacts/archives.
283+
It is recommended to set a reasonable number like 3-4 days, otherwise you may consume your packages storage if you use Github as a builder frequently, more details here: https://docs.github.com/en/get-started/learning-about-github/githubs-plans
282284
283285
### Manual trigger
284286
1. Go to the `Actions` tab in your fork
285-
2. Select the emu dependencies Workflow (ex: `Emu third-party dependencies (Windows) `) and run it on the **main** branch (ex: `dev`).
287+
2. Select the emu dependencies Workflow (ex: `Emu third-party dependencies (Windows) `) and run it on the **main** branch (ex: `dev`).
286288
Dependencies not created on the main branch won't be recognized by other branches or subsequent runs
287289
3. Select one of the Workflow scripts from the left side panel, for example `Build all emu variants (Windows)`
288290
3. On the top-right, select `Run workflow` -> select the desired branch (for example `dev`) -> press the button `Run workflow`
289-
4. When it's done, many packages (called build artifacts) will be created for that workflow.
291+
4. When it's done, many packages (called build artifacts) will be created for that workflow.
290292
Make sure to select the workflow again to view its history, then select the last run at the very top to view its artifacts
291293
292294
<br/>
293295
294296
Important note:
295297
---
296298
297-
When you build the dependencies workflows, they will be cached to decrease the build times of the next triggers and avoid unnecessary/wasteful build process.
299+
When you build the dependencies workflows, they will be cached to decrease the build times of the next triggers and avoid unnecessary/wasteful build process.
298300
This will cause a problem if at any time the third-party dependencies were updated, in that case you need to manually delete the cache, in your fork:
299301
1. Go to the `Actions` tab at the top
300302
2. Select `Caches` from the left side panel
@@ -312,13 +314,13 @@ Open CMD in the repos's directory, then run this script
312314
```batch
313315
package_win.bat <build_folder>
314316
```
315-
`build_folder` is any folder inside `build\win`, for example: `vs2026\release`
317+
`build_folder` is any folder inside `build\win`, for example: `vs2026\release`
316318
The above example will create a `.7z` archive inside `build\package\win\`
317319
318320
### On Linux:
319321
Open bash terminal in the repos's directory, then run this script
320322
```shell
321323
package_linux.sh <build_folder>
322324
```
323-
`build_folder` is any folder inside `build/linux`, for example: `gmake2/release`
325+
`build_folder` is any folder inside `build/linux`, for example: `gmake2/release`
324326
The above example will create a compressed `.tar` archive inside `build/package/linux/`

0 commit comments

Comments
 (0)