Skip to content

Commit 50f22c7

Browse files
committed
For Windows the use native go build when CI=true (GitHub Actions sets this automatically), and falls back to the existing WSL cross-compile path for local Windows devs. Non-Windows hosts are unchanged.
1 parent e3cbdf3 commit 50f22c7

1 file changed

Lines changed: 31 additions & 20 deletions

File tree

tool/build_standalone_mwebd_windows.dart

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,37 @@ Future<void> main() async {
2828
"${tempBuildDir.path}"
2929
"${Platform.pathSeparator}mwebd",
3030
);
31-
final wslBuild = Platform.isWindows
32-
? await Process.start("wsl", [
33-
"bash",
34-
"-l",
35-
"-c",
36-
"GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc "
37-
"go build -o ../mwebd.exe github.com/ltcmweb/mwebd/cmd/mwebd",
38-
], runInShell: true)
39-
: await Process.start(
40-
"go",
41-
["build", "-o", "../mwebd.exe", "github.com/ltcmweb/mwebd/cmd/mwebd"],
42-
environment: {
43-
"GOOS": "windows",
44-
"GOARCH": "amd64",
45-
"CGO_ENABLED": "1",
46-
"CC": "x86_64-w64-mingw32-gcc",
47-
},
48-
runInShell: true,
49-
);
50-
await _waitForProcess(wslBuild);
31+
final isCI = Platform.environment['CI'] == 'true';
32+
final Process build;
33+
if (Platform.isWindows && isCI) {
34+
build = await Process.start(
35+
"go",
36+
["build", "-o", "../mwebd.exe", "github.com/ltcmweb/mwebd/cmd/mwebd"],
37+
environment: {"CGO_ENABLED": "1"},
38+
runInShell: true,
39+
);
40+
} else if (Platform.isWindows) {
41+
build = await Process.start("wsl", [
42+
"bash",
43+
"-l",
44+
"-c",
45+
"GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc "
46+
"go build -o ../mwebd.exe github.com/ltcmweb/mwebd/cmd/mwebd",
47+
], runInShell: true);
48+
} else {
49+
build = await Process.start(
50+
"go",
51+
["build", "-o", "../mwebd.exe", "github.com/ltcmweb/mwebd/cmd/mwebd"],
52+
environment: {
53+
"GOOS": "windows",
54+
"GOARCH": "amd64",
55+
"CGO_ENABLED": "1",
56+
"CC": "x86_64-w64-mingw32-gcc",
57+
},
58+
runInShell: true,
59+
);
60+
}
61+
await _waitForProcess(build);
5162

5263
// create assets/windows dir if needed
5364
final winAssetsDir = Directory(

0 commit comments

Comments
 (0)