Skip to content

Commit 0b406c3

Browse files
authored
Copy the Flutter Runner from //topaz into the engine. (flutter#8886)
Build rules and include paths have been updated as necessary. No other functional change.
1 parent 2b1f992 commit 0b406c3

75 files changed

Lines changed: 13311 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎ci/licenses_golden/licenses_flutter‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,13 @@ FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.cc
715715
FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.h
716716
FILE: ../../../flutter/shell/platform/embedder/vsync_waiter_embedder.cc
717717
FILE: ../../../flutter/shell/platform/embedder/vsync_waiter_embedder.h
718+
FILE: ../../../flutter/shell/platform/fuchsia/collect_traces.dart
719+
FILE: ../../../flutter/shell/platform/fuchsia/component.cc
720+
FILE: ../../../flutter/shell/platform/fuchsia/component.h
721+
FILE: ../../../flutter/shell/platform/fuchsia/compositor_context.cc
722+
FILE: ../../../flutter/shell/platform/fuchsia/compositor_context.h
723+
FILE: ../../../flutter/shell/platform/fuchsia/context_writer_bridge.cc
724+
FILE: ../../../flutter/shell/platform/fuchsia/context_writer_bridge.h
718725
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/fuchsia/lib/fuchsia.dart
719726
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/fuchsia/sdk_ext/fuchsia.cc
720727
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/fuchsia/sdk_ext/fuchsia.h
@@ -730,6 +737,35 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/natives.cc
730737
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/natives.h
731738
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/system.cc
732739
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/zircon/sdk_ext/system.h
740+
FILE: ../../../flutter/shell/platform/fuchsia/engine.cc
741+
FILE: ../../../flutter/shell/platform/fuchsia/engine.h
742+
FILE: ../../../flutter/shell/platform/fuchsia/fuchsia_font_manager.cc
743+
FILE: ../../../flutter/shell/platform/fuchsia/fuchsia_font_manager.h
744+
FILE: ../../../flutter/shell/platform/fuchsia/fuchsia_font_manager_unittest.cc
745+
FILE: ../../../flutter/shell/platform/fuchsia/isolate_configurator.cc
746+
FILE: ../../../flutter/shell/platform/fuchsia/isolate_configurator.h
747+
FILE: ../../../flutter/shell/platform/fuchsia/kernel/extract_far.dart
748+
FILE: ../../../flutter/shell/platform/fuchsia/kernel/framework_shim.dart
749+
FILE: ../../../flutter/shell/platform/fuchsia/kernel/libraries.json
750+
FILE: ../../../flutter/shell/platform/fuchsia/logging.h
751+
FILE: ../../../flutter/shell/platform/fuchsia/loop.cc
752+
FILE: ../../../flutter/shell/platform/fuchsia/loop.h
753+
FILE: ../../../flutter/shell/platform/fuchsia/main.cc
754+
FILE: ../../../flutter/shell/platform/fuchsia/meta/aot_product_runtime
755+
FILE: ../../../flutter/shell/platform/fuchsia/meta/aot_runtime
756+
FILE: ../../../flutter/shell/platform/fuchsia/meta/flutter_aot_product_runner.cmx
757+
FILE: ../../../flutter/shell/platform/fuchsia/meta/flutter_aot_runner.cmx
758+
FILE: ../../../flutter/shell/platform/fuchsia/meta/flutter_jit_product_runner.cmx
759+
FILE: ../../../flutter/shell/platform/fuchsia/meta/flutter_jit_runner.cmx
760+
FILE: ../../../flutter/shell/platform/fuchsia/meta/flutter_runner_tests.cmx
761+
FILE: ../../../flutter/shell/platform/fuchsia/meta/jit_product_runtime
762+
FILE: ../../../flutter/shell/platform/fuchsia/meta/jit_runtime
763+
FILE: ../../../flutter/shell/platform/fuchsia/platform_view.cc
764+
FILE: ../../../flutter/shell/platform/fuchsia/platform_view.h
765+
FILE: ../../../flutter/shell/platform/fuchsia/runner.cc
766+
FILE: ../../../flutter/shell/platform/fuchsia/runner.h
767+
FILE: ../../../flutter/shell/platform/fuchsia/runner_context.cc
768+
FILE: ../../../flutter/shell/platform/fuchsia/runner_context.h
733769
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/files.cc
734770
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/files.h
735771
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/handle_exception.cc
@@ -742,6 +778,29 @@ FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/vmo.cc
742778
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/vmo.h
743779
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/vmservice_object.cc
744780
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/vmservice_object.h
781+
FILE: ../../../flutter/shell/platform/fuchsia/service_provider_dir.cc
782+
FILE: ../../../flutter/shell/platform/fuchsia/service_provider_dir.h
783+
FILE: ../../../flutter/shell/platform/fuchsia/session_connection.cc
784+
FILE: ../../../flutter/shell/platform/fuchsia/session_connection.h
785+
FILE: ../../../flutter/shell/platform/fuchsia/surface.cc
786+
FILE: ../../../flutter/shell/platform/fuchsia/surface.h
787+
FILE: ../../../flutter/shell/platform/fuchsia/task_observers.cc
788+
FILE: ../../../flutter/shell/platform/fuchsia/task_observers.h
789+
FILE: ../../../flutter/shell/platform/fuchsia/task_runner_adapter.cc
790+
FILE: ../../../flutter/shell/platform/fuchsia/task_runner_adapter.h
791+
FILE: ../../../flutter/shell/platform/fuchsia/thread.cc
792+
FILE: ../../../flutter/shell/platform/fuchsia/thread.h
793+
FILE: ../../../flutter/shell/platform/fuchsia/unique_fdio_ns.h
794+
FILE: ../../../flutter/shell/platform/fuchsia/vsync_recorder.cc
795+
FILE: ../../../flutter/shell/platform/fuchsia/vsync_recorder.h
796+
FILE: ../../../flutter/shell/platform/fuchsia/vsync_waiter.cc
797+
FILE: ../../../flutter/shell/platform/fuchsia/vsync_waiter.h
798+
FILE: ../../../flutter/shell/platform/fuchsia/vulkan_surface.cc
799+
FILE: ../../../flutter/shell/platform/fuchsia/vulkan_surface.h
800+
FILE: ../../../flutter/shell/platform/fuchsia/vulkan_surface_pool.cc
801+
FILE: ../../../flutter/shell/platform/fuchsia/vulkan_surface_pool.h
802+
FILE: ../../../flutter/shell/platform/fuchsia/vulkan_surface_producer.cc
803+
FILE: ../../../flutter/shell/platform/fuchsia/vulkan_surface_producer.h
745804
FILE: ../../../flutter/shell/platform/glfw/client_wrapper/flutter_window_controller.cc
746805
FILE: ../../../flutter/shell/platform/glfw/client_wrapper/flutter_window_controller_unittests.cc
747806
FILE: ../../../flutter/shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h

