[fuchsia] Kernel compiler is now ready (flutter/engine#10309)
Also fixes the architecture of the bundled SO files.
This commit is contained in:
@@ -836,6 +836,7 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/natives.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/natives.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/system.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/system.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart/compiler.dart
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/builtin_libraries.cc
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/builtin_libraries.h
|
||||
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.cc
|
||||
|
||||
@@ -17,6 +17,7 @@ if (using_fuchsia_sdk) {
|
||||
|
||||
group("fuchsia") {
|
||||
deps = [
|
||||
"dart:kernel_compiler",
|
||||
"dart_runner:$dart_runner_target",
|
||||
"flutter:$flutter_runner_target",
|
||||
]
|
||||
|
||||
37
engine/src/flutter/shell/platform/fuchsia/dart/BUILD.gn
Normal file
37
engine/src/flutter/shell/platform/fuchsia/dart/BUILD.gn
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//third_party/dart/build/dart/dart_action.gni")
|
||||
import("//third_party/dart/utils/application_snapshot.gni")
|
||||
import("//third_party/dart/utils/compile_platform.gni")
|
||||
|
||||
application_snapshot("kernel_compiler") {
|
||||
main_dart = "compiler.dart"
|
||||
|
||||
deps = [
|
||||
"../flutter/kernel:kernel_platform_files",
|
||||
]
|
||||
|
||||
dot_packages = rebase_path("//third_party/dart/.packages")
|
||||
|
||||
training_args = [ "--train" ]
|
||||
|
||||
kernel_compiler_files =
|
||||
exec_script("//third_party/dart/tools/list_dart_files.py",
|
||||
[
|
||||
"absolute",
|
||||
rebase_path("."),
|
||||
],
|
||||
"list lines")
|
||||
|
||||
kernel_compiler_files +=
|
||||
exec_script("//third_party/dart/tools/list_dart_files.py",
|
||||
[
|
||||
"absolute",
|
||||
rebase_path("//third_party/dart/pkg"),
|
||||
],
|
||||
"list lines")
|
||||
|
||||
inputs = kernel_compiler_files
|
||||
}
|
||||
124
engine/src/flutter/shell/platform/fuchsia/dart/compiler.dart
Normal file
124
engine/src/flutter/shell/platform/fuchsia/dart/compiler.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
import 'package:vm/kernel_front_end.dart'
|
||||
show createCompilerArgParser, runCompiler, successExitCode;
|
||||
|
||||
final ArgParser _argParser = createCompilerArgParser()
|
||||
..addFlag('train',
|
||||
help: 'Run through sample command line to produce snapshot',
|
||||
negatable: false)
|
||||
..addOption('component-name', help: 'Name of the component')
|
||||
..addOption('data-dir',
|
||||
help: 'Name of the subdirectory of //data for output files')
|
||||
..addOption('manifest', help: 'Path to output Fuchsia package manifest');
|
||||
|
||||
String _usage = '''
|
||||
Usage: compiler [options] input.dart
|
||||
|
||||
Options:
|
||||
${_argParser.usage}
|
||||
''';
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
ArgResults options;
|
||||
|
||||
try {
|
||||
options = _argParser.parse(args);
|
||||
|
||||
if (options['train']) {
|
||||
final Directory temp =
|
||||
Directory.systemTemp.createTempSync('train_kernel_compiler');
|
||||
try {
|
||||
options = _argParser.parse(<String>[
|
||||
'--manifest=flutter',
|
||||
'--data-dir=${temp.absolute}',
|
||||
]);
|
||||
|
||||
await runCompiler(options, _usage);
|
||||
return;
|
||||
} finally {
|
||||
temp.deleteSync(recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.rest.isNotEmpty) {
|
||||
throw Exception('Must specify input.dart');
|
||||
}
|
||||
} on Exception catch (error) {
|
||||
print('ERROR: $error\n');
|
||||
print(_usage);
|
||||
exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
final compilerExitCode = await runCompiler(options, _usage);
|
||||
if (compilerExitCode != successExitCode) {
|
||||
exitCode = compilerExitCode;
|
||||
return;
|
||||
}
|
||||
|
||||
final String output = options['output'];
|
||||
final String dataDir = options.options.contains('component-name')
|
||||
? options['component-name']
|
||||
: options['data-dir'];
|
||||
final String manifestFilename = options['manifest'];
|
||||
|
||||
if (manifestFilename != null) {
|
||||
await createManifest(manifestFilename, dataDir, output);
|
||||
}
|
||||
}
|
||||
|
||||
Future createManifest(
|
||||
String packageManifestFilename, String dataDir, String output) async {
|
||||
List<String> packages = await File('$output-packages').readAsLines();
|
||||
|
||||
// Make sure the 'main' package is the last (convention with package loader).
|
||||
packages.remove('main');
|
||||
packages.add('main');
|
||||
|
||||
final IOSink packageManifest = File(packageManifestFilename).openWrite();
|
||||
|
||||
final String kernelListFilename = '$packageManifestFilename.dilplist';
|
||||
final IOSink kernelList = File(kernelListFilename).openWrite();
|
||||
for (String package in packages) {
|
||||
final String filenameInPackage = '$package.dilp';
|
||||
final String filenameInBuild = '$output-$package.dilp';
|
||||
packageManifest
|
||||
.write('data/$dataDir/$filenameInPackage=$filenameInBuild\n');
|
||||
kernelList.write('$filenameInPackage\n');
|
||||
}
|
||||
await kernelList.close();
|
||||
|
||||
final String frameworkVersionFilename =
|
||||
'$packageManifestFilename.frameworkversion';
|
||||
final IOSink frameworkVersion = File(frameworkVersionFilename).openWrite();
|
||||
for (String package in [
|
||||
'collection',
|
||||
'flutter',
|
||||
'meta',
|
||||
'typed_data',
|
||||
'vector_math'
|
||||
]) {
|
||||
Digest digest;
|
||||
if (packages.contains(package)) {
|
||||
final filenameInBuild = '$output-$package.dilp';
|
||||
final bytes = await File(filenameInBuild).readAsBytes();
|
||||
digest = sha256.convert(bytes);
|
||||
}
|
||||
frameworkVersion.write('$package=$digest\n');
|
||||
}
|
||||
await frameworkVersion.close();
|
||||
|
||||
packageManifest.write('data/$dataDir/app.dilplist=$kernelListFilename\n');
|
||||
packageManifest
|
||||
.write('data/$dataDir/app.frameworkversion=$frameworkVersionFilename\n');
|
||||
await packageManifest.close();
|
||||
}
|
||||
@@ -91,17 +91,22 @@ def FindFile(name, path):
|
||||
return os.path.join(root, name)
|
||||
|
||||
|
||||
def FindFileAndCopyTo(file_name, source, dest_parent, dst_name=None):
|
||||
found = FindFile(file_name, source)
|
||||
if not dst_name:
|
||||
dst_name = file_name
|
||||
if found:
|
||||
dst_path = os.path.join(dest_parent, dst_name)
|
||||
CopyPath(found, dst_path)
|
||||
|
||||
|
||||
def CopyGenSnapshotIfExists(source, destination):
|
||||
source_root = os.path.join(_out_dir, source)
|
||||
destination_base = os.path.join(destination, 'dart_binaries')
|
||||
gen_snapshot = FindFile('gen_snapshot', source_root)
|
||||
gen_snapshot_product = FindFile('gen_snapshot_product', source_root)
|
||||
if gen_snapshot:
|
||||
dst_path = os.path.join(destination_base, 'gen_snapshot')
|
||||
CopyPath(gen_snapshot, dst_path)
|
||||
if gen_snapshot_product:
|
||||
dst_path = os.path.join(destination_base, 'gen_snapshot_product')
|
||||
CopyPath(gen_snapshot_product, dst_path)
|
||||
FindFileAndCopyTo('gen_snapshot', source_root, destination_base)
|
||||
FindFileAndCopyTo('gen_snapshot_product', source_root, destination_base)
|
||||
FindFileAndCopyTo('kernel_compiler.dart.snapshot', source_root,
|
||||
destination_base, 'kernel_compiler.snapshot')
|
||||
|
||||
|
||||
def CopyToBucketWithMode(source, destination, aot, product, runner_type):
|
||||
@@ -157,6 +162,7 @@ def ProcessCIPDPakcage(upload, engine_version):
|
||||
|
||||
subprocess.check_call(command, cwd=_bucket_directory)
|
||||
|
||||
|
||||
def GetRunnerTarget(runner_type, product, aot):
|
||||
base = 'flutter/shell/platform/fuchsia/%s:' % runner_type
|
||||
if 'dart' in runner_type:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import("$flutter_root/tools/fuchsia/clang.gni")
|
||||
|
||||
fuchsia_sdk_base = "//fuchsia/sdk/$host_os/arch/$host_cpu"
|
||||
fuchsia_sdk_base = "//fuchsia/sdk/$host_os/arch/$target_cpu"
|
||||
fuchsia_sdk_lib = "$fuchsia_sdk_base/lib"
|
||||
sysroot_lib = "$fuchsia_sdk_base/sysroot/lib"
|
||||
sysroot_dist_lib = "$fuchsia_sdk_base/sysroot/dist/lib"
|
||||
|
||||
Reference in New Issue
Block a user