blob: f7852105f770b1bbffb65de5b495e8002ec445dd [file] [log] [blame]
# Copyright 2015 The Chromium 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("../../gni/angle.gni")
import("//build/config/chromecast_build.gni")
import("//testing/test.gni")
unittests_gypi = exec_script("//build/gypi_to_gn.py",
[
rebase_path("angle_unittests.gypi"),
"--replace=<(angle_path)=.",
],
"scope",
[ "angle_unittests.gypi" ])
declare_args() {
# Don't build dEQP by default.
build_angle_deqp_tests = false
}
if (build_with_chromium) {
googletest_deps = [
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
} else {
googletest_deps = [
":angle_internal_gmock",
":angle_internal_gtest",
]
config("angle_internal_gtest_config") {
include_dirs = [
"//third_party/googletest/src/googletest",
"//third_party/googletest/src/googletest/include",
]
}
static_library("angle_internal_gtest") {
sources = [
"//third_party/googletest/src/googletest/src/gtest-all.cc",
]
public_configs = [ ":angle_internal_gtest_config" ]
}
config("angle_internal_gmock_config") {
include_dirs = [
"//third_party/googletest/src/googlemock",
"//third_party/googletest/src/googlemock/include",
"//third_party/googletest/src/googletest/include",
]
}
static_library("angle_internal_gmock") {
sources = [
"//third_party/googletest/src/googlemock/src/gmock-all.cc",
]
public_configs = [ ":angle_internal_gmock_config" ]
}
group("all") {
testonly = true
deps = [
"//src/tests:angle_end2end_tests",
"//src/tests:angle_perftests",
"//src/tests:angle_unittests",
"//src/tests:angle_white_box_tests",
]
if (build_angle_deqp_tests) {
deps += [
"//src/tests:angle_deqp_egl_no_gtest",
"//src/tests:angle_deqp_egl_tests",
"//src/tests:angle_deqp_gles2_no_gtest",
"//src/tests:angle_deqp_gles2_tests",
"//src/tests:angle_deqp_gles31_no_gtest",
"//src/tests:angle_deqp_gles31_tests",
"//src/tests:angle_deqp_gles3_no_gtest",
"//src/tests:angle_deqp_gles3_tests",
]
}
}
}
test("angle_unittests") {
include_dirs = [ "$angle_root/src" ]
sources = rebase_path(unittests_gypi.angle_unittests_sources, ".", "../..")
if (angle_enable_hlsl) {
sources +=
rebase_path(unittests_gypi.angle_unittests_hlsl_sources, ".", "../..")
defines = [ "ANGLE_ENABLE_HLSL" ]
}
if (build_with_chromium) {
sources += [ "//gpu/angle_unittest_main.cc" ]
} else {
sources += [ "angle_unittests_main.cpp" ]
}
deps = googletest_deps + [
angle_root + ":libANGLE",
angle_root + ":preprocessor",
angle_root + ":translator",
]
}
if (is_win || is_linux || is_mac || is_android) {
end2end_gypi = exec_script("//build/gypi_to_gn.py",
[
rebase_path("angle_end2end_tests.gypi"),
"--replace=<(angle_path)=.",
],
"scope",
[ "angle_end2end_tests.gypi" ])
test("angle_end2end_tests") {
include_dirs = [
"../../src/tests",
"../../util",
]
if (is_android) {
use_native_activity = true
}
sources =
rebase_path(end2end_gypi.angle_end2end_tests_sources, ".", "../..")
if (is_win) {
sources += rebase_path(end2end_gypi.angle_end2end_tests_win_sources,
".",
"../..")
}
if (use_x11) {
sources += rebase_path(end2end_gypi.angle_end2end_tests_x11_sources,
".",
"../..")
}
if (build_with_chromium) {
sources += [ "//gpu/angle_end2end_tests_main.cc" ]
} else {
sources += [ "angle_end2end_tests_main.cpp" ]
}
configs += [
angle_root + ":internal_config",
angle_root + ":libANGLE_config",
]
if (is_linux && !is_component_build) {
# Set rpath to find libEGL.so and libGLESv2.so even in a non-component build.
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
deps = googletest_deps + [
angle_root + ":angle_image_util",
angle_root + ":angle_util",
angle_root + ":libEGL",
angle_root + ":libGLESv2",
angle_root + ":preprocessor",
angle_root + ":translator",
]
}
white_box_gypi = exec_script("//build/gypi_to_gn.py",
[
rebase_path("angle_white_box_tests.gypi"),
"--replace=<(angle_path)=.",
],
"scope",
[ "angle_white_box_tests.gypi" ])
test("angle_white_box_tests") {
include_dirs = [
"../../src/tests",
"../../util",
]
if (is_android) {
use_native_activity = true
}
sources =
rebase_path(white_box_gypi.angle_white_box_tests_sources, ".", "../..")
if (is_win) {
sources += rebase_path(white_box_gypi.angle_white_box_tests_win_sources,
".",
"../..")
}
# Share the same main file as end2end_tests.
# TODO(jmadill): Probably should rename this if we're sharing.
if (build_with_chromium) {
sources += [ "//gpu/angle_end2end_tests_main.cc" ]
} else {
sources += [ "angle_end2end_tests_main.cpp" ]
}
configs += [
angle_root + ":internal_config",
angle_root + ":libANGLE_config",
]
deps = googletest_deps + [
angle_root + ":angle_util_static",
angle_root + ":libANGLE",
angle_root + ":libEGL_static",
angle_root + ":libGLESv2_static",
angle_root + ":preprocessor",
angle_root + ":translator",
]
}
}
if (is_win || is_linux || is_android || is_mac) {
perftests_gypi = exec_script("//build/gypi_to_gn.py",
[
rebase_path("angle_perftests.gypi"),
"--replace=<(angle_path)=.",
],
"scope",
[ "angle_perftests.gypi" ])
test("angle_perftests") {
include_dirs = [
"../../src/tests",
"../../util",
]
if (is_android) {
use_native_activity = true
configs -= [ "//build/config/android:hide_all_but_jni" ]
}
sources = rebase_path(perftests_gypi.angle_perf_tests_sources, ".", "../..")
if (is_win) {
sources +=
rebase_path(perftests_gypi.angle_perf_tests_win_sources, ".", "../..")
}
if (build_with_chromium) {
sources += [ "//gpu/angle_perftests_main.cc" ]
} else {
sources += [ "angle_perftests_main.cpp" ]
}
configs += [
angle_root + ":internal_config",
angle_root + ":libANGLE_config",
]
deps = googletest_deps + [
angle_root + ":angle_util_static",
angle_root + ":libANGLE",
angle_root + ":libEGL_static",
angle_root + ":libGLESv2_static",
]
}
}
###-----------------------------------------------------
### dEQP tests
###-----------------------------------------------------
# TODO(jmadill): Other platforms.
if (build_angle_deqp_tests) {
deqp_gypi = exec_script("//build/gypi_to_gn.py",
[
rebase_path("deqp.gypi"),
"--replace=<(angle_path)=.",
"--replace=<(deqp_path)=//third_party/deqp/src",
],
"scope",
[ "deqp.gypi" ])
config("angle_deqp_support") {
include_dirs = rebase_path(deqp_gypi.deqp_include_dirs, ".", "../..")
if (is_win && !is_clang) {
include_dirs += [ "../deqp/src/framework/platform/win32" ]
cflags = deqp_gypi.deqp_win_cflags
}
if (is_android) {
include_dirs += [ "../../../deqp/src/framework/platform/android" ]
}
defines = deqp_gypi.deqp_defines
defines += [ "_MBCS" ]
if (is_clang) {
# TODO(jmadill): Remove this once we fix dEQP.
cflags_c = [ "-Wno-unused-local-typedef" ]
cflags_cc = [ "-Wno-unused-local-typedef" ]
}
# Ask the system headers to expose all the regular function otherwise
# dEQP doesn't compile and produces warnings about implicitly defined
# functions.
if (is_linux) {
# This has to be GNU_SOURCE as on Linux dEQP uses syscall()
defines += [ "_GNU_SOURCE" ]
}
if (is_android || is_mac) {
# _XOPEN_SOURCE=600 is what is used in deqp/src/Android.mk
defines += [ "_XOPEN_SOURCE=600" ]
}
}
deqp_undefine_configs = [
"//build/config/compiler:chromium_code",
"//build/config/compiler:no_exceptions",
"//build/config/compiler:no_rtti",
]
if (is_win) {
deqp_undefine_configs += [
"//build/config/win:lean_and_mean",
"//build/config/win:nominmax",
"//build/config/win:unicode",
]
}
static_library("angle_deqp_decpp") {
configs -= deqp_undefine_configs
public_configs = [
":angle_deqp_support",
"//build/config/compiler:exceptions",
"//build/config/compiler:no_chromium_code",
angle_root + ":internal_config",
]
sources = rebase_path(deqp_gypi.deqp_libtester_decpp_sources, ".", "../..")
}
config("angle_deqp_libtester_config") {
defines = [ "ANGLE_DEQP_LIBTESTER_IMPLEMENTATION" ]
if (is_clang) {
# TODO(jmadill): Remove this once we fix dEQP.
cflags_cc = [
"-Wno-delete-non-virtual-dtor",
"-Wno-deprecated",
]
}
}
static_library("angle_deqp_libtester") {
public_deps = [
":angle_deqp_decpp",
angle_root + ":angle_common",
angle_root + ":angle_util",
angle_root + ":libEGL",
"//third_party/libpng:libpng",
]
configs -= deqp_undefine_configs
public_configs = [ ":angle_deqp_libtester_config" ]
sources = rebase_path(deqp_gypi.deqp_libtester_sources, ".", "../..")
if (is_win) {
sources += rebase_path(deqp_gypi.deqp_libtester_sources_win, ".", "../..")
}
if (is_linux || is_android || is_mac) {
sources +=
rebase_path(deqp_gypi.deqp_libtester_sources_unix, ".", "../..")
}
if (is_android) {
sources +=
rebase_path(deqp_gypi.deqp_libtester_sources_android, ".", "../..")
libs = [ "log" ]
}
}
config("angle_deqp_gtest_support_config") {
include_dirs = [ "third_party/gpu_test_expectations" ]
}
source_set("angle_deqp_gtest_support") {
testonly = true
public_deps = googletest_deps + [
angle_root + ":angle_common",
angle_root + ":angle_util",
]
public_configs = [ ":angle_deqp_gtest_support_config" ]
sources = deqp_gypi.deqp_gpu_test_expectations_sources
if (is_mac) {
sources += deqp_gypi.deqp_gpu_test_expectations_sources_mac
libs = [ "Cocoa.framework" ]
}
if (build_with_chromium) {
sources += [ "//gpu/angle_deqp_tests_main.cc" ]
} else {
sources += [ "deqp_support/angle_deqp_gtest_main.cpp" ]
}
if (!is_android) {
public_deps += [ angle_root + ":angle_gpu_info_util" ]
}
}
api_names = [
"gles2",
"gles3",
"gles31",
"egl",
]
target_defines = [
"ANGLE_DEQP_GLES2_TESTS",
"ANGLE_DEQP_GLES3_TESTS",
"ANGLE_DEQP_GLES31_TESTS",
"ANGLE_DEQP_EGL_TESTS",
]
target_sources = [
deqp_gypi.deqp_gles2_sources,
deqp_gypi.deqp_gles3_sources,
deqp_gypi.deqp_gles31_sources,
deqp_gypi.deqp_egl_sources,
]
foreach(index,
[
0,
1,
2,
3,
]) {
api_name = api_names[index]
config_name = "angle_deqp_lib${api_name}_config"
config(config_name) {
defines = [ target_defines[index] ]
}
shared_library_name = "angle_deqp_lib${api_name}"
shared_library(shared_library_name) {
deps = [
":angle_deqp_libtester",
"//build/config:exe_and_shlib_deps",
angle_root + ":angle_util",
]
configs -= deqp_undefine_configs
if (is_android) {
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
}
public_configs = [ ":${config_name}" ]
sources = rebase_path(target_sources[index], ".", "../..")
sources += [
"deqp_support/angle_deqp_libtester_main.cpp",
"deqp_support/tcuANGLEPlatform.cpp",
"deqp_support/tcuANGLEPlatform.h",
]
}
if (!build_with_chromium) {
executable("angle_deqp_${api_name}_no_gtest") {
sources = [
"deqp_support/angle_deqp_tests_main.cpp",
]
deps = [
":${shared_library_name}",
]
}
}
test_name = "angle_deqp_${api_name}_tests"
test(test_name) {
deps = [
":${shared_library_name}",
":angle_deqp_gtest_support",
]
# Must be included outside of the source set for the define
sources = [
"deqp_support/angle_deqp_gtest.cpp",
]
data = [
"deqp_support/deqp_${api_name}_test_expectations.txt",
"../../../deqp/src/android/cts/master/${api_name}-master.txt",
"../../../deqp/src/data/",
]
if (is_linux && !is_component_build) {
# Set rpath to find *.so files even in a non-component build.
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
if (is_android) {
use_native_activity = true
}
}
}
}