blob: 23b5aa314d9e631b767fcc1b30aeb528d5f606a9 [file] [log] [blame]
# Copyright 2016 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/test.gni")
import("//src/ui/lib/escher/build_args.gni")
if (is_mac) {
# Escher cannot be built for macOS, as the latter does not
# support Vulkan. So that we may include Escher host tests in
# the default build, we substitute in a dummy no-op test in the
# case of a mac build.
source_set("no_op_mac_unittest") {
testonly = true
sources = [
"no_op_mac_unittest.cc",
]
deps = [
"//third_party/googletest:gtest",
]
}
test("escher_unittests") {
deps = [
":no_op_mac_unittest",
"//src/lib/fxl/test:gtest_main",
]
}
} else {
# TODO: Consider breaking this out into two binaries, one that uses
# glslang and one that does not. This would ensure we always hav a
# compile target for both on the bots, and also exercise any places
# where those diverge.
test("escher_unittests") {
sources = [
"debug/debug_font_unittest.cc",
"debug/paper_renderer_test.cc",
"fake_gpu_allocator.cc",
"fixtures/readback_test.cc",
"fixtures/readback_test.h",
"fs/hack_filesystem_unittest.cc",
"geometry/bounding_box_unittest.cc",
"geometry/indexed_triangle_mesh_clip_unittest.cc",
"geometry/intersection_unittest.cc",
"geometry/interval_unittest.cc",
"geometry/plane_unittest.cc",
"gpu_allocator_unittest.cc",
"gpu_mem_unittest.cc",
"impl/image_cache_unittest.cc",
"math/rotations_unittest.cc",
"mesh_spec_unittest.cc",
"object_unittest.cc",
"paper/paper_draw_call_factory_unittest.cc",
"paper/paper_shape_cache_unittest.cc",
"paper/paper_transform_stack_unittest.cc",
"pose_buffer_latching_test.cc",
"protected_memory_unittest.cc",
"renderer/batch_gpu_downloader_unittest.cc",
"renderer/batch_gpu_uploader_unittest.cc",
"renderer/buffer_cache_unittest.cc",
"renderer/frame_unittest.cc",
"renderer/render_queue_unittest.cc",
"run_all_unittests.cc",
"scene/directional_light_unittest.cc",
"shape/rounded_rect_factory_unittest.cc",
"shape/rounded_rect_unittest.cc",
"transform_unittest.cc",
"util/align_unittest.cc",
"util/bit_ops_unittest.cc",
"util/bitmap_unittest.cc",
"util/block_allocator_unittest.cc",
"util/enum_flags_unittest.cc",
"util/enum_utils_unittest.cc",
"util/epsilon_compare_unittest.cc",
"util/hash_cache_unittest.cc",
"util/hash_unittest.cc",
"util/hashable_unittest.cc",
"util/hashmap_unittest.cc",
"util/intrusive_list_unittest.cc",
"util/object_pool_unittest.cc",
"util/stack_allocator_unittest.cc",
"vk/buffer_unittest.cc",
"vk/chained_semaphore_generator_unittest.cc",
"vk/command_buffer_unittest.cc",
"vk/descriptor_set_allocator_unittest.cc",
"vk/descriptor_set_layout_unittest.cc",
"vk/framebuffer_allocator_unittest.cc",
"vk/image_layout_updater_unittest.cc",
"vk/image_view_allocator_unittest.cc",
"vk/naive_image_unittest.cc",
"vk/render_pass_cache_unittest.cc",
"vk/shader_program_unittest.cc",
"vk/validation_layer_test.cc",
"vk/vulkan_tester.h",
"vk/vulkan_utils_unittest.cc",
]
if (escher_use_runtime_glsl) {
sources += [
"impl/glsl_compiler_unittest.cc",
"vk/shader_module_template_unittest.cc",
]
}
deps = [
":force_paper_shader_compiler_to_build_on_host",
":force_waterfall_to_build_on_host",
":gtest_escher",
"base:base_unittests",
"//src/lib/fxl",
"//third_party/googletest:gmock",
]
if (escher_use_runtime_glsl) {
deps += [
"//third_party/glslang:glslang_sources",
"//third_party/shaderc:libshaderc",
]
}
if (is_linux) {
deps += [ "//src/ui/lib/escher/shaders:linux_shader_data" ]
}
if (is_fuchsia) {
sources += [
"flib/fence_listener_unittest.cc",
"flib/fence_set_listener_unittest.cc",
"flib/release_fence_signaller_unittest.cc",
"flib/util.cc",
"flib/util.h",
"profiling/timestamp_profiler_unittest.cc",
]
deps += [
"//garnet/public/lib/gtest",
"//zircon/public/lib/async-loop-cpp",
"//zircon/public/lib/async-loop-default",
]
}
libs = [ "pthread" ]
include_dirs = [
"//lib",
"//src/ui/lib/escher",
"//third_party/glm",
]
}
}
# Extends GTest with VK_TEST() and VK_TEST_F() macros, which behave just like
# TEST() and TEST_F(), except that they are dynamically disabled when Vulkan
# is not available.
source_set("gtest_vulkan") {
testonly = true
public_deps = [
"//src/ui/lib/escher:vulkan",
"//third_party/googletest:gtest",
]
deps = [
"//src/ui/lib/escher/util:check_vulkan_support",
]
sources = [
"gtest_vulkan.cc",
"gtest_vulkan.h",
"gtest_vulkan_internal.h",
]
}
# Builds upon gtest_vulkan to provide the functions SetUpTestEscher()
# and TearDownTestEscher(), which should be called from main(), and
# GetTestEscher(), which may be called from VK_TEST(). All of these
# functions are in namespace escher.
source_set("gtest_escher") {
testonly = true
if (escher_use_runtime_glsl) {
public_deps = [
":gtest_escher_with_runtime_glsl",
]
} else {
public_deps = [
":gtest_escher_no_runtime_glsl",
]
}
}
template("gtest_escher_library") {
source_set(target_name) {
testonly = true
forward_variables_from(invoker, "*")
sources = [
"gtest_escher.cc",
"gtest_escher.h",
"test_with_vk_validation_layer.cc",
"test_with_vk_validation_layer.h",
"test_with_vk_validation_layer_macros.h",
"test_with_vk_validation_layer_macros_internal.h",
"vk_debug_report_callback_registry.cc",
"vk_debug_report_callback_registry.h",
"vk_debug_report_collector.cc",
"vk_debug_report_collector.h",
]
public_deps = [
":gtest_vulkan",
]
if (gtest_escher_library_use_runtime_glsl) {
public_deps += [ "//src/ui/lib/escher" ]
} else {
public_deps += [ "//src/ui/lib/escher:escher_no_glslang" ]
}
}
}
gtest_escher_library("gtest_escher_no_runtime_glsl") {
gtest_escher_library_use_runtime_glsl = false
}
gtest_escher_library("gtest_escher_with_runtime_glsl") {
gtest_escher_library_use_runtime_glsl = true
}
# Guarantees that buildbots at least build the Escher examples on Linux,
# even if they are not run.
group("force_waterfall_to_build_on_host") {
if (is_linux) {
deps = [
"//src/ui/examples/escher/waterfall($host_toolchain)",
]
}
}
# Guarantees that buildbots at least build the paper shader compiler on Linux,
# even if they are not run.
group("force_paper_shader_compiler_to_build_on_host") {
if (is_linux) {
deps = [
"//src/ui/tools/paper_shader_compiler($host_toolchain)",
]
}
}