Skip to content

Commit 5296f03

Browse files
authored
macos support (#1185)
1 parent 4bf0ff0 commit 5296f03

4 files changed

Lines changed: 57 additions & 19 deletions

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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-latest"},{"os":"macos-15-intel"}]}' >> "$GITHUB_OUTPUT"
2525
else
2626
echo 'matrix={"include":[{"os":"ubuntu-latest"},{"os":"windows-latest"}]}' >> "$GITHUB_OUTPUT"
2727
fi
@@ -107,6 +107,13 @@ jobs:
107107
chmod +x src/test/resources/lua53
108108
fi
109109
110+
- name: Install Lua compiler (macOS)
111+
if: runner.os == 'macOS'
112+
env:
113+
HOMEBREW_NO_AUTO_UPDATE: '1'
114+
shell: bash
115+
run: brew install lua
116+
110117
- name: Run tests
111118
shell: bash
112119
run: ./gradlew test --no-daemon --stacktrace
@@ -169,7 +176,7 @@ jobs:
169176
zips=(upload/*.zip)
170177
echo "Found ${#zips[@]} zip(s):"; ls -alh upload
171178
if (( ${#zips[@]} < 4 )); then
172-
echo "ERROR: expected Win + Linux + macOS x64 + macOS arm64 zips (got ${#zips[@]})."
179+
echo "ERROR: expected Win + Linux + macOS arm64 + macOS x64 zips (got ${#zips[@]})."
173180
exit 1
174181
fi
175182

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: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,12 @@ 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

71-
if (!gameExe.isPresent()) {
67+
if (!gameExe.isPresent() || !version.isPresent()) {
7268
WLogger.warning("The provided wc3 path wasn't suitable. Falling back to discovery.");
7369
discoverExePath();
7470
discoverVersion();
@@ -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
}

0 commit comments

Comments
 (0)