From f34ddb799232b32c93e1bc68f52a2861a7762e93 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 11:34:21 -0800 Subject: [PATCH 1/7] [DO NOT SUBMIT] format test --- ci/bin/format.dart | 3 +- lib/web_ui/dev/build.dart | 60 +++++++++++++-------------------------- 2 files changed, 20 insertions(+), 43 deletions(-) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index 5f4c94b3345b3..09e3fbb9e6cb9 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -1283,8 +1283,7 @@ Future main(List arguments) async { parser.addMultiOption('check', abbr: 'c', allowed: formatCheckNames(), - // TODO(goderbauer): Enable dart by default when we turned on the formatter. - defaultsTo: formatCheckNames()..remove(FormatCheck.dart.name), + defaultsTo: formatCheckNames(), help: 'Specifies which checks will be performed. Defaults to all checks. ' 'May be specified more than once to perform multiple types of checks. '); parser.addFlag('verbose', help: 'Print verbose output.', defaultsTo: verbose); diff --git a/lib/web_ui/dev/build.dart b/lib/web_ui/dev/build.dart index 58ca394dc9bb3..df1fe19123c88 100644 --- a/lib/web_ui/dev/build.dart +++ b/lib/web_ui/dev/build.dart @@ -28,29 +28,34 @@ class BuildCommand extends Command with ArgUtils { argParser.addFlag( 'watch', abbr: 'w', - help: 'Run the build in watch mode so it rebuilds whenever a change is ' + help: + 'Run the build in watch mode so it rebuilds whenever a change is ' 'made. Disabled by default.', ); argParser.addFlag( 'host', - help: 'Build the host build instead of the wasm build, which is ' - 'currently needed for `flutter run --local-engine` to work.' + help: + 'Build the host build instead of the wasm build, which is ' + 'currently needed for `flutter run --local-engine` to work.', ); argParser.addFlag( 'profile', - help: 'Build in profile mode instead of release mode. In this mode, the ' + help: + 'Build in profile mode instead of release mode. In this mode, the ' 'output will be located at "out/wasm_profile".\nThis only applies to ' 'the wasm build. The host build is always built in release mode.', ); argParser.addFlag( 'debug', - help: 'Build in debug mode instead of release mode. In this mode, the ' + help: + 'Build in debug mode instead of release mode. In this mode, the ' 'output will be located at "out/wasm_debug".\nThis only applies to ' 'the wasm build. The host build is always built in release mode.', ); argParser.addFlag( 'dwarf', - help: 'Embed DWARF debugging info into the output wasm modules. This is ' + help: + 'Embed DWARF debugging info into the output wasm modules. This is ' 'only valid in debug mode.', ); } @@ -75,11 +80,7 @@ class BuildCommand extends Command with ArgUtils { } final FilePath libPath = FilePath.fromWebUi('lib'); final List steps = [ - GnPipelineStep( - host: host, - runtimeMode: runtimeMode, - embedDwarf: embedDwarf, - ), + GnPipelineStep(host: host, runtimeMode: runtimeMode, embedDwarf: embedDwarf), NinjaPipelineStep( host: host, runtimeMode: runtimeMode, @@ -108,11 +109,7 @@ class BuildCommand extends Command with ArgUtils { /// Not safe to interrupt as it may leave the `out/` directory in a corrupted /// state. GN is pretty quick though, so it's OK to not support interruption. class GnPipelineStep extends ProcessStep { - GnPipelineStep({ - required this.host, - required this.runtimeMode, - required this.embedDwarf, - }); + GnPipelineStep({required this.host, required this.runtimeMode, required this.embedDwarf}); final bool host; final RuntimeMode runtimeMode; @@ -126,18 +123,13 @@ class GnPipelineStep extends ProcessStep { List get _gnArgs { if (host) { - return [ - '--unoptimized', - '--full-dart-sdk', - ]; + return ['--unoptimized', '--full-dart-sdk']; } else { return [ '--web', '--runtime-mode=${runtimeMode.name}', - if (runtimeMode == RuntimeMode.debug) - '--unoptimized', - if (embedDwarf) - '--wasm-use-dwarf', + if (runtimeMode == RuntimeMode.debug) '--unoptimized', + if (embedDwarf) '--wasm-use-dwarf', ]; } } @@ -145,10 +137,7 @@ class GnPipelineStep extends ProcessStep { @override Future createProcess() { print('Running gn...'); - return startProcess( - path.join(environment.flutterDirectory.path, 'tools', 'gn'), - _gnArgs, - ); + return startProcess(path.join(environment.flutterDirectory.path, 'tools', 'gn'), _gnArgs); } } @@ -156,11 +145,7 @@ class GnPipelineStep extends ProcessStep { /// /// Can be safely interrupted. class NinjaPipelineStep extends ProcessStep { - NinjaPipelineStep({ - required this.host, - required this.runtimeMode, - required this.targets, - }); + NinjaPipelineStep({required this.host, required this.runtimeMode, required this.targets}); @override String get description => 'ninja'; @@ -182,13 +167,6 @@ class NinjaPipelineStep extends ProcessStep { @override Future createProcess() { print('Running autoninja...'); - return startProcess( - 'autoninja', - [ - '-C', - buildDirectory, - ...targets, - ], - ); + return startProcess('autoninja', ['-C', buildDirectory, ...targets]); } } From a1508d80e789d8b8af6211f7f61572b8374759de Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 12:31:26 -0800 Subject: [PATCH 2/7] style check --- lib/web_ui/dev/build.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/web_ui/dev/build.dart b/lib/web_ui/dev/build.dart index df1fe19123c88..08f60a34e7434 100644 --- a/lib/web_ui/dev/build.dart +++ b/lib/web_ui/dev/build.dart @@ -23,6 +23,15 @@ const Map targetAliases = { 'archive': 'flutter/web_sdk:flutter_web_sdk_archive', }; +// Check new style +enum Foo { + a, + b, + c, +} +// This line is 99 long +List a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]; + class BuildCommand extends Command with ArgUtils { BuildCommand() { argParser.addFlag( From acaa576cd79083e3ba2d7bbadd43a8b1ab0e4fb8 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 13:46:15 -0800 Subject: [PATCH 3/7] test --- ci/bin/format.dart | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index 09e3fbb9e6cb9..4b9d0cb7115a0 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -921,6 +921,26 @@ class DartFormatChecker extends FormatChecker { } else { message('All dart files formatted correctly.'); } + + Directory dir = Directory(path.join(_processRunner.defaultWorkingDirectory.path, 'lib', 'web_ui', 'dev')); + while (true) { + final File file = File(path.join(dir.path, '.dart_tool', 'package_config.json')); + if (file.existsSync()) { + stdout.writeln(); + stdout.writeln('HHHHHHHHHHHHHHHHH: ${file.path}'); + stdout.write(file.readAsStringSync()); + stdout.writeln(); + } + if (dir.parent.path == dir.path) { + break; + } + dir = dir.parent; + } + stdout.writeln('dart --version: ${Process.runSync(_dartBin, ['--version']).stdout}'); + stdout.writeln('dart format --version: ${Process.runSync(_dartBin, ['format', '--version']).stdout}'); + + + return incorrect.length; } } From b0c032ae15e123d7562d564933bb56ee8d26d922 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 15:16:05 -0800 Subject: [PATCH 4/7] delete --- ci/bin/format.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index 4b9d0cb7115a0..198c8cf480e13 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -840,6 +840,16 @@ class DartFormatChecker extends FormatChecker { } Future _runDartFormat({required bool fixing}) async { + for (final Directory dir in _processRunner.defaultWorkingDirectory.listSync().whereType()) { + if (path.basename(dir.path) == '.dart_tool') { + continue; + } + for (final Directory subdir in dir.listSync().whereType().where((Directory dir) => path.basename(dir.path) == '.dart_tool')) { + print('Deleting ${subdir.path}'); + subdir.deleteSync(recursive: true); + } + } + final List filesToCheck = await getFileList(['*.dart']); final List cmd = [ From dec80cb09679058fa525e5872f33dee7fc44417e Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 15:19:14 -0800 Subject: [PATCH 5/7] ++ --- ci/bin/format.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index 198c8cf480e13..b15821e739e6e 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -844,7 +844,7 @@ class DartFormatChecker extends FormatChecker { if (path.basename(dir.path) == '.dart_tool') { continue; } - for (final Directory subdir in dir.listSync().whereType().where((Directory dir) => path.basename(dir.path) == '.dart_tool')) { + for (final Directory subdir in dir.listSync(recursive: true).whereType().where((Directory dir) => path.basename(dir.path) == '.dart_tool')) { print('Deleting ${subdir.path}'); subdir.deleteSync(recursive: true); } From a60149f4aca72047bba0f592e3208e0463b740da Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 15:31:08 -0800 Subject: [PATCH 6/7] ++ --- ci/bin/format.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index b15821e739e6e..718c708d09236 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -845,6 +845,9 @@ class DartFormatChecker extends FormatChecker { continue; } for (final Directory subdir in dir.listSync(recursive: true).whereType().where((Directory dir) => path.basename(dir.path) == '.dart_tool')) { + if (subdir.path.contains('third_party')) { + continue; + } print('Deleting ${subdir.path}'); subdir.deleteSync(recursive: true); } From 2f7654bbbd6b7a386436237231bcaf044b302e5b Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 12 Dec 2024 15:35:26 -0800 Subject: [PATCH 7/7] ++ --- ci/bin/format.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index 718c708d09236..b2cee1a73b033 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -845,7 +845,7 @@ class DartFormatChecker extends FormatChecker { continue; } for (final Directory subdir in dir.listSync(recursive: true).whereType().where((Directory dir) => path.basename(dir.path) == '.dart_tool')) { - if (subdir.path.contains('third_party')) { + if (subdir.path.contains('third_party') || subdir.path.contains('impeller/tessellator/dart') || subdir.path.contains('tools') || subdir.path.contains('shell/vmservice') || subdir.path.contains('ci') || subdir.path.contains('testing') || subdir.path.contains('flutter_frontend_server')) { continue; } print('Deleting ${subdir.path}');