New make.dart

This commit is contained in:
Junyuan Feng
2022-04-15 19:48:43 +08:00
parent c524db9f59
commit 9663e4174d
2 changed files with 23 additions and 14 deletions

View File

@@ -2,9 +2,9 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 112; static const int build = 113;
static const String engine = 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"; "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 String buildAt = "2022-04-15 19:46:15.224203";
static const int modifications = 7; static const int modifications = 2;
} }

View File

@@ -83,7 +83,6 @@ void flutterRun(String? mode) {
} }
Future<void> flutterBuild(String source, String target, bool isAndroid) async { Future<void> flutterBuild(String source, String target, bool isAndroid) async {
final startTime = DateTime.now();
final build = await getGitCommitCount(); final build = await getGitCommitCount();
final args = [ final args = [
@@ -112,14 +111,12 @@ Future<void> flutterBuild(String source, String target, bool isAndroid) async {
} }
} }
print('Done.'); print('Done.\n');
} else { } else {
print(buildResult.stderr.toString()); print(buildResult.stderr.toString());
print('\nBuild failed with exit code $exitCode'); print('\nBuild failed with exit code $exitCode');
exit(exitCode); exit(exitCode);
} }
final endTime = DateTime.now();
print('Spent time: ${endTime.difference(startTime).toString()}');
} }
Future<void> flutterBuildIOS() async { Future<void> flutterBuildIOS() async {
@@ -144,16 +141,28 @@ void main(List<String> args) async {
case 'run': case 'run':
return flutterRun(args.length == 2 ? args[1] : null); return flutterRun(args.length == 2 ? args[1] : null);
case 'build': case 'build':
final stopwatch = Stopwatch()..start();
final buildFunc = [flutterBuildIOS, flutterBuildAndroid];
await updateBuildData();
dartFormat();
if (args.length > 1) { if (args.length > 1) {
await updateBuildData(); final platform = args[1];
dartFormat(); switch (platform) {
if (args[1] == 'android' || args[1] == 'harmony') { case 'ios':
return flutterBuildAndroid(); buildFunc.remove(flutterBuildIOS);
} else if (args[1] == 'ios') { break;
return flutterBuildIOS(); 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; return;
default: default:
print('Unsupported command: $command'); print('Unsupported command: $command');