Skip to content

Commit

Permalink
fuchsia: Convert legacy permutations to build flag (flutter#20647)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbreng authored Aug 20, 2020
1 parent 6caad8e commit 4dc8662
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 546 deletions.
16 changes: 5 additions & 11 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ config("config") {
cflags = [ "/WX" ] # Treat warnings as errors.
}
}
}

# This "fuchsia_legacy" configuration includes old, non-embedder API sources and
# defines the LEGACY_FUCHSIA_EMBEDDER symbol. This config and its associated
# template are both transitional and will be removed after the embedder API
# transition is complete.
#
# See `source_set_maybe_fuchsia_legacy` in //flutter/common/config.gni
#
# TODO(fxb/54041): Remove when no longer neccesary.
config("fuchsia_legacy") {
if (is_fuchsia) {
# This define is transitional and will be removed after the embedder API
# transition is complete.
#
# TODO(bugs.fuchsia.dev/54041): Remove when no longer neccesary.
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
defines = [ "LEGACY_FUCHSIA_EMBEDDER" ]
}
}
Expand Down
119 changes: 3 additions & 116 deletions common/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ declare_args() {

# Whether to use the Skia text shaper module
flutter_enable_skshaper = false

# Whether to use the legacy embedder when building for Fuchsia.
flutter_enable_legacy_fuchsia_embedder = true
}

# feature_defines_list ---------------------------------------------------------
Expand Down Expand Up @@ -56,119 +59,3 @@ if (is_ios || is_mac) {
]
flutter_cflags_objcc = flutter_cflags_objc
}

# This template creates a `source_set` in both standard and "fuchsia_legacy"
# configurations.
#
# The "fuchsia_legacy" configuration includes old, non-embedder API sources and
# defines the LEGACY_FUCHSIA_EMBEDDER symbol. This template and the config
# are both transitional and will be removed after the embedder API transition
# is complete.
# TODO(fxb/54041): Remove when no longer neccesary.
#
# `sources`, `defines`, `public_configs`, `configs`, `public_deps`, `deps` work
# as they do in a normal `source_set`.
#
# `legacy_deps` is the list of dependencies which should be mutated by
# appending '_fuchsia_legacy' when creating the 2 `source_set`'s. The template adds
# `legacy_deps` to `public_deps`, whether it mutates them or not.
template("source_set_maybe_fuchsia_legacy") {
public_deps_non_legacy = []
deps_non_legacy = []
if (defined(invoker.public_deps)) {
public_deps_non_legacy += invoker.public_deps
}
if (defined(invoker.deps)) {
deps_non_legacy += invoker.deps
}
if (defined(invoker.public_deps_legacy_and_next)) {
foreach(legacy_dep, invoker.public_deps_legacy_and_next) {
public_deps_non_legacy += [ legacy_dep ]
}
}
if (defined(invoker.deps_legacy_and_next)) {
foreach(legacy_dep, invoker.deps_legacy_and_next) {
deps_non_legacy += [ legacy_dep ]
}
}

source_set(target_name) {
forward_variables_from(invoker,
[
"testonly",
"sources",
"defines",
"public_configs",
"configs",
])
public_deps = public_deps_non_legacy
deps = deps_non_legacy
}

if (is_fuchsia) {
legagcy_suffix = "_fuchsia_legacy"

sources_legacy = []
if (defined(invoker.sources_legacy)) {
sources_legacy += invoker.sources_legacy
}
if (defined(invoker.sources)) {
sources_legacy += invoker.sources
}

public_configs_legacy = [ "//flutter:fuchsia_legacy" ]
if (defined(invoker.public_configs)) {
public_configs_legacy += invoker.public_configs
}

public_deps_legacy = []
deps_legacy = []
if (defined(invoker.public_deps)) {
public_deps_legacy += invoker.public_deps
}
if (defined(invoker.deps)) {
deps_legacy += invoker.deps
}
if (defined(invoker.public_deps_legacy)) {
public_deps_legacy += invoker.public_deps_legacy
}
if (defined(invoker.deps_legacy)) {
deps_legacy += invoker.deps_legacy
}
if (defined(invoker.public_deps_legacy_and_next)) {
foreach(legacy_dep, invoker.public_deps_legacy_and_next) {
public_deps_legacy += [ legacy_dep + legagcy_suffix ]
}
}
if (defined(invoker.deps_legacy_and_next)) {
foreach(legacy_dep, invoker.deps_legacy_and_next) {
deps_legacy += [ legacy_dep + legagcy_suffix ]
}
}

source_set(target_name + legagcy_suffix) {
forward_variables_from(invoker,
[
"testonly",
"defines",
"configs",
])
sources = sources_legacy

public_configs = public_configs_legacy

public_deps = public_deps_legacy
deps = deps_legacy
}
} else {
if (defined(invoker.sources_legacy)) {
not_needed(invoker, [ "sources_legacy" ])
}
if (defined(invoker.public_deps_legacy)) {
not_needed(invoker, [ "public_deps_legacy" ])
}
if (defined(invoker.deps_legacy)) {
not_needed(invoker, [ "deps_legacy" ])
}
}
}
67 changes: 25 additions & 42 deletions flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/testing/testing.gni")

