Skip to content

Commit fc3ee4c

Browse files
committed
try containerize linux builds
cherry pick of 1528ee2
1 parent 9c51902 commit fc3ee4c

File tree

4 files changed

+55
-74
lines changed

4 files changed

+55
-74
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -58,76 +58,38 @@ jobs:
5858
strategy:
5959
fail-fast: false
6060
matrix:
61-
preset: [
62-
"clang-cross-ue3-x86-release",
63-
"clang-cross-ue4-x64-release",
64-
"llvm-mingw-ue3-x86-release",
65-
"llvm-mingw-ue4-x64-release",
66-
"mingw-ue3-x86-release",
67-
"mingw-ue4-x64-release",
68-
]
61+
toolchain:
62+
- preset: clang-cross-ue3-x86-release
63+
container: clang-cross
64+
- preset: clang-cross-ue4-x64-release
65+
container: clang-cross
66+
- preset: llvm-mingw-ue3-x86-release
67+
container: llvm-mingw
68+
- preset: llvm-mingw-ue4-x64-release
69+
container: llvm-mingw
70+
- preset: mingw-ue3-x86-release
71+
container: mingw
72+
- preset: mingw-ue4-x64-release
73+
container: mingw
6974

7075
steps:
71-
- name: Setup CMake and Ninja
72-
uses: lukka/get-cmake@latest
73-
74-
- name: Setup LLVM MinGW
75-
if: startswith(matrix.preset, 'llvm-mingw')
76-
run: |
77-
wget -nv ${{ env.LLVM_MINGW_DOWNLOAD }}
78-
tar -xf ${{ env.LLVM_MINGW_VERSION }}.tar.xz -C ~/
79-
echo $(readlink -f ~/${{ env.LLVM_MINGW_VERSION }}/bin) >> $GITHUB_PATH
80-
81-
- name: Setup MinGW
82-
if: startswith(matrix.preset, 'mingw')
83-
uses: egor-tensin/setup-mingw@v2
84-
with:
85-
platform: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}
86-
87-
- name: Setup Clang
88-
if: startswith(matrix.preset, 'clang-cross')
89-
uses: egor-tensin/setup-clang@v1
90-
91-
- name: Restore win sdk cache
92-
if: startswith(matrix.preset, 'clang-cross')
93-
uses: actions/cache@v4
94-
id: cache-win-sdk
95-
with:
96-
path: ~/win-sdk
97-
key: ${{ runner.os }}-win-sdk
98-
99-
- name: Setup msitools
100-
if: startswith(matrix.preset, 'clang-cross') && steps.cache-win-sdk.outputs.cache-hit != 'true'
101-
uses: awalsh128/cache-apt-pkgs-action@latest
102-
with:
103-
packages: msitools
104-
version: ${{ runner.os }}-msitools
105-
106-
- name: Setup win sdk
107-
if: startswith(matrix.preset, 'clang-cross') && steps.cache-win-sdk.outputs.cache-hit != 'true'
108-
run: |
109-
git clone https://github.com/mstorsjo/msvc-wine.git
110-
msvc-wine/vsdownload.py --accept-license --dest ~/win-sdk Microsoft.VisualStudio.Workload.VCTools
111-
msvc-wine/install.sh ~/win-sdk
112-
rm -r msvc-wine
113-
114-
- name: Checkout repository and submodules
115-
uses: actions/checkout@v4
116-
with:
117-
submodules: recursive
118-
119-
- name: Configure CMake
120-
working-directory: ${{ env.GITHUB_WORKSPACE }}
121-
# The extra msvc wine arg won't do anything if we're not cross compiling
122-
run: >
123-
cmake .
124-
--preset ${{ matrix.preset }}
125-
-G Ninja
126-
-DMSVC_WINE_ENV_SCRIPT=$(readlink -f ~)/win-sdk/bin/${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}/msvcenv.sh
76+
- name: Checkout repository and submodules
77+
uses: actions/checkout@v4
78+
with:
79+
submodules: recursive
80+
81+
- name: Build
82+
uses: devcontainers/[email protected]
83+
with:
84+
cacheFrom: ghcr.io/bl-sdk/${{ matrix.toolchain.container }}:latest
85+
configFile: .devcontainer/${{ matrix.toolchain.container }}/devcontainer.json
86+
push: never
87+
# The git watcher cmake thinks something's unsafe? Doesn't happen to me locally.
88+
runCmd: |
89+
git config --global --add safe.directory `pwd`
90+
cmake . --preset ${{ matrix.toolchain.preset }} -G Ninja
91+
cmake --build out/build/${{ matrix.toolchain.preset }}
12792
128-
- name: Build
129-
working-directory: ${{ env.GITHUB_WORKSPACE }}
130-
run: cmake --build out/build/${{ matrix.preset }}
13193
13294
# ==============================================================================
13395

