Skip to content

Commit 73a6982

Browse files
committed
try containerize linux builds, update readme
1 parent 3f8069f commit 73a6982

File tree

3 files changed

+74
-106
lines changed

3 files changed

+74
-106
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ jobs:
5151
submodules: recursive
5252

5353
- name: Configure build
54-
working-directory: ${{ env.GITHUB_WORKSPACE }}
5554
run: |
5655
pip install requests
5756
5857
cmake . --preset ${{ matrix.preset }} -G Ninja
5958
6059
- name: Build
61-
working-directory: ${{ env.GITHUB_WORKSPACE }}
6260
run: cmake --build out/build/${{ matrix.preset }}
6361

6462
build-ubuntu:
@@ -68,75 +66,39 @@ jobs:
6866
strategy:
6967
fail-fast: false
7068
matrix:
71-
preset: [
72-
"clang-cross-ue3-x86-release",
73-
"clang-cross-ue4-x64-release",
74-
"llvm-mingw-ue3-x86-release",
75-
"llvm-mingw-ue4-x64-release",
76-
"mingw-ue3-x86-release",
77-
"mingw-ue4-x64-release",
78-
]
69+
toolchain:
70+
- preset: clang-cross-ue3-x86-release
71+
container: clang-cross
72+
- preset: clang-cross-ue4-x64-release
73+
container: clang-cross
74+
- preset: llvm-mingw-ue3-x86-release
75+
container: llvm-mingw
76+
- preset: llvm-mingw-ue4-x64-release
77+
container: llvm-mingw
78+
- preset: mingw-ue3-x86-release
79+
container: mingw
80+
- preset: mingw-ue4-x64-release
81+
container: mingw
7982

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

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: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -98,54 +98,54 @@ To use it:
9898
Note that the sdk disables the integration if it's unable to import debugpy on first use, meaning
9999
you may not get away with manipulating `sys.path`. Instead, consider using [`._pth` files](https://docs.python.org/3/library/sys_path_init.html).
100100

101-
# Installation
102-
1. Download the relevant [release](https://github.com/bl-sdk/pyunrealsdk/releases).
103-
104-
If you don't know which compiler's version to get, we recommend MSVC (so functions log messages
105-
include namespaces).
106-
107-
2. Install some game specific plugin loader. The released dlls are not set up to alias any system
108-
dlls, you can't just call it `d3d9.dll` and assume your game will load fine.
109-
110-
If you know a specific dll name is fine to use without aliasing, rename `pyunrealsdk.dll`.
111-
112-
3. Extract all files to somewhere in your game's dll search path. Your plugin loader's plugins
113-
folder may work, otherwise you can fall back to the same directory as the executable.
114-
115101
# Development
116-
To build:
102+
The sdk can be built with one of five different toolchains, each of which have a few different
103+
configurations:
104+
105+
- MSVC
106+
- Clang (Windows)
107+
- Clang (Cross Compile) <sup>*</sup>
108+
- MinGW <sup>*</sup>
109+
- LLVM MinGW <sup>*</sup>
110+
111+
The toolchains with an asterix are all cross compiling toolchains. These all also have an associated
112+
dev container, which is the recommended way of building them. The `clang-cross-*` presets in
113+
particular hardcode a path assuming they're running in the container.
114+
115+
The sdk is always built as a Windows dll. To allow the cross compiling toolchains to link against a
116+
Windows copy of Python, rather than using CMake's normal `FindPython` helpers, when configuring we
117+
download a copy from Python's site. When integrating the sdk into your own projects, exactly which
118+
version can be specified using the `EXPLICIT_PYTHON_ARCH` and `EXPLICIT_PYTHON_VERSION` variables.
119+
The CMake presets already have these set if building locally.
120+
121+
To download the relevant python version, you need a copy of Python with requests on your path. When
122+
cross compiling you also need `msiextract`, which is typically part of an `msitools` package. The
123+
dev containers already have these set up.
124+
```sh
125+
pip install requests
126+
python -c 'import requests'
127+
128+
# Linux only
129+
apt install msitools # Or equivalent
130+
msiextract --version
131+
```
132+
133+
Once you've got this all set up, to build the sdk:
117134

118135
1. Clone the repo (including submodules).
119136
```sh
120137
git clone --recursive https://github.com/bl-sdk/pyunrealsdk.git
121138
```
122139

123-
2. Make sure you have Python with requests on your PATH. This doesn't need to be the same version
124-
as what the SDK uses, it's just used by the script which downloads the correct one.
125-
```sh
126-
pip install requests
127-
python -c 'import requests'
128-
```
129-
130-
If not running on Windows, make sure `msiextract` is also on your PATH. This is typically part
131-
of an `msitools` package.
132-
```sh
133-
apt install msitools # Or equivalent
134-
msiextract --version
135-
```
136-
137-
See the explicit python [readme](https://github.com/bl-sdk/common_cmake/blob/master/explicit_python/Readme.md)
138-
for a few extra details.
139-
140-
3. (OPTIONAL) Copy `postbuild.template`, and edit it to copy files to your game install directories.
140+
2. (OPTIONAL) Copy `postbuild.template`, and edit it to copy files to your game install directories.
141141

142-
4. Choose a preset, and run CMake. Most IDEs will be able to do this for you,
142+
3. Choose a preset, and run CMake. Most IDEs will be able to do this for you,
143143
```
144144
cmake . --preset msvc-ue4-x64-debug
145145
cmake --build out/build/msvc-ue4-x64-debug
146146
```
147147

148-
5. (OPTIONAL) Copy the python runtime files to the game's directory. At a minimum, you probably
148+
4. (OPTIONAL) Copy the python runtime files to the game's directory. At a minimum, you probably
149149
want these:
150150
```
151151
python3.dll
@@ -159,10 +159,10 @@ To build:
159159
cmake --build out/build/msvc-ue4-x64-debug --target install
160160
```
161161

162-
As an alternative to this and step 3, you could point the CMake install dir directly at your
162+
As an alternative to this and step 2, you could point the CMake install dir directly at your
163163
game, so everything's automatically copied. This however will only work with one game at a time.
164164

165-
6. (OPTIONAL) If you're debugging a game on Steam, add a `steam_appid.txt` in the same folder as the
165+
5. (OPTIONAL) If you're debugging a game on Steam, add a `steam_appid.txt` in the same folder as the
166166
executable, containing the game's Steam App Id.
167167

168168
Normally, games compiled with Steamworks will call

0 commit comments

Comments
 (0)