‎shell/platform/BUILD.gn‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ group("platform") {
2626
]
2727
} else if (is_fuchsia) {
2828
# Fuchsia has its own runner implementation.
29-
deps = []
29+
deps = [
30+
"fuchsia",
31+
]
3032
} else {
3133
assert(false, "Unknown/Unsupported platform.")
3234
}

‎shell/platform/fuchsia/BUILD.gn‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
assert(is_fuchsia)
6+
7+
import("//build/fuchsia/sdk.gni")
8+
9+
executable("fuchsia") {
10+
output_name = "four_gate"
11+
12+
sources = [
13+
"component.cc",
14+
"component.h",
15+
"compositor_context.cc",
16+
"compositor_context.h",
17+
"context_writer_bridge.cc",
18+
"context_writer_bridge.h",
19+
"engine.cc",
20+
"engine.h",
21+
"fuchsia_font_manager.cc",
22+
"fuchsia_font_manager.h",
23+
"isolate_configurator.cc",
24+
"isolate_configurator.h",
25+
"logging.h",
26+
"loop.cc",
27+
"loop.h",
28+
"main.cc",
29+
"platform_view.cc",
30+
"platform_view.h",
31+
"runner.cc",
32+
"runner.h",
33+
"runner_context.cc",
34+
"runner_context.h",
35+
"service_provider_dir.cc",
36+
"service_provider_dir.h",
37+
"session_connection.cc",
38+
"session_connection.h",
39+
"surface.cc",
40+
"surface.h",
41+
"task_observers.cc",
42+
"task_observers.h",
43+
"task_runner_adapter.cc",
44+
"task_runner_adapter.h",
45+
"thread.cc",
46+
"thread.h",
47+
"unique_fdio_ns.h",
48+
"vsync_recorder.cc",
49+
"vsync_recorder.h",
50+
"vsync_waiter.cc",
51+
"vsync_waiter.h",
52+
"vulkan_surface.cc",
53+
"vulkan_surface.h",
54+
"vulkan_surface_pool.cc",
55+
"vulkan_surface_pool.h",
56+
"vulkan_surface_producer.cc",
57+
"vulkan_surface_producer.h",
58+
]
59+
60+
deps = [
61+
"$flutter_root/common",
62+
"$flutter_root/flow",
63+
"$flutter_root/fml",
64+
"$flutter_root/lib/ui",
65+
"$flutter_root/runtime",
66+
"$flutter_root/runtime:libdart",
67+
"$flutter_root/shell/common",
68+
"$flutter_root/vulkan",
69+
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
70+
"$fuchsia_sdk_root/fidl:fuchsia.images",
71+
"$fuchsia_sdk_root/fidl:fuchsia.io",
72+
"$fuchsia_sdk_root/fidl:fuchsia.modular",
73+
"$fuchsia_sdk_root/fidl:fuchsia.sys",
74+
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
75+
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
76+
"$fuchsia_sdk_root/pkg:async-cpp",
77+
"$fuchsia_sdk_root/pkg:async-loop",
78+
"$fuchsia_sdk_root/pkg:async-loop-cpp",
79+
"$fuchsia_sdk_root/pkg:fdio",
80+
"$fuchsia_sdk_root/pkg:fidl_cpp",
81+
"$fuchsia_sdk_root/pkg:scenic_cpp",
82+
"$fuchsia_sdk_root/pkg:syslog",
83+
"$fuchsia_sdk_root/pkg:zx",
84+
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
85+
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
86+
"dart-pkg/fuchsia",
87+
"dart-pkg/zircon",
88+
"runtime/dart/utils",
89+
"//third_party/tonic",
90+
]
91+
}

