Skip to content

Commit

Permalink
[fuchsia] core-jit (flutter#3753)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmacnak-google authored Jun 19, 2017
1 parent 105cc35 commit 2c611fd
Show file tree
Hide file tree
Showing 6 changed files with 4,718 additions and 4 deletions.
7 changes: 7 additions & 0 deletions build/aot_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def main():
help='Where to output dependency information')
parser.add_argument('--root-build-dir', type=str, required=True,
help='The root build dir for --depfile and --snapshot')
parser.add_argument('--checked', default=False, action='store_true',
help='Enable checked mode')

args = parser.parse_args()

Expand All @@ -48,6 +50,11 @@ def main():
cmd.append("--url_mapping=" + url_mapping)
for entry_points_manifest in args.entry_points_manifest:
cmd.append("--embedder_entry_points_manifest=" + entry_points_manifest)
if args.checked:
cmd.append('--enable_asserts')
cmd.append('--enable_type_checks')
cmd.append('--error_on_bad_type')
cmd.append('--error_on_bad_override')
cmd.append(args.main_dart)

result = subprocess.call(cmd, cwd=args.root_build_dir)
Expand Down
6 changes: 6 additions & 0 deletions build/flutter_app.gni
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ template("flutter_app") {
"--root-build-dir",
rebase_path(root_build_dir),
]
if (is_debug) {
args += [ "--checked" ]
}

deps = [
":$dart_package_name",
Expand Down Expand Up @@ -286,6 +289,9 @@ template("flutter_aot_app") {
"--root-build-dir",
rebase_path(root_build_dir),
]
if (is_debug) {
args += [ "--checked" ]
}

deps = [
":$dart_package_name",
Expand Down
12 changes: 11 additions & 1 deletion build/script_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ def main():
help='Where to output dependency information')
parser.add_argument('--root-build-dir', type=str, required=True,
help='The root build dir for --depfile and --snapshot')
parser.add_argument('--checked', default=False, action='store_true',
help='Enable checked mode')

args = parser.parse_args()

cmd = [
args.snapshotter_path,
'--enable_mirrors=false',
'--await_is_keyword',
'--assert_initializer',
'--snapshot_kind=script',
'--vm_snapshot_data=%s' % args.vm_snapshot_data,
'--vm_snapshot_instructions=%s' % args.vm_snapshot_instructions,
Expand All @@ -45,8 +50,13 @@ def main():
'--packages=%s' % args.packages,
'--script_snapshot=%s' % args.snapshot,
'--dependencies=%s' % args.depfile,
args.main_dart
]
if args.checked:
cmd.append('--enable_asserts')
cmd.append('--enable_type_checks')
cmd.append('--error_on_bad_type')
cmd.append('--error_on_bad_override')
cmd.append(args.main_dart)

result = subprocess.call(cmd, cwd=args.root_build_dir)
if result != 0:
Expand Down
75 changes: 72 additions & 3 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,55 @@ copy("generate_dart_ui") {
]
}

if (target_is_fuchsia) {
action("generate_package_map") {
dart_deps = [
"//lib/fidl/dart:dart",
"//lib/flutter/packages/flutter:flutter",
"//lib/widgets/packages/widgets:lib.widgets",
"//application/lib/app/dart:dart",
]

dot_packages_file = "$target_gen_dir/snapshot.packages"
outputs = [
dot_packages_file
]
deps = dart_deps
depfile = "$dot_packages_file.d"

script = "//build/dart/gen_dot_packages.py"
args = [
"--out",
rebase_path(dot_packages_file, root_build_dir),
"--source-dir",
rebase_path("."),
"--root-build-dir",
rebase_path(root_build_dir),
"--root-gen-dir",
rebase_path(root_gen_dir),
"--package-name",
"snapshot_root",
"--depfile",
rebase_path(depfile),
"--deps",
] + dart_deps
}
}

action("generate_snapshot_bin") {
if (target_is_fuchsia) {
snapshot_dart = "snapshot_fuchsia.dart"
# TODO(rmacnak): Fuchsia cross builds use the wrong Dart target
# architecture, and have added steps that depend on this error for
# reasonable build times (e.g., invoking the analyzer).
if (target_cpu == host_cpu) {
snapshot_kind = "core-jit"
} else {
snapshot_kind = "core"
}
} else {
snapshot_dart = "snapshot.dart"
snapshot_kind = "core"
}

deps = [
Expand All @@ -37,6 +81,10 @@ action("generate_snapshot_bin") {
"//dart/runtime/tools/create_snapshot_bin.py",
snapshot_dart,
] + dart_ui_files
if (target_is_fuchsia) {
deps += [ ":generate_package_map" ]
inputs += [ "fuchsia_compilation_trace.txt" ]
}

vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot.bin"
vm_snapshot_instructions = "$target_gen_dir/vm_snapshot_instructions.bin"
Expand All @@ -60,12 +108,16 @@ action("generate_snapshot_bin") {
args = [
"--executable",
rebase_path("$gen_snapshot_dir/gen_snapshot"),
"--package_root",
rebase_path("$root_gen_dir"),
"--script",
rebase_path(snapshot_dart),
"--snapshot_kind",
"core",
snapshot_kind,
"--vm_flag",
"--await_is_keyword",
"--vm_flag",
"--assert_initializer",
"--vm_flag",
"--enable_mirrors=false",
"--vm_output_bin",
rebase_path(vm_snapshot_data, root_build_dir),
"--vm_instructions_output_bin",
Expand All @@ -77,13 +129,30 @@ action("generate_snapshot_bin") {
"--url_mapping=dart:ui,$rebased_dart_ui_path",
]

if (is_debug) {
args += [
"--vm_flag",
"--enable_asserts",
"--vm_flag",
"--enable_type_checks",
"--vm_flag",
"--error_on_bad_type",
"--vm_flag",
"--error_on_bad_override",
]
}

if (target_is_fuchsia) {
inputs += fidl_dart_sdk_ext_files + mozart_dart_sdk_ext_files
fidl_internal_path = rebase_path(fidl_dart_sdk_ext_lib)
mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib)
args += [
"--url_mapping=dart:fidl.internal,$fidl_internal_path",
"--url_mapping=dart:mozart.internal,$mozart_internal_path",
"--packages",
rebase_path("$target_gen_dir/snapshot.packages"),
"--load_compilation_trace",
rebase_path("fuchsia_compilation_trace.txt"),
]
}
}
Expand Down
Loading

0 comments on commit 2c611fd

Please sign in to comment.