Skip to content

Commit

Permalink
fuchsia: Enable most unittests (flutter#19583)
Browse files Browse the repository at this point in the history
Tweak the primary flutter build rule so that fuchsia is more similar to
other platforms in how tests and the shell are built.

Only embedder_unittests and GLFW tests are disabled on Fuchsia now.

TEST: Ran unittests on host/fuchsia; workstation on fuchsia
BUG: fxb/53847, fxb/54056
  • Loading branch information
arbreng authored Jul 14, 2020
1 parent 1e23309 commit 9353692
Show file tree
Hide file tree
Showing 23 changed files with 1,136 additions and 961 deletions.
176 changes: 89 additions & 87 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,62 @@

import("//flutter/common/config.gni")
import("//flutter/shell/platform/config.gni")

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

# Whether to build the dartdevc sdk, libraries, and source files
# required for the flutter web sdk.
declare_args() {
full_dart_sdk = false
}

group("flutter") {
testonly = true
config("config") {
include_dirs = [ ".." ]
if (is_win) {
if (current_cpu != "x86") {
cflags = [ "/WX" ] # Treat warnings as errors.
}
}
}

public_deps = []
# 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) {
defines = [ "LEGACY_FUCHSIA_EMBEDDER" ]
}
}

if (!is_fuchsia) {
public_deps += [
"//flutter/lib/snapshot:generate_snapshot_bin",
"//flutter/lib/snapshot:kernel_platform_files",
config("export_dynamic_symbols") {
if (is_linux || is_fuchsia) {
inputs = [
"//flutter/common/exported_symbols.sym",
]
ldflags = [ "-Wl,--dynamic-list=" + rebase_path(inputs[0], root_build_dir) ]
}
}

public_deps += [
group("flutter") {
testonly = true

# Compile the engine.
public_deps = [
"//flutter/shell/platform/embedder:flutter_engine",
"//flutter/sky",
]

if (current_toolchain == host_toolchain) {
public_deps += [ "//flutter/tools/font-subset" ]
}

if (current_toolchain == host_toolchain) {
public_deps += [ "//flutter/shell/testing" ]
public_deps += [ "//flutter/tools/const_finder" ]
}

if (is_fuchsia) {
# If enbaled, compile the SDK / snapshot.
if (!is_fuchsia) {
public_deps += [
"//flutter/shell/platform/fuchsia",
"//flutter/shell/testing($host_toolchain)",
"//flutter/lib/snapshot:generate_snapshot_bin",
"//flutter/lib/snapshot:kernel_platform_files",
]
}

if (!is_fuchsia) {
if (current_toolchain == host_toolchain) {
public_deps += [
"//flutter/flutter_frontend_server:frontend_server",
Expand All @@ -61,93 +72,95 @@ group("flutter") {
}
}

# If on the host, compile all unittests targets.
# If on the host, compile tools.
if (current_toolchain == host_toolchain) {
if (is_mac) {
public_deps +=
[ "//flutter/shell/platform/darwin:flutter_channels_unittests" ]
}
public_deps += [
"//flutter/shell/testing",
"//flutter/tools/const_finder",
"//flutter/tools/font-subset",
]
}

# Compile all benchmark targets if enabled.
if (enable_unittests && !is_win) {
public_deps += [
"//flutter/fml:fml_benchmarks",
"//flutter/lib/ui:ui_benchmarks",
"//flutter/shell/common:shell_benchmarks",
"//flutter/third_party/txt:txt_benchmarks",
]
}

# Compile all unittests targets if enabled.
if (enable_unittests) {
public_deps += [
"//flutter/flow:flow_unittests",
"//flutter/fml:fml_unittests",
"//flutter/lib/ui:ui_unittests",
"//flutter/runtime:runtime_unittests",
"//flutter/shell/common:shell_unittests",
"//flutter/shell/platform/embedder:embedder_unittests",
"//flutter/testing:testing_unittests",
"//flutter/third_party/txt:txt_unittests",
]

if (!is_win) {
if (is_fuchsia) {
public_deps += [ "//flutter/shell/platform/fuchsia:tests" ]
}

if (is_mac) {
public_deps +=
[ "//flutter/shell/platform/darwin:flutter_channels_unittests" ]
}

if (!is_win && !is_fuchsia) {
public_deps += [
"//flutter/fml:fml_benchmarks",
"//flutter/lib/ui:ui_benchmarks",
"//flutter/shell/common:shell_benchmarks",
"//flutter/shell/platform/android/external_view_embedder:android_external_view_embedder_unittests",
"//flutter/shell/platform/android/jni:jni_unittests",
"//flutter/third_party/txt:txt_benchmarks",
]
}

# TODO(): Enable embedder_unittests on fucsia.
if (!is_fuchsia) {
public_deps += [ "//flutter/shell/platform/embedder:embedder_unittests" ]
}

# Unit tests for desktop embeddings should only be built if the desktop
# embeddings are being built.
if (enable_desktop_embeddings) {
public_deps += [
"//flutter/shell/platform/common/cpp:common_cpp_core_unittests",
"//flutter/shell/platform/common/cpp:common_cpp_unittests",
"//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper_unittests",
"//flutter/shell/platform/glfw/client_wrapper:client_wrapper_glfw_unittests",
]

if (!is_fuchsia) {
# These tests require the embedder and thus cannot run on fuchsia.
# TODO(): Enable when embedder works on fuchsia.
public_deps +=
[ "//flutter/shell/platform/common/cpp:common_cpp_unittests" ]

# These tests require GLFW and thus cannot run on fuchsia.
public_deps += [ "//flutter/shell/platform/glfw/client_wrapper:client_wrapper_glfw_unittests" ]
}

if (is_linux) {
public_deps +=
[ "//flutter/shell/platform/linux:flutter_linux_unittests" ]
}

if (is_mac) {
public_deps += [ "//flutter/shell/platform/darwin/macos:flutter_desktop_darwin_unittests" ]
}

if (is_win) {
public_deps += [
"//flutter/shell/platform/windows:flutter_windows_unittests",
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests",
]
}
if (is_linux) {
public_deps +=
[ "//flutter/shell/platform/linux:flutter_linux_unittests" ]
}
}
}
}

config("config") {
include_dirs = [ ".." ]
if (is_win) {
if (current_cpu != "x86") {
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) {
defines = [ "LEGACY_FUCHSIA_EMBEDDER" ]
}
}

config("export_dynamic_symbols") {
if (is_linux || is_fuchsia) {
inputs = [
"//flutter/common/exported_symbols.sym",
]
ldflags = [ "-Wl,--dynamic-list=" + rebase_path(inputs[0], root_build_dir) ]
}
}

group("dist") {
testonly = true

Expand All @@ -156,23 +169,12 @@ group("dist") {
]
}

# Fuchsia currently only supports a subset of our unit tests
# When adding a new dep here, please also ensure the dep is added to
# testing/fuchsia/run_tests.sh and testing/fuchsia/test_fars
if (is_fuchsia) {
group("fuchsia_tests") {
testonly = true

deps = [
"//flutter/flow:flow_tests",
"//flutter/flow:flow_tests_next",
"//flutter/fml:fml_tests",
"//flutter/runtime:runtime_tests",
"//flutter/runtime:runtime_tests_next",
"//flutter/shell/common:shell_tests",
"//flutter/shell/common:shell_tests_next",
"//flutter/shell/platform/fuchsia/flutter:flutter_runner_scenic_tests",
"//flutter/shell/platform/fuchsia/flutter:flutter_runner_tests",
"//flutter/shell/platform/fuchsia:tests",
]
}
}
20 changes: 0 additions & 20 deletions common/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,16 @@ if (is_android) {
import("//build/config/android/config.gni")
}

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

if (target_cpu == "arm" || target_cpu == "arm64") {
import("//build/config/arm.gni")
}

if (is_fuchsia) {
import("//build/toolchain/clang.gni")
}

declare_args() {
# The runtime mode ("debug", "profile", "release", or "jit_release")
flutter_runtime_mode = "debug"

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

# A copy of the enable_bitcode flag from build/toolchain/clang.gni.
# This needs to be mirrored here because build/toolchain/clang.gni does
# not exist in the Fuchsia source tree.
flutter_enable_bitcode = false
}

# feature_defines_list ---------------------------------------------------------
Expand Down Expand Up @@ -60,15 +49,6 @@ if (flutter_runtime_mode == "debug") {
feature_defines_list += [ "FLUTTER_RUNTIME_MODE=0" ]
}

if (is_fuchsia) {
# TODO(chinmaygarde): This is always set. The macro may now be removed.
feature_defines_list += [ "FUCHSIA_SDK=1" ]
}

if ((is_ios || is_mac) && defined(enable_bitcode)) {
flutter_enable_bitcode = enable_bitcode
}

if (is_ios || is_mac) {
flutter_cflags_objc = [
"-Werror=overriding-method-mismatch",
Expand Down
Loading

0 comments on commit 9353692

Please sign in to comment.