Skip to content

Commit fc1fa12

Browse files
committed
ci(msvc): compile launcher with MAGOS_TEST_BUILD for tests (+ Makefile Rust prereqs)
MSVC CI linked launcher.obj (compiled without the MAGOS_TEST_BUILD guard, so it retained main()) into test_steam_env.exe and test_injection.exe, which each define their own main -> LNK2005 / LNK1169. Compile a guarded launcher_test.obj and link that into the test exes instead; the production magos_launcher.exe stays unguarded. Also move /SUBSYSTEM:WINDOWS off the cl compile line (D9002) to the link step for stub_target.exe (it defines WinMain, so WINDOWS is correct). Mirrors the Makefile's tests/launcher.o rule. Makefile: the $(RUST_LIB) rule had no source prereqs, so incremental builds linked a stale staticlib when only Rust sources changed. Add discovery/src/*.rs + Cargo manifests as prereqs. (GNU make's ** is not recursive and expands to nothing here, so src/*.rs is listed explicitly.)
1 parent 842648a commit fc1fa12

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

.github/workflows/msvc-build.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,23 @@ jobs:
6868
set REL=target\x86_64-pc-windows-msvc\release
6969
:: Test runner object.
7070
cl /nologo /O2 /c tests\test_runner.c
71-
:: Launcher object (for test linking).
72-
cl /nologo /O2 /I launcher\src /c launcher\src\launcher.c
73-
:: Stub target — minimal GUI exe.
74-
cl /nologo /O2 /SUBSYSTEM:WINDOWS /Fe:tests\stub_target.exe tests\stub_target.c
71+
:: Launcher object for test linking — compiled with MAGOS_TEST_BUILD so
72+
:: launcher.c's main() is excluded (each test exe provides its own main).
73+
:: Mirrors the Makefile's tests/launcher.o rule. The production
74+
:: magos_launcher.exe (built above) is compiled WITHOUT the guard.
75+
cl /nologo /O2 /I launcher\src /DMAGOS_TEST_BUILD /c launcher\src\launcher.c /Fo:launcher_test.obj
76+
:: Stub target — minimal GUI exe (/SUBSYSTEM:WINDOWS is a linker flag,
77+
:: so it goes after /link, not on the cl compile line).
78+
cl /nologo /O2 /Fe:tests\stub_target.exe tests\stub_target.c /link /SUBSYSTEM:WINDOWS
7579
:: Stub shell — minimal DLL.
7680
cl /nologo /O2 /c tests\stub_shell.c
7781
link /nologo /DLL /OUT:tests\stub_shell.dll stub_shell.obj kernel32.lib
78-
:: test_steam_env.exe
82+
:: test_steam_env.exe — links the guarded launcher_test.obj (no main).
7983
cl /nologo /O2 /I launcher\src /Fe:tests\test_steam_env.exe ^
80-
tests\test_steam_env.c test_runner.obj launcher.obj kernel32.lib
81-
:: test_injection.exe
84+
tests\test_steam_env.c test_runner.obj launcher_test.obj kernel32.lib
85+
:: test_injection.exe — links the guarded launcher_test.obj (no main).
8286
cl /nologo /O2 /I launcher\src /Fe:tests\test_injection.exe ^
83-
tests\test_injection.c test_runner.obj launcher.obj kernel32.lib
87+
tests\test_injection.c test_runner.obj launcher_test.obj kernel32.lib
8488
8589
- name: Run C unit tests (native)
8690
shell: cmd

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ WINE ?= wine
2020

2121
REL_DIR := target/$(TARGET)/$(PROFILE)
2222
RUST_LIB := $(REL_DIR)/libmagos_discovery.a
23+
# Rust sources the staticlib depends on. GNU make's `**` is not recursive (it
24+
# expands to nothing here), so list src/*.rs explicitly. discovery/tests/*.rs
25+
# are separate integration-test binaries, not compiled into the staticlib.
26+
RUST_SRCS := $(wildcard discovery/src/*.rs)
2327
DLL := magos_shell.dll
2428
LAUNCHER := magos_launcher.exe
2529

@@ -54,7 +58,7 @@ TEST_EXES := tests/test_steam_env.exe tests/test_injection.exe
5458
all: build
5559

5660
rust-staticlib: $(RUST_LIB)
57-
$(RUST_LIB):
61+
$(RUST_LIB): $(RUST_SRCS) discovery/Cargo.toml Cargo.toml Cargo.lock
5862
$(CARGO) build --$(PROFILE) -p magos-discovery --target $(TARGET)
5963

6064
build: dll launcher

0 commit comments

Comments
 (0)