Skip to content

Commit 7fc9380

Browse files
committed
macos support
1 parent 4bf0ff0 commit 7fc9380

5 files changed

Lines changed: 61 additions & 20 deletions

File tree

.github/workflows/build.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
shell: bash
2222
run: |
2323
if [[ "${{ github.event_name }}" == "push" ]]; then
24-
echo 'matrix={"include":[{"os":"ubuntu-latest"},{"os":"windows-latest"},{"os":"macos-13"},{"os":"macos-14"}]}' >> "$GITHUB_OUTPUT"
24+
echo 'matrix={"include":[{"os":"ubuntu-latest"},{"os":"windows-latest"},{"os":"macos-14"}]}' >> "$GITHUB_OUTPUT"
2525
else
26-
echo 'matrix={"include":[{"os":"ubuntu-latest"},{"os":"windows-latest"}]}' >> "$GITHUB_OUTPUT"
26+
echo 'matrix={"include":[{"os":"ubuntu-latest"},{"os":"windows-latest"},{"os":"macos-14"}]}' >> "$GITHUB_OUTPUT"
2727
fi
2828
2929
build:
@@ -107,6 +107,15 @@ jobs:
107107
chmod +x src/test/resources/lua53
108108
fi
109109
110+
- name: Install Lua 5.3 compiler (macOS)
111+
if: runner.os == 'macOS'
112+
env:
113+
HOMEBREW_NO_AUTO_UPDATE: '1'
114+
shell: bash
115+
run: |
116+
brew install lua@5.3
117+
echo "$(brew --prefix lua@5.3)/bin" >> "$GITHUB_PATH"
118+
110119
- name: Run tests
111120
shell: bash
112121
run: ./gradlew test --no-daemon --stacktrace
@@ -168,8 +177,8 @@ jobs:
168177
shopt -s nullglob
169178
zips=(upload/*.zip)
170179
echo "Found ${#zips[@]} zip(s):"; ls -alh upload
171-
if (( ${#zips[@]} < 4 )); then
172-
echo "ERROR: expected Win + Linux + macOS x64 + macOS arm64 zips (got ${#zips[@]})."
180+
if (( ${#zips[@]} < 3 )); then
181+
echo "ERROR: expected Win + Linux + macOS arm64 zips (got ${#zips[@]})."
173182
exit 1
174183
fi
175184

de.peeeq.wurstscript/deploy.gradle

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,24 @@ tasks.register("jlinkRuntime25", Exec) {
185185

186186
// 3) Assemble folder layout: jre + compiler.jar (no manifest)
187187
tasks.register("assembleSlimCompilerDist", Copy) {
188-
description = "Assembles dist folder with slim JRE and compiler.jar (no manifest)."
188+
description = "Assembles dist folder with JRE and compiler.jar (no manifest)."
189189
group = "distribution"
190-
dependsOn("jlinkRuntime25", "shadowJar")
191190

192-
from(jreImageDir) { into("wurst-runtime") }
193-
from(fatJar) { into("wurst-compiler") }
191+
if (os.isMacOsX()) {
192+
// On macOS, skip jlink entirely. Copying the original Temurin JDK preserves
193+
// Apple's codesignatures on dylibs/executables, which jlink would invalidate.
194+
// jmods/ (jlink inputs, ~150 MB) and include/ (C headers) are dev-only.
195+
dependsOn("shadowJar")
196+
from(javaHomeProvider) {
197+
into("wurst-runtime")
198+
exclude("jmods/**", "include/**")
199+
}
200+
} else {
201+
dependsOn("jlinkRuntime25", "shadowJar")
202+
from(jreImageDir) { into("wurst-runtime") }
203+
}
204+
205+
from(fatJar) { into("wurst-compiler") }
194206
into(distRoot)
195207

196208
doLast {

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/RunMap.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ private Path getCustomMapDataPath() {
225225
return Paths.get(customMapDataPath);
226226
}
227227

228+
if (Orient.isMacSystem()) {
229+
return Paths.get(System.getProperty("user.home"),
230+
"Library", "Application Support", "Blizzard", "Warcraft III", "CustomMapData");
231+
}
232+
228233
Path documents;
229234
try {
230235
documents = FileSystemView.getFileSystemView().getDefaultDirectory().toPath();
@@ -308,11 +313,17 @@ private Optional<String> findMapDocumentPath(String testMapName, File myDocument
308313

309314
if (!new File(documentPath.get()).exists()) {
310315
WLogger.info("Warcraft folder " + documentPath + " does not exist.");
311-
// Try wine default:
312-
documentPath = Optional.of(System.getProperty("user.home")
313-
+ "/.wine/drive_c/users/" + System.getProperty("user.name") + "/My Documents/Warcraft III");
316+
if (Orient.isMacSystem()) {
317+
// macOS 1.29+: ~/Library/Application Support/Blizzard/Warcraft III
318+
documentPath = Optional.of(System.getProperty("user.home")
319+
+ "/Library/Application Support/Blizzard/Warcraft III");
320+
} else {
321+
// Linux: try Wine default path
322+
documentPath = Optional.of(System.getProperty("user.home")
323+
+ "/.wine/drive_c/users/" + System.getProperty("user.name") + "/My Documents/Warcraft III");
324+
}
314325
if (!new File(documentPath.get()).exists()) {
315-
WLogger.severe("Severe: Wine Warcraft folder " + documentPath + " does not exist.");
326+
WLogger.severe("Severe: Warcraft folder " + documentPath + " does not exist.");
316327
}
317328
}
318329

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/utils/W3InstallationData.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,10 @@ public W3InstallationData(WurstLanguageServer languageServer, boolean shouldAskF
5959
public W3InstallationData(WurstLanguageServer languageServer, File wc3Path, boolean shouldAskForPath) {
6060
this.languageServer = languageServer;
6161
this.shouldAskForPath = shouldAskForPath;
62-
if (!Orient.isWindowsSystem()) {
63-
WLogger.warning("Game path configuration only works on windows");
64-
discoverExePath();
65-
discoverVersion();
66-
return;
67-
}
6862

69-
loadFromPath(wc3Path);
63+
if (Orient.isWindowsSystem() || Orient.isMacSystem()) {
64+
loadFromPath(wc3Path);
65+
}
7066

7167
if (!gameExe.isPresent()) {
7268
WLogger.warning("The provided wc3 path wasn't suitable. Falling back to discovery.");
@@ -77,7 +73,19 @@ public W3InstallationData(WurstLanguageServer languageServer, File wc3Path, bool
7773

7874
private void loadFromPath(File wc3Path) {
7975
try {
80-
gameExe = Optional.ofNullable(WinGameExeFinder.fromDirIgnoreVersion(wc3Path));
76+
if (Orient.isWindowsSystem()) {
77+
gameExe = Optional.ofNullable(WinGameExeFinder.fromDirIgnoreVersion(wc3Path));
78+
} else if (Orient.isMacSystem()) {
79+
// WC3 Reforged on macOS: <installDir>/x86_64/Warcraft III.app/Contents/MacOS/Warcraft III
80+
// Older layout: <installDir>/Warcraft III.app/Contents/MacOS/Warcraft III
81+
File x64 = new File(wc3Path, "x86_64/Warcraft III.app/Contents/MacOS/Warcraft III");
82+
File x32 = new File(wc3Path, "Warcraft III.app/Contents/MacOS/Warcraft III");
83+
if (x64.exists()) {
84+
gameExe = Optional.of(x64);
85+
} else if (x32.exists()) {
86+
gameExe = Optional.of(x32);
87+
}
88+
}
8189
} catch (NotFoundException e) {
8290
WLogger.severe(e);
8391
}

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/WurstScriptTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ private String getLuacExecutable() {
696696
candidates.add(cpUnix);
697697
}
698698
candidates.add("luac53");
699+
candidates.add("luac5.3");
699700
candidates.add("luac");
700701
}
701702

0 commit comments

Comments
 (0)