提交 0c000bdf 编写于 作者: A Adam Barth 提交者: GitHub

Get //flutter/runtime building on Fuchsia (#2922)

上级 fe509b0d
......@@ -8,12 +8,9 @@ group("flutter") {
if (is_fuchsia) {
# TODO(abarth) Remove this specific list once Fuchsia can build everything.
deps = [
"//flutter/assets",
"//flutter/flow",
"//flutter/glue",
"//flutter/lib/ui",
"//flutter/runtime",
"//flutter/snapshotter",
"//lib/tonic",
]
} else {
deps = [
......
......@@ -44,12 +44,6 @@ source_set("ui") {
"painting/rrect.h",
"painting/shader.cc",
"painting/shader.h",
"text/paragraph_builder.cc",
"text/paragraph_builder.h",
"text/paragraph.cc",
"text/paragraph.h",
"text/text_box.cc",
"text/text_box.h",
"ui_dart_state.cc",
"ui_dart_state.h",
"window/window.cc",
......@@ -64,7 +58,6 @@ source_set("ui") {
"//flutter/services/engine:interfaces",
"//flutter/services/pointer:interfaces",
"//flutter/skia",
"//flutter/sky/engine",
"//lib/tonic",
"//lib/tonic/mojo",
"//mojo/public/cpp/application",
......@@ -73,6 +66,21 @@ source_set("ui") {
"//mojo/services/asset_bundle/interfaces",
]
if (!is_fuchsia) {
sources += [
"text/paragraph_builder.cc",
"text/paragraph_builder.h",
"text/paragraph.cc",
"text/paragraph.h",
"text/text_box.cc",
"text/text_box.h",
]
deps += [
"//flutter/sky/engine",
]
}
if (is_android) {
deps += [
# TODO(abarth): In principle, these libraries should be fully independent.
......
......@@ -18,12 +18,16 @@
#include "flutter/lib/ui/painting/path.h"
#include "flutter/lib/ui/painting/picture_recorder.h"
#include "flutter/lib/ui/painting/picture.h"
#include "flutter/lib/ui/text/paragraph_builder.h"
#include "flutter/lib/ui/text/paragraph.h"
#include "flutter/lib/ui/window/window.h"
#include "lib/ftl/build_config.h"
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/logging/dart_error.h"
#if !defined(OS_FUCHSIA)
#include "flutter/lib/ui/text/paragraph_builder.h"
#include "flutter/lib/ui/text/paragraph.h"
#endif
using tonic::ToDart;
namespace blink {
......@@ -56,8 +60,10 @@ void DartUI::InitForGlobal() {
ImageShader::RegisterNatives(g_natives);
MaskFilter::RegisterNatives(g_natives);
MojoServices::RegisterNatives(g_natives);
#if !defined(OS_FUCHSIA)
Paragraph::RegisterNatives(g_natives);
ParagraphBuilder::RegisterNatives(g_natives);
#endif
Picture::RegisterNatives(g_natives);
PictureRecorder::RegisterNatives(g_natives);
Scene::RegisterNatives(g_natives);
......@@ -67,7 +73,7 @@ void DartUI::InitForGlobal() {
}
void DartUI::InitForIsolate() {
DCHECK(g_natives);
FTL_DCHECK(g_natives);
DART_CHECK_VALID(Dart_SetNativeResolver(Dart_LookupLibrary(ToDart("dart:ui")),
GetNativeFunction, GetSymbol));
}
......
......@@ -6,13 +6,16 @@
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/lib/ui/window/window.h"
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
#include "lib/tonic/converter/dart_converter.h"
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
#include "flutter/lib/jni/dart_jni.h"
#endif
#if !defined(OS_FUCHSIA)
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
#endif
using tonic::ToDart;
namespace blink {
......@@ -59,11 +62,13 @@ MojoServices* UIDartState::mojo_services() {
return mojo_services_.get();
}
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
DartJniIsolateData* UIDartState::jni_data() {
return jni_data_.get();
}
#endif
#endif // defined(OS_ANDROID)
#if !defined(OS_FUCHSIA)
void UIDartState::set_font_selector(PassRefPtr<FontSelector> selector) {
font_selector_ = selector;
......@@ -73,4 +78,6 @@ PassRefPtr<FontSelector> UIDartState::font_selector() {
return font_selector_;
}
#endif // !defined(OS_FUCHSIA)
} // namespace blink
......@@ -6,11 +6,14 @@
#define FLUTTER_LIB_UI_UI_DART_STATE_H_
#include "dart/runtime/include/dart_api.h"
#include "flutter/sky/engine/wtf/RefPtr.h"
#include "lib/ftl/build_config.h"
#include "lib/tonic/dart_persistent_value.h"
#include "lib/tonic/dart_state.h"
#if !defined(OS_FUCHSIA)
#include "flutter/sky/engine/wtf/RefPtr.h"
#endif
namespace blink {
class FontSelector;
class DartJniIsolateData;
......@@ -42,12 +45,14 @@ class UIDartState : public tonic::DartState {
void set_mojo_services(std::unique_ptr<MojoServices> mojo_services);
MojoServices* mojo_services();
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
DartJniIsolateData* jni_data();
#endif
#if !defined(OS_FUCHSIA)
void set_font_selector(PassRefPtr<FontSelector> selector);
PassRefPtr<FontSelector> font_selector();
#endif
private:
void DidSetIsolate() override;
......@@ -55,11 +60,15 @@ class UIDartState : public tonic::DartState {
IsolateClient* isolate_client_;
Dart_Port main_port_;
std::unique_ptr<MojoServices> mojo_services_;
#ifdef OS_ANDROID
std::unique_ptr<Window> window_;
#if defined(OS_ANDROID)
std::unique_ptr<DartJniIsolateData> jni_data_;
#endif
std::unique_ptr<Window> window_;
#if !defined(OS_FUCHSIA)
RefPtr<FontSelector> font_selector_;
#endif
};
} // namespace blink
......
......@@ -2,21 +2,33 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/dart/embedder/embedder.gni")
vmservice_sources_gypi =
exec_script("//build/gypi_to_gn.py",
[ rebase_path("//dart/runtime/bin/vmservice/vmservice_sources.gypi") ],
"scope",
[ rebase_path("//dart/runtime/bin/vmservice/vmservice_sources.gypi") ])
dart_embedder_resources("gen_embedded_resources_cc") {
action("gen_embedded_resources_cc") {
script = "//dart/runtime/tools/create_resources.py"
output_file = "$target_gen_dir/embedded_resources.cc"
outputs = [ output_file ]
inputs = rebase_path(vmservice_sources_gypi.sources,
"",
"//dart/runtime/bin/vmservice")
root_prefix = "//dart/runtime/bin/"
output = "$target_gen_dir/embedded_resources.cc"
table_name = "flutter_embedded_service_isolate"
args = [
"--output",
rebase_path(output_file),
"--outer_namespace",
"mojo", # TODO(abarth): Change namespace.
"--inner_namespace",
"dart", # TODO(abarth): Change namespace.
"--table_name",
"flutter_embedded_service_isolate",
"--root_prefix",
rebase_path("//dart/runtime/bin/"),
] + rebase_path(inputs)
}
source_set("embedded_resources_cc") {
......
......@@ -29,6 +29,7 @@
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/runtime/dart_service_isolate.h"
#include "flutter/runtime/start_up.h"
#include "lib/ftl/arraysize.h"
#include "lib/ftl/files/eintr_wrapper.h"
#include "lib/ftl/files/unique_fd.h"
#include "lib/ftl/logging.h"
......@@ -44,7 +45,7 @@
#include "lib/tonic/typed_data/uint8_list.h"
#include "mojo/public/platform/dart/dart_handle_watcher.h"
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
#include "flutter/lib/jni/dart_jni.h"
#endif
......@@ -159,7 +160,7 @@ bool DartFileModifiedCallback(const char* source_url, int64_t since_ms) {
}
void ThreadExitCallback() {
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
DartJni::OnThreadExit();
#endif
}
......@@ -271,7 +272,7 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
dart_state->class_library().add_provider("ui",
std::move(ui_class_provider));
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
DartJni::InitForIsolate();
std::unique_ptr<DartClassProvider> jni_class_provider(
new DartClassProvider(dart_state, "dart:jni"));
......@@ -325,7 +326,7 @@ static void ServiceStreamCancelCallback(const char* stream_id) {
}
}
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
DartJniIsolateData* GetDartJniDataForCurrentIsolate() {
return UIDartState::Current()->jni_data();
......@@ -499,7 +500,7 @@ void SetServiceIsolateHook(ServiceIsolateHook hook) {
void SetRegisterNativeServiceProtocolExtensionHook(
RegisterNativeServiceProtocolExtensionHook hook) {
CHECK(!g_service_isolate_initialized);
FTL_CHECK(!g_service_isolate_initialized);
g_register_native_service_protocol_extensions_hook = hook;
}
......@@ -583,7 +584,7 @@ void InitDartVM() {
#endif
DartUI::InitForGlobal();
#ifdef OS_ANDROID
#if defined(OS_ANDROID)
DartJni::InitForGlobal(GetDartJniDataForCurrentIsolate);
#endif
......
......@@ -14,7 +14,7 @@
namespace blink {
#define DART_ALLOW_DYNAMIC_RESOLUTION (defined(OS_IOS) || FLUTTER_AOT)
#define DART_ALLOW_DYNAMIC_RESOLUTION (OS_IOS || FLUTTER_AOT)
#if DART_ALLOW_DYNAMIC_RESOLUTION
......
......@@ -51,7 +51,7 @@ void SkyView::PopRoute() {
}
void SkyView::CreateView(const std::string& script_uri) {
DCHECK(!dart_controller_);
FTL_DCHECK(!dart_controller_);
dart_controller_.reset(new DartController());
std::unique_ptr<Window> window(new Window(this));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册