Skip to content

Commit 1fb033e

Browse files
committed
setup building both x32 & x64
1 parent 2b1cb35 commit 1fb033e

File tree

4 files changed

+67
-24
lines changed

4 files changed

+67
-24
lines changed

.cargo/config.toml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,44 @@
22
target-dir = "_build"
33

44
# FUCK YOU TO PEOPLE WITH OLD CPUS
5-
rustflags = ["-Ctarget-cpu=x86-64-v2"]
5+
#rustflags = ["-Ctarget-cpu=x86-64-v2"]
66

7-
target = "x86_64-pc-windows-msvc"
7+
target = "i686-pc-windows-msvc"
88

99
[env]
10+
CFLAGS_i686_pc_windows_msvc = "/Zi /FS"
11+
CXXFLAGS_i686_pc_windows_msvc = "/Zi /FS"
1012
CFLAGS_x86_64_pc_windows_msvc = "/Zi /FS"
1113
CXXFLAGS_x86_64_pc_windows_msvc = "/Zi /FS"
1214

1315
SRCWRTIMER_ROOT_DIR = { value = ".", relative = true }
1416

17+
18+
[target.i686-unknown-linux-gnu]
19+
rustflags = [
20+
# 2025... we can rely on CPUs to be using SSE2... not that it will likely change much in codegen...
21+
"-Ctarget-feature=+sse2",
22+
# Yeah, we want frame pointers...
23+
"-Cforce-frame-pointers=yes",
24+
]
25+
[target.i686-pc-windows-msvc]
26+
rustflags = [
27+
# 2025... we can rely on CPUs to be using SSE2... not that it will likely change much in codegen...
28+
"-Ctarget-feature=+sse2",
29+
# TODO: Do we want static crt on Windows? I can't remember if there was a reason for this...
30+
"-Ctarget-feature=+crt-static",
31+
# Yeah, we want frame pointers...
32+
"-Cforce-frame-pointers=yes",
33+
]
34+
35+
36+
[target.x86_64-unknown-linux-gnu]
37+
rustflags = [
38+
# FUCK YOU TO PEOPLE WITH OLD CPUS
39+
"-Ctarget-cpu=x86-64-v2",
40+
# Yeah, we want frame pointers...
41+
"-Cforce-frame-pointers=yes",
42+
]
1543
[target.x86_64-pc-windows-msvc]
1644
rustflags = [
1745
# FUCK YOU TO PEOPLE WITH OLD CPUS

.github/workflows/build-everything.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ jobs:
4545
uses: mlugg/setup-zig@v1
4646
with:
4747
version: '0.13.0' ### UPDATE Makefile.toml whenever this is updated.
48-
- name: Build extensions for Linux
49-
run: cargo make linux
50-
- name: Build extensions for Windows/MSVC
51-
run: cargo make msvc
48+
- name: Build extensions for Linux (x32)
49+
run: cargo make --profile x32 linux
50+
- name: Build extensions for Windows/MSVC (x32)
51+
run: cargo make --profile x32 msvc
52+
- name: Build extensions for Linux (x64)
53+
run: cargo make --profile x64 linux
54+
- name: Build extensions for Windows/MSVC (x64)
55+
run: cargo make --profile x64 msvc
5256
- name: Copy things to _package
5357
run: |
5458
cargo make copy-srcwrtimer

Makefile.toml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ SMBINVER="sourcemod-1.12.0-git7193-${HOSTOSPLAIN}" ### UPDATE .github/workflows/
9797
SMBINEXT = { source = "${OS}", default_value = "tar.gz", mapping = {"Windows_NT" = "zip"} }
9898
SPCOMP = { source = "${OS}", default_value = "spcomp64", mapping = {"Windows_NT" = "spcomp"} }
9999

100+
101+
TARGETARCH = "i686"
102+
[env.x64]
103+
# cargo make --profile x64 full
104+
TARGETARCH = "x86_64"
105+
[env.x32]
106+
# cargo make --profile x32 full
107+
TARGETARCH = "i686"
108+
109+
100110
################################################################################
101111
## asdf
102112
################################################################################
@@ -211,25 +221,24 @@ do_everything
211221
[tasks.copy-extensions]
212222
script_runner = "@duckscript"
213223
script = '''
214-
extdir = set "${PACKAGEDIR}/srcwrtimer/addons/sourcemod/extensions/x64"
215-
builddir = set "${CARGO_MAKE_WORKING_DIRECTORY}/_build"
216-
217224
fn copy_ext
225+
extdir = set "${PACKAGEDIR}/srcwrtimer/addons/sourcemod/extensions${3}"
218226
rm "${extdir}/${1}.ext.dll"
219227
rm "${extdir}/${1}.pdb"
220228
rm "${extdir}/${1}.ext.so"
221-
if is_path_exists "${builddir}/x86_64-pc-windows-msvc/release/${1}.dll"
222-
cp "${builddir}/x86_64-pc-windows-msvc/release/${1}.dll" "${extdir}/${1}.ext.dll"
223-
cp "${builddir}/x86_64-pc-windows-msvc/release/${1}.pdb" "${extdir}/${1}.pdb"
229+
if is_path_exists "${2}/${4}-pc-windows-msvc/release/${1}.dll"
230+
cp "${2}/${4}-pc-windows-msvc/release/${1}.dll" "${extdir}/${1}.ext.dll"
231+
cp "${2}/${4}-pc-windows-msvc/release/${1}.pdb" "${extdir}/${1}.pdb"
224232
end
225-
if is_path_exists "${builddir}/x86_64-unknown-linux-gnu/release/lib${1}.so"
226-
cp "${builddir}/x86_64-unknown-linux-gnu/release/lib${1}.so" "${extdir}/${1}.ext.so"
233+
if is_path_exists "${2}/${4}-unknown-linux-gnu/release/lib${1}.so"
234+
cp "${2}/${4}-unknown-linux-gnu/release/lib${1}.so" "${extdir}/${1}.ext.so"
227235
end
228236
end
229237
230238
members = split "${CARGO_MAKE_CRATE_WORKSPACE_MEMBERS}" ","
231239
for member in ${members}
232-
copy_ext ${member}
240+
copy_ext ${member} "${CARGO_MAKE_WORKING_DIRECTORY}/_build/" "" "i686"
241+
copy_ext ${member} "${CARGO_MAKE_WORKING_DIRECTORY}/_build" "/x64" "x86_64"
233242
end
234243
release ${handle}
235244
'''
@@ -304,19 +313,19 @@ toolchain = "nightly"
304313
command = "cargo"
305314
# CS:S binaries are now at 2.29 according to this:
306315
# objdump -T bin/*.so | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
307-
args = ["zigbuild", "--release", "--target", "x86_64-unknown-linux-gnu.2.29"]
316+
args = ["zigbuild", "--release", "--target", "${TARGETARCH}-unknown-linux-gnu.2.29"]
308317

309318
[tasks.msvc]
310319
toolchain = "nightly"
311320
command = "cargo"
312321
#env = { "CARGO_LOG" = "cargo::core::compiler::fingerprint=info" }
313-
args = ["build", "--release", "--target", "x86_64-pc-windows-msvc"]
322+
args = ["build", "--release", "--target", "${TARGETARCH}-pc-windows-msvc"]
314323

315324
# TODO: xwin not quite worky...
316-
[tasks.msvc.linux]
317-
toolchain = "nightly"
318-
command = "cargo"
319-
args = ["xwin", "build", "--xwin-arch", "x86_64", "--release", "--target", "x86_64-pc-windows-msvc"]
325+
#[tasks.msvc.linux]
326+
#toolchain = "nightly"
327+
#command = "cargo"
328+
#args = ["xwin", "build", "--xwin-arch", "x86", "--release", "--target", "${TARGETARCH}-pc-windows-msvc"]
320329

321330
################################################################################
322331
## asdf
@@ -325,12 +334,12 @@ args = ["xwin", "build", "--xwin-arch", "x86_64", "--release", "--target", "x86_
325334
[tasks.rustup-linux]
326335
toolchain = "nightly"
327336
command = "rustup"
328-
args = ["target", "add", "x86_64-unknown-linux-gnu"]
337+
args = ["target", "add", "${TARGETARCH}-unknown-linux-gnu"]
329338

330339
[tasks.rustup-msvc]
331340
toolchain = "nightly"
332341
command = "rustup"
333-
args = ["target", "add", "x86_64-pc-windows-msvc"]
342+
args = ["target", "add", "${TARGETARCH}-pc-windows-msvc"]
334343

335344
################################################################################
336345
## asdf

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ That's where all the SourceMod files are dumped after being built. Extensions, p
107107
# then install cargo-make...
108108
cargo install --force cargo-make
109109
# this will download zig, metamod-source, sourcemod, and hl2sdk... (and rust toolchains for i686-pc-windows-msvc & i686-unknown-linux-gnu), then it'll build things
110-
cargo make full
110+
cargo make --profile x32 full
111+
# this will build x64 (with rust toolchains for x86_64-pc-windows-msvc & x86_64-unknown-linux-gnu)
112+
cargo make --profile x64 full
111113
```
112114

113115
## Contributing

0 commit comments

Comments
 (0)