‎shell/platform/fuchsia/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Flutter Application Runner
2+
==========================
3+
4+
Implements the `fuchsia::sys::Runner` FIDL interface to launch and run mutliple Flutter applications within the same process.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
# Copyright 2013 The Flutter Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
import argparse
7+
import subprocess
8+
import os
9+
import sys
10+
11+
12+
def main():
13+
parser = argparse.ArgumentParser(description='Package a Flutter application')
14+
15+
parser.add_argument('--flutter-root', type=str, required=True,
16+
help='The root of the Flutter SDK')
17+
parser.add_argument('--flutter-tools', type=str, required=True,
18+
help='The executable for the Flutter tool')
19+
parser.add_argument('--asset-dir', type=str, required=True,
20+
help='The directory where to put intermediate files')
21+
parser.add_argument('--app-dir', type=str, required=True,
22+
help='The root of the app')
23+
parser.add_argument('--packages', type=str, required=True,
24+
help='The package map to use')
25+
parser.add_argument('--manifest', type=str, help='The application manifest')
26+
parser.add_argument('--component-name', type=str, help='The name of the component')
27+
parser.add_argument('--asset-manifest-out', type=str,
28+
help='Output path for the asset manifest used by the fuchsia packaging tool')
29+
30+
args = parser.parse_args()
31+
32+
env = os.environ.copy()
33+
env['FLUTTER_ROOT'] = args.flutter_root
34+
35+
call_args = [
36+
args.flutter_tools,
37+
'--asset-dir=%s' % args.asset_dir,
38+
'--packages=%s' % args.packages,
39+
]
40+
if 'manifest' in args:
41+
call_args.append('--manifest=%s' % args.manifest)
42+
43+
if args.asset_manifest_out:
44+
call_args.append('--asset-manifest-out=%s' % args.asset_manifest_out)
45+
46+
if args.component_name:
47+
call_args.append('--component-name=%s' % args.component_name)
48+
49+
result = subprocess.call(call_args, env=env, cwd=args.app_dir)
50+
51+
return result
52+
53+
if __name__ == '__main__':
54+
sys.exit(main())
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python
2+
# Copyright 2013 The Flutter Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
import argparse
6+
import os
7+
import re
8+
import sys
9+
def main():
10+
parser = argparse.ArgumentParser(
11+
sys.argv[0],
12+
description="Generate main file for Fuchsia dart test")
13+
parser.add_argument("--out",
14+
help="Path to .dart file to generate",
15+
required=True)
16+
parser.add_argument("--main-dart",
17+
help="Path to main.dart file to import",
18+
required=True)
19+
args = parser.parse_args()
20+
out_dir = os.path.dirname(args.out)
21+
assert os.path.isfile(os.path.join(os.path.dirname(args.out), args.main_dart))
22+
outfile = open(args.out, 'w')
23+
24+
# Ignores relative lib imports due to a few modules that complain about
25+
# this. It is also possible that a future may be unawaited given that main
26+
# may not always be synchronous across all functions.
27+
outfile.write('''// Generated by ''')
28+
outfile.write(os.path.basename(__file__))
29+
outfile.write('''
30+
31+
32+
// ignore_for_file: avoid_relative_lib_imports
33+
import 'dart:async';
34+
35+
import 'package:flutter_driver/driver_extension.dart';
36+
''')
37+
outfile.write("import '%s' as flutter_app_main;\n" % args.main_dart)
38+
outfile.write('''
39+
void main() async {
40+
assert(await (() async {
41+
// TODO(awdavies): Use the logger instead.
42+
print('Overriding app main method because flutter_driver_extendable '
43+
'is enabled in the build file');
44+
45+
try {
46+
// Enables Flutter Driver VM service extension
47+
//
48+
// This extension is required for tests that use package:flutter_driver
49+
// to drive applications from a separate process.
50+
enableFlutterDriverExtension();
51+
52+
// TODO(awdavies): Use the logger instead.
53+
print('flutter driver extensions enabled.');
54+
//ignore: avoid_catches_without_on_clauses
55+
} catch (e) {
56+
// TODO(awdavies): Use the logger instead.
57+
// Noop.
58+
print('flutter driver extensions not enabled. $e');
59+
}
60+
// Always return true so that the assert succeeds.
61+
return true;
62+
}()));
63+
// Execute the main method of the app under test
64+
var res = (flutter_app_main.main as dynamic)();
65+
if (res != null && res is Future) {
66+
await res;
67+
}
68+
}
69+
''')
70+
outfile.close()
71+
72+
if __name__ == '__main__':
73+
main()
74+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:io';
6+
import 'dart:convert';
7+
8+
bool includeFunction(String function) {
9+
return function.startsWith("dart:") ||
10+
function.startsWith("package:flutter/") ||
11+
function.startsWith("package:vector_math/");
12+
}
13+
14+
main(List<String> args) async {
15+
if (args.length != 1) {
16+
print("Usage:\n"
17+
" fx syslog | dart topaz/runtime/flutter_runner/collect_traces.dart output.txt");
18+
exitCode = 1;
19+
return;
20+
}
21+
22+
var functionCounts = Map<String, int>();
23+
24+
ProcessSignal.sigint.watch().listen((_) {
25+
var functions = List<String>();
26+
// TODO(flutter): Investigate consensus functions to avoid bloat.
27+
var minimumCount = 1;
28+
functionCounts.forEach((String function, int count) {
29+
if (count >= minimumCount) {
30+
functions.add(function);
31+
}
32+
});
33+
34+
functions.sort();
35+
36+
var sb = StringBuffer();
37+
for (var function in functions) {
38+
sb.writeln(function);
39+
}
40+
41+
File(args[0]).writeAsString(sb.toString(), flush: true).then((_) { exit(0); });
42+
});
43+
44+
final stdinAsLines = LineSplitter().bind(Utf8Decoder().bind(stdin));
45+
await for (final line in stdinAsLines) {
46+
final marker = "compilation-trace: ";
47+
final markerPosition = line.indexOf(marker);
48+
if (markerPosition == -1) {
49+
continue;
50+
}
51+
52+
final function = line.substring(markerPosition + marker.length);
53+
if (!includeFunction(function)) {
54+
continue;
55+
}
56+
print(function);
57+
58+
var count = functionCounts[function];
59+
if (count == null) {
60+
count = 1;
61+
} else {
62+
count++;
63+
}
64+
functionCounts[function] = count;
65+
}
66+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The compilation trace lists functions that will be compiled in the core
2+
snapshot. It is derived by unioning the output of Dart_SaveCompilationTrace
3+
after startup from a few apps.
4+
5+
To update this trace.
6+
- In //topaz/runtime/flutter_runner/engine.cc, change kCompilationTraceDelayInSeconds to a non-zero value.
7+
- Re-build.
8+
- Run `fx syslog | dart topaz/runtime/flutter_runner/collect_traces.dart topaz/runtime/flutter_runner/compilation_trace.txt`
9+
- Boot and run a few apps, making sure to exercise the interesting paths before the timer set above expires.
10+
- Send SIGINT (Ctrl-C) to collect_traces.dart.

0 commit comments

Comments
 (0)