source_set_maybe_fuchsia_legacy("flow") {
source_set("flow") {
sources = [
"compositor_context.cc",
"compositor_context.h",
Expand Down Expand Up @@ -78,28 +78,31 @@ source_set_maybe_fuchsia_legacy("flow") {
"//third_party/skia",
]

sources_legacy = [
"layers/child_scene_layer.cc",
"layers/child_scene_layer.h",
"scene_update_context.cc",
"scene_update_context.h",
"view_holder.cc",
"view_holder.h",
]
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
sources += [
"layers/child_scene_layer.cc",
"layers/child_scene_layer.h",
"scene_update_context.cc",
"scene_update_context.h",
"view_holder.cc",
"view_holder.h",
]

public_deps_legacy = [
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
"$fuchsia_sdk_root/pkg:scenic_cpp",
]
public_deps = [
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
"$fuchsia_sdk_root/fidl:fuchsia.ui.views",
"$fuchsia_sdk_root/pkg:scenic_cpp",
]
}
}

if (enable_unittests) {
test_fixtures("flow_fixtures") {
fixtures = []
}

source_set_maybe_fuchsia_legacy("flow_testing") {
source_set("flow_testing") {
testonly = true

sources = [
Expand All @@ -121,10 +124,10 @@ if (enable_unittests) {
"//third_party/googletest:gtest",
]

deps_legacy_and_next = [ ":flow" ]
deps = [ ":flow" ]
}

source_set_maybe_fuchsia_legacy("flow_unittests_common") {
executable("flow_unittests") {
testonly = true

sources = [
Expand Down Expand Up @@ -160,7 +163,9 @@ if (enable_unittests) {
]

deps = [
":flow",
":flow_fixtures",
":flow_testing",
"//flutter/fml",
"//flutter/testing:skia",
"//flutter/testing:testing_lib",
Expand All @@ -169,32 +174,10 @@ if (enable_unittests) {
"//third_party/skia",
]

sources_legacy = [ "layers/fuchsia_layer_unittests.cc" ]

deps_legacy = [ "//build/fuchsia/pkg:sys_cpp_testing" ]

deps_legacy_and_next = [
":flow",
":flow_testing",
]
}

if (is_fuchsia) {
executable("flow_unittests") {
testonly = true

deps = [ ":flow_unittests_common_fuchsia_legacy" ]
}
executable("flow_unittests_next") {
testonly = true

deps = [ ":flow_unittests_common" ]
}
} else {
executable("flow_unittests") {
testonly = true
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
sources += [ "layers/fuchsia_layer_unittests.cc" ]

deps = [ ":flow_unittests_common" ]
deps += [ "//build/fuchsia/pkg:sys_cpp_testing" ]
}
}
}
59 changes: 19 additions & 40 deletions lib/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/testing/testing.gni")

source_set_maybe_fuchsia_legacy("ui") {
source_set("ui") {
sources = [
"compositing/scene.cc",
"compositing/scene.h",
Expand Down Expand Up @@ -120,6 +120,7 @@ source_set_maybe_fuchsia_legacy("ui") {
deps = [
"//flutter/assets",
"//flutter/common",
"//flutter/flow",
"//flutter/fml",
"//flutter/runtime:test_font",
"//flutter/third_party/tonic",
Expand All @@ -132,18 +133,18 @@ source_set_maybe_fuchsia_legacy("ui") {
defines = [ "FLUTTER_ENABLE_SKSHAPER" ]
}

sources_legacy = [
"compositing/scene_host.cc",
"compositing/scene_host.h",
]

deps_legacy = [
"$fuchsia_sdk_root/pkg:async-cpp",
"//flutter/shell/platform/fuchsia/dart-pkg/fuchsia",
"//flutter/shell/platform/fuchsia/dart-pkg/zircon",
]
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
sources += [
"compositing/scene_host.cc",
"compositing/scene_host.h",
]

deps_legacy_and_next = [ "//flutter/flow:flow" ]
deps += [
"$fuchsia_sdk_root/pkg:async-cpp",
"//flutter/shell/platform/fuchsia/dart-pkg/fuchsia",
"//flutter/shell/platform/fuchsia/dart-pkg/zircon",
]
}
}

if (enable_unittests) {
Expand Down Expand Up @@ -174,7 +175,7 @@ if (enable_unittests) {
]
}

source_set_maybe_fuchsia_legacy("ui_unittests_common") {
executable("ui_unittests") {
testonly = true

public_configs = [ "//flutter:export_dynamic_symbols" ]
Expand All @@ -187,44 +188,22 @@ if (enable_unittests) {
]

deps = [
":ui",
":ui_unittests_fixtures",
"//flutter/common",
"//flutter/shell/common:shell_test_fixture_sources",
"//flutter/testing",
"//flutter/testing:dart",
"//flutter/testing:fixture_test",
"//flutter/third_party/tonic",
"//third_party/dart/runtime/bin:elf_loader",
]

# TODO(): This test is hard-coded to use a TestGLSurface so it cannot run on fuchsia.
# TODO(https://github.com/flutter/flutter/issues/63837): This test is hard-coded to use a TestGLSurface so it cannot run on fuchsia.
if (!is_fuchsia) {
sources += [ "painting/image_decoder_unittests.cc" ]

deps += [ "//flutter/testing:opengl" ]
}

deps_legacy_and_next = [
":ui",
"//flutter/shell/common:shell_test_fixture_sources",
"//flutter/testing:dart",
"//flutter/testing:fixture_test",
]
}

if (is_fuchsia) {
executable("ui_unittests") {
testonly = true

deps = [ ":ui_unittests_common_fuchsia_legacy" ]
}
executable("ui_unittests_next") {
testonly = true

deps = [ ":ui_unittests_common" ]
}
} else {
executable("ui_unittests") {
testonly = true

deps = [ ":ui_unittests_common" ]
}
}
}
Loading

0 comments on commit 4dc8662

Please sign in to comment.