CMakePresets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
"lhs": "${hostSystemName}",
4141
"rhs": "Windows"
4242
},
43+
"environment": {
44+
"MSVC_WINE_ENV_SCRIPT": "/win-sdk/bin/x86/msvcenv.sh"
45+
},
4346
"toolchainFile": "common_cmake/clang-cross-x86.cmake"
4447
},
4548
{
@@ -50,6 +53,9 @@
5053
"lhs": "${hostSystemName}",
5154
"rhs": "Windows"
5255
},
56+
"environment": {
57+
"MSVC_WINE_ENV_SCRIPT": "/win-sdk/bin/x64/msvcenv.sh"
58+
},
5359
"toolchainFile": "common_cmake/clang-cross-x64.cmake"
5460
},
5561
{

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,24 @@ This turns out to be a bit of a problem - MSVC and GNU have different exception
142142
both. Practically, this means when cross compiling, you should either compile everything from
143143
scratch, or setup Clang to build with the MSVC ABI. [See this blog post for more info](https://apple1417.dev/posts/2023-05-18-debugging-proton).
144144

145-
# Running the SDK by itself
145+
# Building the SDK by itself
146146
The shared library is also useful when developing for the sdk itself, since it's the minimal
147-
configuration to get it running. The CMake presets are set up to build this.
148-
149-
Note that you will need to use some game specific plugin loader to get the dll loaded. It is not set
150-
up to alias any system dlls (since when actually using it as a library you don't want that), you
151-
can't just call it `d3d9.dll` and assume your game will load fine.
147+
configuration to get it running. The CMake presets are set up to build this. There are currently
148+
five supported toolchains, each of which have a few different sdk configurations:
149+
150+
- MSVC
151+
- Clang (Windows)
152+
- Clang (Cross Compile) <sup>*</sup>
153+
- MinGW <sup>*</sup>
154+
- LLVM MinGW <sup>*</sup>
155+
156+
The toolchains with an asterix are all cross compiling toolchains. These all also have an associated
157+
dev container, which is the recommended way of building them. The `clang-cross-*` presets in
158+
particular hardcode a path assuming they're running in the container.
159+
160+
Note that you will need to use some game specific plugin loader to get the `unrealsdk.dll` loaded.
161+
It is not set up to alias any system dlls (since when actually using it as a library you don't want
162+
that), you can't just rename it to `d3d9.dll` and assume your game will load fine.
152163

153164
To build:
154165

src/unrealsdk/unreal/structs/fname.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ struct hash<unrealsdk::unreal::FName> {
8484
size_t operator()(const unrealsdk::unreal::FName& name) const {
8585
static_assert(sizeof(unrealsdk::unreal::FName) == sizeof(uint64_t),
8686
"FName is not same size as a uint64");
87-
return hash<uint64_t>()(*reinterpret_cast<const uint64_t*>(&name));
87+
uint64_t val{};
88+
memcpy(&val, &name, sizeof(name));
89+
return hash<uint64_t>()(val);
8890
}
8991
};
9092

0 commit comments

Comments
 (0)