mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Revert "[pkg/dart2native] upgrade dart2native to null safe"
This reverts commit b6fad9c4f3
.
Reason for revert: Seeing failures in google3.
Original change's description:
> [pkg/dart2native] upgrade dart2native to null safe
>
> Change-Id: Ieef99b982bab14425a4df9f84a40d8ae1ba2bd79
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202402
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Devon Carew <devoncarew@google.com>
TBR=devoncarew@google.com,bkonyi@google.com
Change-Id: Idff233978847be421f7b59ab93d04da99c02cbf5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202722
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
parent
37806ba461
commit
6862fa1408
6 changed files with 44 additions and 46 deletions
|
@ -214,7 +214,7 @@
|
||||||
"name": "dart2native",
|
"name": "dart2native",
|
||||||
"rootUri": "../pkg/dart2native",
|
"rootUri": "../pkg/dart2native",
|
||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "2.12"
|
"languageVersion": "2.7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dart_internal",
|
"name": "dart_internal",
|
||||||
|
|
|
@ -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:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
|
|
|
@ -21,12 +21,10 @@ Generates an executable or an AOT snapshot from <main-dart-file>.
|
||||||
|
|
||||||
Future<void> main(List<String> args) async {
|
Future<void> main(List<String> args) async {
|
||||||
// If we're outputting to a terminal, wrap usage text to that width.
|
// If we're outputting to a terminal, wrap usage text to that width.
|
||||||
int? outputLineWidth;
|
int outputLineWidth;
|
||||||
try {
|
try {
|
||||||
outputLineWidth = stdout.terminalColumns;
|
outputLineWidth = stdout.terminalColumns;
|
||||||
} catch (_) {
|
} catch (_) {/* Ignore. */}
|
||||||
/* Ignore. */
|
|
||||||
}
|
|
||||||
|
|
||||||
final ArgParser parser = ArgParser(usageLineLength: outputLineWidth)
|
final ArgParser parser = ArgParser(usageLineLength: outputLineWidth)
|
||||||
..addMultiOption('define', abbr: 'D', valueHelp: 'key=value', help: '''
|
..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];
|
final String sourceFile = parsedArgs.rest[0];
|
||||||
if (!FileSystemEntity.isFileSync(sourceFile)) {
|
if (!FileSystemEntity.isFileSync(sourceFile)) {
|
||||||
stderr.writeln(
|
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();
|
await stderr.flush();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +115,7 @@ Sets the verbosity level used for filtering messages during compilation.
|
||||||
outputFile: parsedArgs['output'],
|
outputFile: parsedArgs['output'],
|
||||||
debugFile: parsedArgs['save-debugging-info'],
|
debugFile: parsedArgs['save-debugging-info'],
|
||||||
packages: parsedArgs['packages'],
|
packages: parsedArgs['packages'],
|
||||||
defines: parsedArgs['define'] ?? [],
|
defines: parsedArgs['define'],
|
||||||
enableExperiment: parsedArgs['enable-experiment'],
|
enableExperiment: parsedArgs['enable-experiment'],
|
||||||
enableAsserts: parsedArgs['enable-asserts'],
|
enableAsserts: parsedArgs['enable-asserts'],
|
||||||
soundNullSafety: parsedArgs['sound-null-safety'],
|
soundNullSafety: parsedArgs['sound-null-safety'],
|
||||||
|
|
|
@ -44,7 +44,7 @@ Future<ProcessResult> generateAotKernel(
|
||||||
String platformDill,
|
String platformDill,
|
||||||
String sourceFile,
|
String sourceFile,
|
||||||
String kernelFile,
|
String kernelFile,
|
||||||
String? packages,
|
String packages,
|
||||||
List<String> defines,
|
List<String> defines,
|
||||||
{String enableExperiment = '',
|
{String enableExperiment = '',
|
||||||
List<String> extraGenKernelOptions = const []}) {
|
List<String> extraGenKernelOptions = const []}) {
|
||||||
|
@ -52,10 +52,10 @@ Future<ProcessResult> generateAotKernel(
|
||||||
genKernel,
|
genKernel,
|
||||||
'--platform',
|
'--platform',
|
||||||
platformDill,
|
platformDill,
|
||||||
if (enableExperiment.isNotEmpty) '--enable-experiment=$enableExperiment',
|
if (enableExperiment.isNotEmpty) '--enable-experiment=${enableExperiment}',
|
||||||
'--aot',
|
'--aot',
|
||||||
'-Ddart.vm.product=true',
|
'-Ddart.vm.product=true',
|
||||||
...(defines.map((d) => '-D$d')),
|
...(defines.map((d) => '-D${d}')),
|
||||||
if (packages != null) ...['--packages', packages],
|
if (packages != null) ...['--packages', packages],
|
||||||
'-o',
|
'-o',
|
||||||
kernelFile,
|
kernelFile,
|
||||||
|
@ -65,16 +65,15 @@ Future<ProcessResult> generateAotKernel(
|
||||||
}
|
}
|
||||||
|
|
||||||
Future generateAotSnapshot(
|
Future generateAotSnapshot(
|
||||||
String genSnapshot,
|
String genSnapshot,
|
||||||
String kernelFile,
|
String kernelFile,
|
||||||
String snapshotFile,
|
String snapshotFile,
|
||||||
bool enableAsserts,
|
String debugFile,
|
||||||
List<String> extraGenSnapshotOptions, {
|
bool enableAsserts,
|
||||||
String? debugFile,
|
List<String> extraGenSnapshotOptions) {
|
||||||
}) {
|
|
||||||
return Process.run(genSnapshot, [
|
return Process.run(genSnapshot, [
|
||||||
'--snapshot-kind=app-aot-elf',
|
'--snapshot-kind=app-aot-elf',
|
||||||
'--elf=$snapshotFile',
|
'--elf=${snapshotFile}',
|
||||||
if (debugFile != null) '--save-debugging-info=$debugFile',
|
if (debugFile != null) '--save-debugging-info=$debugFile',
|
||||||
if (debugFile != null) '--dwarf-stack-traces',
|
if (debugFile != null) '--dwarf-stack-traces',
|
||||||
if (debugFile != null) '--strip',
|
if (debugFile != null) '--strip',
|
||||||
|
|
|
@ -3,32 +3,30 @@
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import 'dart2native.dart';
|
import 'dart2native.dart';
|
||||||
|
|
||||||
final Directory binDir = File(Platform.resolvedExecutable).parent;
|
final Directory binDir = File(Platform.resolvedExecutable).parent;
|
||||||
final String executableSuffix = Platform.isWindows ? '.exe' : '';
|
final String executableSuffix = Platform.isWindows ? '.exe' : '';
|
||||||
final String dartaotruntime =
|
final String dartaotruntime =
|
||||||
path.join(binDir.path, 'dartaotruntime$executableSuffix');
|
path.join(binDir.path, 'dartaotruntime${executableSuffix}');
|
||||||
final String genKernel =
|
final String genKernel =
|
||||||
path.join(binDir.path, 'snapshots', 'gen_kernel.dart.snapshot');
|
path.join(binDir.path, 'snapshots', 'gen_kernel.dart.snapshot');
|
||||||
final String genSnapshot =
|
final String genSnapshot =
|
||||||
path.join(binDir.path, 'utils', 'gen_snapshot$executableSuffix');
|
path.join(binDir.path, 'utils', 'gen_snapshot${executableSuffix}');
|
||||||
final String productPlatformDill = path.join(
|
final String productPlatformDill = path.join(
|
||||||
binDir.parent.path, 'lib', '_internal', 'vm_platform_strong_product.dill');
|
binDir.parent.path, 'lib', '_internal', 'vm_platform_strong_product.dill');
|
||||||
|
|
||||||
Future<void> generateNative({
|
Future<void> generateNative({
|
||||||
String kind = 'exe',
|
String kind = 'exe',
|
||||||
required String sourceFile,
|
String sourceFile,
|
||||||
String? outputFile,
|
String outputFile,
|
||||||
String? debugFile,
|
String debugFile,
|
||||||
String? packages,
|
String packages,
|
||||||
required List<String> defines,
|
List<String> defines,
|
||||||
String enableExperiment = '',
|
String enableExperiment = '',
|
||||||
bool enableAsserts = false,
|
bool enableAsserts = false,
|
||||||
bool? soundNullSafety,
|
bool soundNullSafety,
|
||||||
bool verbose = false,
|
bool verbose = false,
|
||||||
String verbosity = 'all',
|
String verbosity = 'all',
|
||||||
List<String> extraOptions = const [],
|
List<String> extraOptions = const [],
|
||||||
|
@ -39,13 +37,17 @@ Future<void> generateNative({
|
||||||
if (packages != null) {
|
if (packages != null) {
|
||||||
packages = path.canonicalize(path.normalize(packages));
|
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 sourceWithoutDart = sourcePath.replaceFirst(RegExp(r'\.dart$'), '');
|
||||||
final outputPath = path.canonicalize(path.normalize(outputFile ??
|
final outputPath = path.canonicalize(path.normalize(outputFile != null
|
||||||
{
|
? outputFile
|
||||||
Kind.aot: '$sourceWithoutDart.aot',
|
: {
|
||||||
Kind.exe: '$sourceWithoutDart.exe',
|
Kind.aot: '${sourceWithoutDart}.aot',
|
||||||
}[outputKind]!));
|
Kind.exe: '${sourceWithoutDart}.exe',
|
||||||
|
}[outputKind]));
|
||||||
final debugPath =
|
final debugPath =
|
||||||
debugFile != null ? path.canonicalize(path.normalize(debugFile)) : null;
|
debugFile != null ? path.canonicalize(path.normalize(debugFile)) : null;
|
||||||
|
|
||||||
|
@ -88,14 +90,8 @@ Future<void> generateNative({
|
||||||
final String snapshotFile = (outputKind == Kind.aot
|
final String snapshotFile = (outputKind == Kind.aot
|
||||||
? outputPath
|
? outputPath
|
||||||
: path.join(tempDir.path, 'snapshot.aot'));
|
: path.join(tempDir.path, 'snapshot.aot'));
|
||||||
final snapshotResult = await generateAotSnapshot(
|
final snapshotResult = await generateAotSnapshot(genSnapshot, kernelFile,
|
||||||
genSnapshot,
|
snapshotFile, debugPath, enableAsserts, extraOptions);
|
||||||
kernelFile,
|
|
||||||
snapshotFile,
|
|
||||||
enableAsserts,
|
|
||||||
extraOptions,
|
|
||||||
debugFile: debugPath,
|
|
||||||
);
|
|
||||||
if (snapshotResult.exitCode != 0) {
|
if (snapshotResult.exitCode != 0) {
|
||||||
stderr.writeln(snapshotResult.stdout);
|
stderr.writeln(snapshotResult.stdout);
|
||||||
stderr.writeln(snapshotResult.stderr);
|
stderr.writeln(snapshotResult.stderr);
|
||||||
|
@ -117,7 +113,7 @@ Future<void> generateNative({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print('Generated: $outputPath');
|
print('Generated: ${outputPath}');
|
||||||
} finally {
|
} finally {
|
||||||
tempDir.deleteSync(recursive: true);
|
tempDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ name: dart2native
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: "^2.7.0"
|
||||||
|
|
||||||
# Add the bin/dart2native.dart script to the scripts pub installs.
|
# Add the bin/dart2native.dart script to the scripts pub installs.
|
||||||
executables:
|
executables:
|
||||||
|
@ -16,4 +16,3 @@ dependencies:
|
||||||
path: ../front_end
|
path: ../front_end
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^1.0.0
|
|
||||||
|
|
Loading…
Reference in a new issue