diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 19ec4084ebe..93ba1d7389c 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -214,7 +214,7 @@ "name": "dart2native", "rootUri": "../pkg/dart2native", "packageUri": "lib/", - "languageVersion": "2.12" + "languageVersion": "2.7" }, { "name": "dart_internal", diff --git a/pkg/dart2native/analysis_options.yaml b/pkg/dart2native/analysis_options.yaml index 1713ee63dd1..c84f27cb5e1 100644 --- a/pkg/dart2native/analysis_options.yaml +++ b/pkg/dart2native/analysis_options.yaml @@ -1,4 +1,10 @@ -include: package:lints/recommended.yaml +include: package:pedantic/analysis_options.1.8.0.yaml + +analyzer: + errors: + # Increase the severity of several hints. + prefer_single_quotes: warning + unused_import: warning linter: rules: diff --git a/pkg/dart2native/bin/dart2native.dart b/pkg/dart2native/bin/dart2native.dart index dbae9948682..ed18daf72a2 100644 --- a/pkg/dart2native/bin/dart2native.dart +++ b/pkg/dart2native/bin/dart2native.dart @@ -21,12 +21,10 @@ Generates an executable or an AOT snapshot from . Future main(List args) async { // If we're outputting to a terminal, wrap usage text to that width. - int? outputLineWidth; + int outputLineWidth; try { outputLineWidth = stdout.terminalColumns; - } catch (_) { - /* Ignore. */ - } + } catch (_) {/* Ignore. */} final ArgParser parser = ArgParser(usageLineLength: outputLineWidth) ..addMultiOption('define', abbr: 'D', valueHelp: 'key=value', help: ''' @@ -105,7 +103,7 @@ Sets the verbosity level used for filtering messages during compilation. final String sourceFile = parsedArgs.rest[0]; if (!FileSystemEntity.isFileSync(sourceFile)) { stderr.writeln( - '"$sourceFile" is not a file. See \'--help\' for more information.'); + '"${sourceFile}" is not a file. See \'--help\' for more information.'); await stderr.flush(); exit(1); } @@ -117,7 +115,7 @@ Sets the verbosity level used for filtering messages during compilation. outputFile: parsedArgs['output'], debugFile: parsedArgs['save-debugging-info'], packages: parsedArgs['packages'], - defines: parsedArgs['define'] ?? [], + defines: parsedArgs['define'], enableExperiment: parsedArgs['enable-experiment'], enableAsserts: parsedArgs['enable-asserts'], soundNullSafety: parsedArgs['sound-null-safety'], diff --git a/pkg/dart2native/lib/dart2native.dart b/pkg/dart2native/lib/dart2native.dart index 1776f7c5f46..3e51b53226a 100644 --- a/pkg/dart2native/lib/dart2native.dart +++ b/pkg/dart2native/lib/dart2native.dart @@ -44,7 +44,7 @@ Future generateAotKernel( String platformDill, String sourceFile, String kernelFile, - String? packages, + String packages, List defines, {String enableExperiment = '', List extraGenKernelOptions = const []}) { @@ -52,10 +52,10 @@ Future generateAotKernel( genKernel, '--platform', platformDill, - if (enableExperiment.isNotEmpty) '--enable-experiment=$enableExperiment', + if (enableExperiment.isNotEmpty) '--enable-experiment=${enableExperiment}', '--aot', '-Ddart.vm.product=true', - ...(defines.map((d) => '-D$d')), + ...(defines.map((d) => '-D${d}')), if (packages != null) ...['--packages', packages], '-o', kernelFile, @@ -65,16 +65,15 @@ Future generateAotKernel( } Future generateAotSnapshot( - String genSnapshot, - String kernelFile, - String snapshotFile, - bool enableAsserts, - List extraGenSnapshotOptions, { - String? debugFile, -}) { + String genSnapshot, + String kernelFile, + String snapshotFile, + String debugFile, + bool enableAsserts, + List extraGenSnapshotOptions) { return Process.run(genSnapshot, [ '--snapshot-kind=app-aot-elf', - '--elf=$snapshotFile', + '--elf=${snapshotFile}', if (debugFile != null) '--save-debugging-info=$debugFile', if (debugFile != null) '--dwarf-stack-traces', if (debugFile != null) '--strip', diff --git a/pkg/dart2native/lib/generate.dart b/pkg/dart2native/lib/generate.dart index 5a542ff6024..3df6176e647 100644 --- a/pkg/dart2native/lib/generate.dart +++ b/pkg/dart2native/lib/generate.dart @@ -3,32 +3,30 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:io'; - import 'package:path/path.dart' as path; - import 'dart2native.dart'; final Directory binDir = File(Platform.resolvedExecutable).parent; final String executableSuffix = Platform.isWindows ? '.exe' : ''; final String dartaotruntime = - path.join(binDir.path, 'dartaotruntime$executableSuffix'); + path.join(binDir.path, 'dartaotruntime${executableSuffix}'); final String genKernel = path.join(binDir.path, 'snapshots', 'gen_kernel.dart.snapshot'); final String genSnapshot = - path.join(binDir.path, 'utils', 'gen_snapshot$executableSuffix'); + path.join(binDir.path, 'utils', 'gen_snapshot${executableSuffix}'); final String productPlatformDill = path.join( binDir.parent.path, 'lib', '_internal', 'vm_platform_strong_product.dill'); Future generateNative({ String kind = 'exe', - required String sourceFile, - String? outputFile, - String? debugFile, - String? packages, - required List defines, + String sourceFile, + String outputFile, + String debugFile, + String packages, + List defines, String enableExperiment = '', bool enableAsserts = false, - bool? soundNullSafety, + bool soundNullSafety, bool verbose = false, String verbosity = 'all', List extraOptions = const [], @@ -39,13 +37,17 @@ Future generateNative({ if (packages != null) { packages = path.canonicalize(path.normalize(packages)); } - final Kind outputKind = {'aot': Kind.aot, 'exe': Kind.exe}[kind]!; + final Kind outputKind = { + 'aot': Kind.aot, + 'exe': Kind.exe, + }[kind]; final sourceWithoutDart = sourcePath.replaceFirst(RegExp(r'\.dart$'), ''); - final outputPath = path.canonicalize(path.normalize(outputFile ?? - { - Kind.aot: '$sourceWithoutDart.aot', - Kind.exe: '$sourceWithoutDart.exe', - }[outputKind]!)); + final outputPath = path.canonicalize(path.normalize(outputFile != null + ? outputFile + : { + Kind.aot: '${sourceWithoutDart}.aot', + Kind.exe: '${sourceWithoutDart}.exe', + }[outputKind])); final debugPath = debugFile != null ? path.canonicalize(path.normalize(debugFile)) : null; @@ -88,14 +90,8 @@ Future generateNative({ final String snapshotFile = (outputKind == Kind.aot ? outputPath : path.join(tempDir.path, 'snapshot.aot')); - final snapshotResult = await generateAotSnapshot( - genSnapshot, - kernelFile, - snapshotFile, - enableAsserts, - extraOptions, - debugFile: debugPath, - ); + final snapshotResult = await generateAotSnapshot(genSnapshot, kernelFile, + snapshotFile, debugPath, enableAsserts, extraOptions); if (snapshotResult.exitCode != 0) { stderr.writeln(snapshotResult.stdout); stderr.writeln(snapshotResult.stderr); @@ -117,7 +113,7 @@ Future generateNative({ } } - print('Generated: $outputPath'); + print('Generated: ${outputPath}'); } finally { tempDir.deleteSync(recursive: true); } diff --git a/pkg/dart2native/pubspec.yaml b/pkg/dart2native/pubspec.yaml index 49aa873fe24..4c274e7cc38 100644 --- a/pkg/dart2native/pubspec.yaml +++ b/pkg/dart2native/pubspec.yaml @@ -3,7 +3,7 @@ name: dart2native publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: "^2.7.0" # Add the bin/dart2native.dart script to the scripts pub installs. executables: @@ -16,4 +16,3 @@ dependencies: path: ../front_end dev_dependencies: - lints: ^1.0.0