Commit 7098cff5 by Jamie Madill Committed by Commit Bot

Make BUILD.gn targets into templates.

This allows us to "globally" add and remove certain configs as long as we use the new templates. This simplifies the logic of adding configs for stuff like extra warnings and default include dirs. As well it simplifies removing certain common unwanted configs. Generally simplifies the logic in BUILD.gn. Will allow for easily suppressing the clang-plugins config instead of using a global setting in .gn. Then we can enable the additional warnings config-by-config. Also fixes some warnings that turned up after we enabled the extra warnings config in our tests. Also moves the dEQP tests main to be consistent with the other test main files. Bug: angleproject:3069 Change-Id: I5a8166cd0f5a7926822c171fcaf473fc86b3ffc1 Reviewed-on: https://chromium-review.googlesource.com/c/1409871 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent c8be560b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//build/config/sanitizers/sanitizers.gni") import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni") # import the use_x11 variable import("//build/config/ui.gni") # import the use_x11 variable
import("//build_overrides/build.gni") import("//build_overrides/build.gni")
import("//testing/test.gni")
if (is_android) { if (is_android) {
import("//build/config/android/config.gni") import("//build/config/android/config.gni")
} }
...@@ -86,3 +87,152 @@ declare_args() { ...@@ -86,3 +87,152 @@ declare_args() {
if (is_win) { if (is_win) {
import("//build/config/win/visual_studio_version.gni") import("//build/config/win/visual_studio_version.gni")
} }
angle_common_configs = [
angle_root + ":extra_warnings",
angle_root + ":internal_config",
]
angle_remove_configs = [ "//build/config/compiler:default_include_dirs" ]
set_defaults("angle_executable") {
configs = angle_common_configs
public_configs = []
suppressed_configs = []
}
set_defaults("angle_shared_library") {
configs = angle_common_configs
public_configs = []
suppressed_configs = []
}
set_defaults("angle_source_set") {
configs = angle_common_configs
public_configs = []
suppressed_configs = []
}
set_defaults("angle_static_library") {
configs = angle_common_configs
public_configs = []
suppressed_configs = []
}
set_defaults("angle_test") {
configs = angle_common_configs
public_configs = []
suppressed_configs = []
}
template("angle_executable") {
executable(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= angle_remove_configs
configs -= invoker.suppressed_configs
}
}
template("angle_shared_library") {
shared_library(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= angle_remove_configs
configs -= invoker.suppressed_configs
public_configs += [ angle_root + ":shared_library_public_config" ]
if (is_android) {
configs += [ angle_root + ":build_id_config" ]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
}
}
}
template("angle_source_set") {
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= angle_remove_configs
configs -= invoker.suppressed_configs
}
}
template("angle_static_library") {
static_library(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= angle_remove_configs
configs -= invoker.suppressed_configs
}
}
template("angle_test") {
test(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= angle_remove_configs
configs -= invoker.suppressed_configs
if (is_linux && !is_component_build) {
# Set rpath to find shared libs in a non-component build.
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
if (is_android) {
configs += [ angle_root + ":build_id_config" ]
configs -= [ "//build/config/android:hide_all_but_jni" ]
}
}
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import("../gni/angle.gni") import("../gni/angle.gni")
executable("shader_translator") { angle_executable("shader_translator") {
sources = [ sources = [
"shader_translator/shader_translator.cpp", "shader_translator/shader_translator.cpp",
] ]
...@@ -18,7 +18,7 @@ config("sample_util_config") { ...@@ -18,7 +18,7 @@ config("sample_util_config") {
include_dirs = [ "sample_util" ] include_dirs = [ "sample_util" ]
} }
static_library("sample_util") { angle_static_library("sample_util") {
sources = [ sources = [
"sample_util/SampleApplication.cpp", "sample_util/SampleApplication.cpp",
"sample_util/SampleApplication.h", "sample_util/SampleApplication.h",
...@@ -40,7 +40,6 @@ static_library("sample_util") { ...@@ -40,7 +40,6 @@ static_library("sample_util") {
configs += [ "../:library_name_config" ] configs += [ "../:library_name_config" ]
public_configs = [ public_configs = [
":sample_util_config", ":sample_util_config",
"../:internal_config",
"../:no_gl_prototypes", "../:no_gl_prototypes",
] ]
} }
...@@ -55,7 +54,7 @@ template("angle_sample") { ...@@ -55,7 +54,7 @@ template("angle_sample") {
} }
} }
executable(target_name) { angle_executable(target_name) {
deps = [ deps = [
":sample_util", ":sample_util",
] ]
......
...@@ -707,8 +707,8 @@ TEST(MatrixUtilsTest, Mat4Rotate) ...@@ -707,8 +707,8 @@ TEST(MatrixUtilsTest, Mat4Rotate)
{ {
const auto &input = rotationGoldenInputs[i]; const auto &input = rotationGoldenInputs[i];
const auto &output = rotationGoldenOutputs[i]; const auto &output = rotationGoldenOutputs[i];
Mat4 r = Mat4::Rotate(input.angle, input.axis); Mat4 rot = Mat4::Rotate(input.angle, input.axis);
CheckMatrixCloseToGolden(output, r); CheckMatrixCloseToGolden(output, rot);
} }
} }
......
...@@ -72,8 +72,10 @@ TEST_F(FenceNVTest, SetAndTestBehavior) ...@@ -72,8 +72,10 @@ TEST_F(FenceNVTest, SetAndTestBehavior)
EXPECT_TRUE(mFence->isSet()); EXPECT_TRUE(mFence->isSet());
// Fake the behavior of testing the fence before and after it's passed. // Fake the behavior of testing the fence before and after it's passed.
EXPECT_CALL(*mImpl, test(_, _)) EXPECT_CALL(*mImpl, test(_, _))
.WillOnce(DoAll(SetArgumentPointee<1>(GL_FALSE), Return(angle::Result::Continue))) .WillOnce(DoAll(SetArgumentPointee<1>(static_cast<GLboolean>(GL_FALSE)),
.WillOnce(DoAll(SetArgumentPointee<1>(GL_TRUE), Return(angle::Result::Continue))) Return(angle::Result::Continue)))
.WillOnce(DoAll(SetArgumentPointee<1>(static_cast<GLboolean>(GL_TRUE)),
Return(angle::Result::Continue)))
.RetiresOnSaturation(); .RetiresOnSaturation();
GLboolean out; GLboolean out;
EXPECT_EQ(angle::Result::Continue, mFence->test(nullptr, &out)); EXPECT_EQ(angle::Result::Continue, mFence->test(nullptr, &out));
......
...@@ -83,7 +83,8 @@ class EGLDirectCompositionTest : public ANGLETest ...@@ -83,7 +83,8 @@ class EGLDirectCompositionTest : public ANGLETest
ComPtr<IVisual> angleVis; ComPtr<IVisual> angleVis;
ASSERT_TRUE(SUCCEEDED(mAngleHost.As(&angleVis))); ASSERT_TRUE(SUCCEEDED(mAngleHost.As(&angleVis)));
ASSERT_TRUE(SUCCEEDED(angleVis->put_Size({WINDOWWIDTH, WINDOWHEIGHT}))); ASSERT_TRUE(SUCCEEDED(angleVis->put_Size(
{static_cast<FLOAT>(WINDOWWIDTH), static_cast<FLOAT>(WINDOWHEIGHT)})));
ASSERT_TRUE(SUCCEEDED(angleVis->put_Offset({0, 0, 0}))); ASSERT_TRUE(SUCCEEDED(angleVis->put_Offset({0, 0, 0})));
......
...@@ -112,15 +112,15 @@ class CopyTextureTest : public ANGLETest ...@@ -112,15 +112,15 @@ class CopyTextureTest : public ANGLETest
float alpha = color.A / 255.0f; float alpha = color.A / 255.0f;
if (premultiplyAlpha) if (premultiplyAlpha)
{ {
color.R *= alpha; color.R = static_cast<GLubyte>(static_cast<float>(color.R) * alpha);
color.G *= alpha; color.G = static_cast<GLubyte>(static_cast<float>(color.G) * alpha);
color.B *= alpha; color.B = static_cast<GLubyte>(static_cast<float>(color.B) * alpha);
} }
else if (unmultiplyAlpha && color.A != 0) else if (unmultiplyAlpha && color.A != 0)
{ {
color.R /= alpha; color.R = static_cast<GLubyte>(static_cast<float>(color.R) / alpha);
color.G /= alpha; color.G = static_cast<GLubyte>(static_cast<float>(color.G) / alpha);
color.B /= alpha; color.B = static_cast<GLubyte>(static_cast<float>(color.B) / alpha);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment