From 2998f87f13fdfa1dfeffea30c28363734a6b1149 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sun, 24 Nov 2024 23:44:59 -0700 Subject: [PATCH] Make some windows specific fixes --- Dockerfile | 2 +- Jenkinsfile | 4 +--- bin/server.dart | 2 +- compile.bat | 5 ++++- compile.sh | 2 +- lib/consts.dart | 2 +- lib/wine.dart | 44 ++++++++++++++++++++++++++++++++++---------- pubspec.yaml | 2 +- 8 files changed, 44 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7238850..788a802 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ FROM git.zontreck.com/ariascreations/yolks:wine_8.0 WORKDIR /app -COPY --from=BUILDER /app/out/server /app/server +COPY --from=BUILDER /app/out/cemmserver /app/server COPY --from=RCONBUILD /app/mcrcon/mcrcon /app/rcon diff --git a/Jenkinsfile b/Jenkinsfile index 61400c8..4a131f6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,9 +69,7 @@ pipeline { steps { script { bat 'flutter pub get' - bat 'flutter build windows' - bat 'mkdir out' - bat 'dart compile exe -o out\\server.exe bin\\server.dart' + bat 'call compile.bat' } } diff --git a/bin/server.dart b/bin/server.dart index c6ad55a..c9606f8 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -20,7 +20,7 @@ void main() async { await settings.Read(); print( - "Server Admin Credentials\nUsername: ${settings.superuser.name}\nPassword (Default): changeMe123\n\n"); + "Server Admin Credentials\n> Username: ${settings.superuser.name}\n> Password (Default): changeMe123\n\n"); PathHelper helper = PathHelper(pth: Directory.current.path); helper = helper.resolve("data").mkdir(); diff --git a/compile.bat b/compile.bat index 0836b2f..749d941 100644 --- a/compile.bat +++ b/compile.bat @@ -1,3 +1,6 @@ @echo off -call flutter build windows \ No newline at end of file +call flutter pub get +call flutter build windows +mkdir out +call dart compile exe -o out\cemmserver.exe bin\server.dart \ No newline at end of file diff --git a/compile.sh b/compile.sh index 89fc033..4492437 100755 --- a/compile.sh +++ b/compile.sh @@ -14,7 +14,7 @@ then fi -dart compile exe -o out/server bin/server.dart +dart compile exe -o out/cemmserver bin/server.dart rsync -a --progress -h --delete build/linux/x64/release/bundle/ out/client/ if [ -f RELEASE ] diff --git a/lib/consts.dart b/lib/consts.dart index bc82af2..7785d83 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -1,3 +1,3 @@ class Consts { - static const VERSION = "1.1.112324.1959"; + static const VERSION = "1.1.112424.2344"; } diff --git a/lib/wine.dart b/lib/wine.dart index 20a35e1..859a4f6 100644 --- a/lib/wine.dart +++ b/lib/wine.dart @@ -4,7 +4,15 @@ import 'package:libac_dart/utils/IOTools.dart'; import 'package:servermanager/statemachine.dart'; import 'package:servermanager/structs/settings.dart'; +// A patch to allow windows to run software using the below methods. +Future requiresWine() async { + if (Platform.isWindows) return false; + return true; +} + Future runWine(String command, List argx) async { + bool requiredWine = await requiresWine(); + Settings settings = Settings(); Directory dir = Directory(settings.getWinePrefixPath()); @@ -20,11 +28,16 @@ Future runWine(String command, List argx) async { List args = [command]; args.addAll(argx); - ProcessResult res = await Process.run( - "wine", - args, // Run arbitrary command with arguments - environment: env, - ); + ProcessResult? res; + if (requiredWine) + res = await Process.run( + "wine", + args, // Run arbitrary command with arguments + environment: env, + ); + else + res = await Process.run(args[0], args.length > 1 ? args.sublist(1) : [], + environment: {}); print('Exit code: ${res.exitCode}'); print('stdout: ${res.stdout}'); @@ -35,6 +48,8 @@ Future runWine(String command, List argx) async { } Future runWinetrick(String trick) async { + if (!(await requiresWine())) return; + Settings settings = Settings(); Directory dir = Directory(settings.getWinePrefixPath()); @@ -65,6 +80,8 @@ Future runWinetrick(String trick) async { Future runDetachedWine( String command, List argx, String workingDir) async { + bool requiredWine = await requiresWine(); + Settings settings = Settings(); Directory dir = Directory(PathHelper.builder(settings.base_path).resolve("pfx").build()); @@ -81,11 +98,18 @@ Future runDetachedWine( List args = [command]; args.addAll(argx); - StateMachine.PROC = await Process.start( - "wine", args, // Run arbitrary command with arguments - environment: env, - workingDirectory: workingDir, - mode: ProcessStartMode.detachedWithStdio); + if (requiredWine) + StateMachine.PROC = await Process.start( + "wine", args, // Run arbitrary command with arguments + environment: env, + workingDirectory: workingDir, + mode: ProcessStartMode.detachedWithStdio); + else + StateMachine.PROC = await Process.start( + args[0], args.length > 1 ? args.sublist(1) : [], + environment: {}, + workingDirectory: workingDir, + mode: ProcessStartMode.detachedWithStdio); try { StateMachine.PROC!.stdout.forEach((line) {}); diff --git a/pubspec.yaml b/pubspec.yaml index 6272967..037d5f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.112324+1959 +version: 1.1.112424+2344 environment: sdk: ">=3.1.4 <4.0.0"