From 9663e4174dae96f759030a0f25be80afb4571b75 Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Fri, 15 Apr 2022 19:48:43 +0800 Subject: [PATCH] New make.dart --- lib/data/res/build_data.dart | 6 +++--- make.dart | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 2198e624..c71e1a33 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 112; + static const int build = 113; static const String engine = "Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision c860cba910 (3 weeks ago) • 2022-03-25 00:23:12 -0500\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n"; - static const String buildAt = "2022-04-15 19:07:21.221650"; - static const int modifications = 7; + static const String buildAt = "2022-04-15 19:46:15.224203"; + static const int modifications = 2; } diff --git a/make.dart b/make.dart index 29809e8d..042de8e2 100755 --- a/make.dart +++ b/make.dart @@ -83,7 +83,6 @@ void flutterRun(String? mode) { } Future flutterBuild(String source, String target, bool isAndroid) async { - final startTime = DateTime.now(); final build = await getGitCommitCount(); final args = [ @@ -112,14 +111,12 @@ Future flutterBuild(String source, String target, bool isAndroid) async { } } - print('Done.'); + print('Done.\n'); } else { print(buildResult.stderr.toString()); print('\nBuild failed with exit code $exitCode'); exit(exitCode); } - final endTime = DateTime.now(); - print('Spent time: ${endTime.difference(startTime).toString()}'); } Future flutterBuildIOS() async { @@ -144,16 +141,28 @@ void main(List args) async { case 'run': return flutterRun(args.length == 2 ? args[1] : null); case 'build': + final stopwatch = Stopwatch()..start(); + final buildFunc = [flutterBuildIOS, flutterBuildAndroid]; + await updateBuildData(); + dartFormat(); if (args.length > 1) { - await updateBuildData(); - dartFormat(); - if (args[1] == 'android' || args[1] == 'harmony') { - return flutterBuildAndroid(); - } else if (args[1] == 'ios') { - return flutterBuildIOS(); + final platform = args[1]; + switch (platform) { + case 'ios': + buildFunc.remove(flutterBuildIOS); + break; + case 'android': + buildFunc.remove(flutterBuildAndroid); + break; + default: + print('Unknown platform: $platform'); + exit(1); } - print('unkonwn build arg: ${args[1]}'); } + for (final func in buildFunc) { + await func(); + } + print('Build finished in ${stopwatch.elapsed}'); return; default: print('Unsupported command: $command');