Skip to content

Commit

Permalink
Wire up Fuchsia SDK related updated for shell dependencies. flutter#8869
Browse files Browse the repository at this point in the history


This does not actually import the runners into the engine. It only sets up the targets so they need no modifications are necessary when the migration is done. The engine has been verified to build in both buildroots.
  • Loading branch information
chinmaygarde authored May 7, 2019
1 parent 444925f commit f6e6d39
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 47 deletions.
8 changes: 8 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

import("$flutter_root/common/config.gni")

if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
}

# Whether to build the dartdevc sdk, libraries, and source files
# required for the flutter web sdk.
declare_args() {
Expand All @@ -24,6 +28,10 @@ group("flutter") {
public_deps += [ "$flutter_root/shell/testing" ]
}

if (is_fuchsia && using_fuchsia_sdk) {
public_deps += [ "$flutter_root/shell/platform/fuchsia" ]
}

if (!is_fuchsia && !is_fuchsia_host) {
if (current_toolchain == host_toolchain) {
public_deps += [
Expand Down
1 change: 0 additions & 1 deletion ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ FILE: ../../../flutter/third_party/txt/src/txt/platform.h
FILE: ../../../flutter/third_party/txt/src/txt/platform_android.cc
FILE: ../../../flutter/third_party/txt/src/txt/platform_linux.cc
FILE: ../../../flutter/third_party/txt/src/txt/platform_mac.mm
FILE: ../../../flutter/vulkan/skia_vulkan_header.h
FILE: ../../../flutter/vulkan/vulkan_application.cc
FILE: ../../../flutter/vulkan/vulkan_application.h
FILE: ../../../flutter/vulkan/vulkan_backbuffer.cc
Expand Down
8 changes: 8 additions & 0 deletions common/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if (is_android) {
import("//build/config/android/config.gni")
}

if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
}

if (target_cpu == "arm" || target_cpu == "arm64") {
import("//build/config/arm.gni")
}
Expand Down Expand Up @@ -38,3 +42,7 @@ if (flutter_runtime_mode == "debug") {
} else {
feature_defines_list += [ "FLUTTER_RUNTIME_MODE=0" ]
}

if (is_fuchsia && using_fuchsia_sdk) {
feature_defines_list += [ "FUCHSIA_SDK=1" ]
}
25 changes: 17 additions & 8 deletions flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
}

source_set("flow") {
sources = [
"compositor_context.cc",
Expand Down Expand Up @@ -80,13 +84,19 @@ source_set("flow") {
"view_holder.h",
]

public_deps += [
"//sdk/fidl/fuchsia.ui.scenic",
"//sdk/fidl/fuchsia.ui.views",
"//sdk/lib/ui/scenic/cpp",
"//topaz/public/dart-pkg/zircon",
"//zircon/public/lib/zx",
]
if (using_fuchsia_sdk) {
public_deps += [
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
"$fuchsia_sdk_root/pkg:scenic_cpp",
]
} else {
public_deps += [
"//garnet/public/lib/ui/scenic/cpp",
"//sdk/fidl/fuchsia.ui.scenic",
"//topaz/public/dart-pkg/zircon",
"//zircon/public/lib/zx",
]
}
}
}

Expand All @@ -98,7 +108,6 @@ executable("flow_unittests") {
"flow_test_utils.cc",
"flow_test_utils.h",
"layers/performance_overlay_layer_unittests.cc",
"layers/physical_shape_layer_unittests.cc",
"matrix_decomposition_unittests.cc",
"raster_cache_unittests.cc",
]
Expand Down
3 changes: 1 addition & 2 deletions flow/scene_update_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "flutter/flow/layers/layer.h"
#include "flutter/flow/matrix_decomposition.h"
#include "flutter/fml/trace_event.h"
#include "flutter/lib/ui/window/viewport_metrics.h"

namespace flutter {

Expand Down Expand Up @@ -301,7 +300,7 @@ SceneUpdateContext::Frame::Frame(SceneUpdateContext& context,
paint_bounds_(SkRect::MakeEmpty()),
layer_(layer) {
if (local_elevation != 0.0) {
if (depth > flutter::kUnsetDepth && world_elevation >= depth) {
if (depth > -1 && world_elevation >= depth) {
// TODO(mklim): Deal with bounds overflow correctly.
FML_LOG(ERROR) << "Elevation " << world_elevation << " is outside of "
<< depth;
Expand Down
11 changes: 9 additions & 2 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/fuchsia/sdk.gni")

source_set("fml") {
sources = [
"arraysize.h",
Expand Down Expand Up @@ -83,7 +85,10 @@ source_set("fml") {

configs += [ "//third_party/icu:icu_config" ]

public_configs = [ "$flutter_root:config" ]
public_configs = [
"$flutter_root:config",
"$flutter_root/common:flutter_config",
]

libs = []

Expand Down Expand Up @@ -153,7 +158,9 @@ source_set("fml") {
if (is_fuchsia) {
sources += [ "platform/fuchsia/paths_fuchsia.cc" ]

public_deps += [ "//zircon/public/lib/trace" ]
if (!using_fuchsia_sdk) {
public_deps += [ "//zircon/public/lib/trace" ]
}
}

if (is_win) {
Expand Down
10 changes: 5 additions & 5 deletions fml/trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "flutter/fml/build_config.h"

#if defined(OS_FUCHSIA)
#if !defined(FUCHSIA_SDK)

// Forward to the system tracing mechanism on Fuchsia.

Expand All @@ -27,7 +28,8 @@
#define TRACE_EVENT_ASYNC_END1(a, b, c, d, e) TRACE_ASYNC_END(a, b, c, d, e)
#define TRACE_EVENT_INSTANT0(a, b) TRACE_INSTANT(a, b, TRACE_SCOPE_THREAD)

#endif // defined(OS_FUCHSIA)
#endif // !defined(FUCHSIA_SDK)
#endif // defined(OS_FUCHSIA)

#include <cstddef>
#include <cstdint>
Expand All @@ -39,8 +41,7 @@
#include "flutter/fml/time/time_point.h"
#include "third_party/dart/runtime/include/dart_tools_api.h"

#if !defined(OS_FUCHSIA)

#if !defined(OS_FUCHSIA) || defined(FUCHSIA_SDK)
#ifndef TRACE_EVENT_HIDE_MACROS

#define __FML__TOKEN_CAT__(x, y) x##y
Expand Down Expand Up @@ -103,8 +104,7 @@
::fml::tracing::TraceEventFlowEnd0(category, name, id);

#endif // TRACE_EVENT_HIDE_MACROS

#endif // !defined(OS_FUCHSIA)
#endif // !defined(OS_FUCHSIA) || defined(FUCHSIA_SDK)

namespace fml {
namespace tracing {
Expand Down
28 changes: 23 additions & 5 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# found in the LICENSE file.

import("//build/compiled_action.gni")
import("//build/fuchsia/sdk.gni")
import("//third_party/dart/utils/compile_platform.gni")
import("$flutter_root/common/config.gni")
import("$flutter_root/lib/ui/dart_ui.gni")

bindings_output_dir = "$root_gen_dir/sky/bindings"

copy("generate_dart_ui") {
visibility = [ ":*" ]
sources = dart_ui_files

outputs = [
Expand All @@ -20,7 +22,7 @@ copy("generate_dart_ui") {
compiled_action("generate_snapshot_bin") {
tool = "//third_party/dart/runtime/bin:gen_snapshot"

if (is_fuchsia || is_fuchsia_host) {
if ((is_fuchsia || is_fuchsia_host) && !using_fuchsia_sdk) {
platform_kernel =
"$root_out_dir/flutter_runner_patched_sdk/platform_strong.dill"
} else {
Expand Down Expand Up @@ -56,8 +58,7 @@ compiled_action("generate_snapshot_bin") {
rebase_path(isolate_snapshot_instructions),
]

if (is_debug && flutter_runtime_mode != "profile" &&
flutter_runtime_mode != "release") {
if (is_debug) {
args += [ "--enable_asserts" ]
}

Expand Down Expand Up @@ -206,7 +207,7 @@ bin_to_linkable("platform_strong_dill_linkable") {
deps = [
":kernel_platform_files",
]
if (is_fuchsia || is_fuchsia_host) {
if ((is_fuchsia || is_fuchsia_host) && !using_fuchsia_sdk) {
input = "$root_out_dir/flutter_runner_patched_sdk/platform_strong.dill"
} else {
input = "$root_out_dir/flutter_patched_sdk/platform_strong.dill"
Expand All @@ -231,6 +232,23 @@ source_set("snapshot") {
get_target_outputs(":platform_strong_dill_linkable")
}

compile_platform("non_strong_platform") {
single_root_scheme = "org-dartlang-sdk"
single_root_base = rebase_path("../../../")
libraries_specification_uri =
"org-dartlang-sdk:///flutter/lib/snapshot/libraries.json"

outputs = [
"$root_out_dir/flutter_patched_sdk/platform.dill",
"$root_out_dir/flutter_patched_sdk/vm_outline.dill",
]

args = [
"--target=flutter",
"dart:core",
]
}

compile_platform("strong_platform") {
single_root_scheme = "org-dartlang-sdk"
single_root_base = rebase_path("../../../")
Expand All @@ -254,7 +272,7 @@ compile_platform("strong_platform") {
}

# Fuchsia's snapshot requires a different platform with extra dart: libraries.
if (is_fuchsia || is_fuchsia_host) {
if ((is_fuchsia || is_fuchsia_host) && !using_fuchsia_sdk) {
group("kernel_platform_files") {
public_deps = [
"//topaz/runtime/flutter_runner/kernel:kernel_platform_files",
Expand Down
12 changes: 11 additions & 1 deletion lib/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/fuchsia/sdk.gni")

source_set("ui") {
sources = [
"compositing/scene.cc",
Expand Down Expand Up @@ -121,6 +123,14 @@ source_set("ui") {
"compositing/scene_host.h",
]

deps += [ "//topaz/public/dart-pkg/zircon" ]
if (using_fuchsia_sdk) {
deps += [
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
"$fuchsia_sdk_root/pkg:async-cpp",
]
} else {
deps += [ "//topaz/public/dart-pkg/zircon" ]
}
}
}
12 changes: 9 additions & 3 deletions lib/ui/compositing/scene_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "flutter/lib/ui/compositing/scene_host.h"

#include <lib/fsl/handles/object_info.h>
#include <lib/ui/scenic/cpp/view_token_pair.h>
#include <lib/zx/eventpair.h>
#include <third_party/tonic/dart_args.h>
Expand Down Expand Up @@ -75,6 +74,13 @@ void InvokeDartFunction(tonic::DartPersistentValue* function, T& arg) {
}
}

zx_koid_t GetKoid(zx_handle_t handle) {
zx_info_handle_basic_t info;
zx_status_t status = zx_object_get_info(handle, ZX_INFO_HANDLE_BASIC, &info,
sizeof(info), nullptr, nullptr);
return status == ZX_OK ? info.koid : ZX_KOID_INVALID;
}

} // namespace

namespace flutter {
Expand Down Expand Up @@ -113,7 +119,7 @@ fml::RefPtr<SceneHost> SceneHost::CreateViewHolder(
SceneHost::SceneHost(fml::RefPtr<zircon::dart::Handle> exportTokenHandle)
: gpu_task_runner_(
UIDartState::Current()->GetTaskRunners().GetGPUTaskRunner()),
id_(fsl::GetKoid(exportTokenHandle->handle())),
id_(GetKoid(exportTokenHandle->handle())),
use_view_holder_(false) {
gpu_task_runner_->PostTask(
[id = id_, handle = std::move(exportTokenHandle)]() {
Expand All @@ -128,7 +134,7 @@ SceneHost::SceneHost(fml::RefPtr<zircon::dart::Handle> viewHolderTokenHandle,
Dart_Handle viewStateChangedCallback)
: gpu_task_runner_(
UIDartState::Current()->GetTaskRunners().GetGPUTaskRunner()),
id_(fsl::GetKoid(viewHolderTokenHandle->handle())),
id_(GetKoid(viewHolderTokenHandle->handle())),
use_view_holder_(true) {
if (Dart_IsClosure(viewConnectedCallback)) {
view_connected_callback_ = std::make_unique<tonic::DartPersistentValue>(
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/compositing/scene_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_
#define FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_

#include <dart-pkg/zircon/sdk_ext/handle.h>
#include <lib/ui/scenic/cpp/id.h>
#include <stdint.h>
#include <third_party/tonic/dart_library_natives.h>
#include <third_party/tonic/dart_persistent_value.h>
#include <zircon/types.h>
#include "dart-pkg/zircon/sdk_ext/handle.h"

#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/task_runner.h"
Expand Down
4 changes: 2 additions & 2 deletions shell/common/skia_event_tracer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FlutterEventTracer : public SkEventTracer {
const uint8_t* p_arg_types,
const uint64_t* p_arg_values,
uint8_t flags) override {
#if defined(OS_FUCHSIA)
#if defined(OS_FUCHSIA) && !defined(FUCHSIA_SDK)
// In a manner analogous to "fml/trace_event.h", use Fuchsia's system
// tracing macros when running on Fuchsia.
switch (phase) {
Expand Down Expand Up @@ -85,7 +85,7 @@ class FlutterEventTracer : public SkEventTracer {
SkEventTracer::Handle handle) override {
// This is only ever called from a scoped trace event so we will just end
// the section.
#if defined(OS_FUCHSIA)
#if defined(OS_FUCHSIA) && !defined(FUCHSIA_SDK)
TRACE_DURATION_END(kSkiaTag, name);
#else
fml::tracing::TraceEventEnd(name);
Expand Down
4 changes: 3 additions & 1 deletion shell/testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/fuchsia/sdk.gni")

executable("testing") {
testonly = true

Expand All @@ -25,7 +27,7 @@ executable("testing") {
"//third_party/tonic",
]

if (is_fuchsia) {
if (is_fuchsia && !is_fuchsia_sdk) {
deps += [
"//garnet/public/lib/ui/scenic:client",
"//zircon/public/lib/trace",
Expand Down
4 changes: 2 additions & 2 deletions sky/packages/sky_engine/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/fuchsia/sdk.gni")
import("//third_party/dart/sdk/lib/_http/http_sources.gni")
import("//third_party/dart/sdk/lib/async/async_sources.gni")
import("//third_party/dart/sdk/lib/collection/collection_sources.gni")
Expand All @@ -13,7 +14,6 @@ import("//third_party/dart/sdk/lib/io/io_sources.gni")
import("//third_party/dart/sdk/lib/isolate/isolate_sources.gni")
import("//third_party/dart/sdk/lib/math/math_sources.gni")
import("//third_party/dart/sdk/lib/typed_data/typed_data_sources.gni")

import("$flutter_root/build/dart/rules.gni")
import("$flutter_root/lib/ui/dart_ui.gni")

Expand Down Expand Up @@ -170,7 +170,7 @@ dart_pkg("sky_engine") {
]
}

if (is_fuchsia) {
if (is_fuchsia && !using_fuchsia_sdk) {
import("//build/dart/dart_library.gni")

dart_library("sky_engine_dart") {
Expand Down
Loading

0 comments on commit f6e6d39

Please sign in to comment.