Commit 9190f49c by Jamie Madill Committed by Commit Bot

GN: Make new angle_test_utils target.

This source set target lets other targets import the test utils without needing to export them. They get built into angle_util. They also get compiled into the various tests and samples. The change also fixes export issues. Moves some of the GN logic into the util/ subfolder. Bug: angleproject:3162 Bug: chromium:1030192 Change-Id: If99d201092ad8541c0de60b3bd893ac9b5875270 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1968259Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 390c4952
...@@ -249,25 +249,6 @@ config("angle_common_config") { ...@@ -249,25 +249,6 @@ config("angle_common_config") {
} }
} }
if (is_win && !angle_is_winuwp) {
angle_source_set("angle_stack_walker") {
sources = [
"util/windows/third_party/StackWalker/src/StackWalker.cpp",
"util/windows/third_party/StackWalker/src/StackWalker.h",
]
if (is_clang) {
cflags_cc = [
"-Wno-c++98-compat-extra-semi",
"-Wno-missing-declarations",
"-Wno-switch",
]
} else {
cflags_cc = [ "/wd4740" ]
}
}
}
angle_source_set("angle_system_utils") { angle_source_set("angle_system_utils") {
sources = angle_system_utils_sources sources = angle_system_utils_sources
} }
...@@ -1109,17 +1090,16 @@ foreach(is_shared_library, ...@@ -1109,17 +1090,16 @@ foreach(is_shared_library,
deps = [ deps = [
":angle_common", ":angle_common",
":angle_util_loader_headers", ":angle_util_loader_headers",
"util:angle_test_utils",
] ]
public_deps = [] public_deps = []
libs = [] libs = []
if (is_win && !angle_is_winuwp) { if (is_win && !angle_is_winuwp) {
sources += util_win_sources sources += util_win_sources
deps += [ ":angle_stack_walker" ]
} }
if (is_linux) { if (is_linux) {
sources += util_linux_sources
libs += [ libs += [
"rt", "rt",
"dl", "dl",
......
...@@ -330,6 +330,7 @@ template("angle_test") { ...@@ -330,6 +330,7 @@ template("angle_test") {
deps += _googletest_deps + [ deps += _googletest_deps + [
"$angle_root:angle_common", "$angle_root:angle_common",
"$angle_root:includes", "$angle_root:includes",
"$angle_root/util:angle_test_utils",
] ]
if (build_with_chromium) { if (build_with_chromium) {
......
...@@ -16,7 +16,7 @@ config("sample_util_config") { ...@@ -16,7 +16,7 @@ config("sample_util_config") {
include_dirs = [ "sample_util" ] include_dirs = [ "sample_util" ]
} }
angle_static_library("sample_util") { angle_source_set("sample_util") {
testonly = true testonly = true
sources = [ sources = [
"sample_util/SampleApplication.cpp", "sample_util/SampleApplication.cpp",
...@@ -35,6 +35,7 @@ angle_static_library("sample_util") { ...@@ -35,6 +35,7 @@ angle_static_library("sample_util") {
"../:angle_common", "../:angle_common",
"../:angle_util", "../:angle_util",
"../:angle_util_loader_headers", "../:angle_util_loader_headers",
"../util:angle_test_utils",
] ]
configs += [ "../:library_name_config" ] configs += [ "../:library_name_config" ]
public_configs = [ public_configs = [
......
...@@ -814,6 +814,7 @@ if (build_angle_deqp_tests && !is_fuchsia) { ...@@ -814,6 +814,7 @@ if (build_angle_deqp_tests && !is_fuchsia) {
deps += [ deps += [
":angle_deqp_libtester", ":angle_deqp_libtester",
"$angle_root:angle_util", "$angle_root:angle_util",
"$angle_root/util:angle_test_utils",
] ]
suppressed_configs += deqp_undefine_configs suppressed_configs += deqp_undefine_configs
......
# Copyright 2019 The ANGLE Project 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")
if (is_win && !angle_is_winuwp) {
angle_source_set("angle_stack_walker") {
sources = [
"windows/third_party/StackWalker/src/StackWalker.cpp",
"windows/third_party/StackWalker/src/StackWalker.h",
]
if (is_clang) {
cflags_cc = [
"-Wno-c++98-compat-extra-semi",
"-Wno-missing-declarations",
"-Wno-switch",
]
} else {
cflags_cc = [ "/wd4740" ]
}
}
}
config("angle_test_util_config") {
include_dirs = [ ".." ]
}
angle_source_set("angle_test_utils") {
public_configs = [ ":angle_test_util_config" ]
deps = [
"$angle_root:angle_common",
]
sources = [
"Timer.cpp",
"Timer.h",
"test_utils.cpp",
"test_utils.h",
]
if (is_win) {
sources += [
"windows/test_utils_win.cpp",
"windows/win32/test_utils_win32.cpp",
]
if (!angle_is_winuwp) {
deps += [ ":angle_stack_walker" ]
}
} else {
sources += [
"posix/crash_handler_posix.cpp",
"posix/test_utils_posix.cpp",
]
}
}
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
#ifndef SAMPLE_UTIL_TIMER_H #ifndef SAMPLE_UTIL_TIMER_H
#define SAMPLE_UTIL_TIMER_H #define SAMPLE_UTIL_TIMER_H
#include "util/util_export.h" class Timer final
class ANGLE_UTIL_EXPORT Timer final
{ {
public: public:
Timer(); Timer();
......
...@@ -15,56 +15,51 @@ ...@@ -15,56 +15,51 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "util/Timer.h" #include "util/Timer.h"
#include "util/util_export.h"
namespace angle namespace angle
{ {
// Cross platform equivalent of the Windows Sleep function // Cross platform equivalent of the Windows Sleep function
ANGLE_UTIL_EXPORT void Sleep(unsigned int milliseconds); void Sleep(unsigned int milliseconds);
ANGLE_UTIL_EXPORT void SetLowPriorityProcess(); void SetLowPriorityProcess();
// Write a debug message, either to a standard output or Debug window. // Write a debug message, either to a standard output or Debug window.
ANGLE_UTIL_EXPORT void WriteDebugMessage(const char *format, ...); void WriteDebugMessage(const char *format, ...);
// Set thread affinity and priority. // Set thread affinity and priority.
ANGLE_UTIL_EXPORT bool StabilizeCPUForBenchmarking(); bool StabilizeCPUForBenchmarking();
// Set a crash handler to print stack traces. // Set a crash handler to print stack traces.
using CrashCallback = std::function<void()>; using CrashCallback = std::function<void()>;
ANGLE_UTIL_EXPORT void InitCrashHandler(CrashCallback *callback); void InitCrashHandler(CrashCallback *callback);
ANGLE_UTIL_EXPORT void TerminateCrashHandler(); void TerminateCrashHandler();
// Print a stack back trace. // Print a stack back trace.
ANGLE_UTIL_EXPORT void PrintStackBacktrace(); void PrintStackBacktrace();
// Get temporary directory. // Get temporary directory.
ANGLE_UTIL_EXPORT bool GetTempDir(char *tempDirOut, uint32_t maxDirNameLen); bool GetTempDir(char *tempDirOut, uint32_t maxDirNameLen);
// Creates a temporary file. The full path is placed in |path|, and the // Creates a temporary file. The full path is placed in |path|, and the
// function returns true if was successful in creating the file. The file will // function returns true if was successful in creating the file. The file will
// be empty and all handles closed after this function returns. // be empty and all handles closed after this function returns.
ANGLE_UTIL_EXPORT bool CreateTemporaryFile(char *tempFileNameOut, uint32_t maxFileNameLen); bool CreateTemporaryFile(char *tempFileNameOut, uint32_t maxFileNameLen);
// Same as CreateTemporaryFile but the file is created in |dir|. // Same as CreateTemporaryFile but the file is created in |dir|.
ANGLE_UTIL_EXPORT bool CreateTemporaryFileInDir(const char *dir, bool CreateTemporaryFileInDir(const char *dir, char *tempFileNameOut, uint32_t maxFileNameLen);
char *tempFileNameOut,
uint32_t maxFileNameLen);
// Deletes a file or directory. // Deletes a file or directory.
ANGLE_UTIL_EXPORT bool DeleteFile(const char *path); bool DeleteFile(const char *path);
// Reads a file contents into a string. // Reads a file contents into a string.
ANGLE_UTIL_EXPORT bool ReadEntireFileToString(const char *filePath, bool ReadEntireFileToString(const char *filePath, char *contentsOut, uint32_t maxLen);
char *contentsOut,
uint32_t maxLen);
// Compute a file's size. // Compute a file's size.
ANGLE_UTIL_EXPORT bool GetFileSize(const char *filePath, uint32_t *sizeOut); bool GetFileSize(const char *filePath, uint32_t *sizeOut);
class ANGLE_UTIL_EXPORT ProcessHandle; class ProcessHandle;
class ANGLE_UTIL_EXPORT Process : angle::NonCopyable class Process : angle::NonCopyable
{ {
public: public:
virtual bool started() = 0; virtual bool started() = 0;
...@@ -78,7 +73,7 @@ class ANGLE_UTIL_EXPORT Process : angle::NonCopyable ...@@ -78,7 +73,7 @@ class ANGLE_UTIL_EXPORT Process : angle::NonCopyable
const std::string &getStderr() const { return mStderr; } const std::string &getStderr() const { return mStderr; }
protected: protected:
friend class ANGLE_UTIL_EXPORT ProcessHandle; friend class ProcessHandle;
virtual ~Process(); virtual ~Process();
Timer mTimer; Timer mTimer;
...@@ -86,7 +81,7 @@ class ANGLE_UTIL_EXPORT Process : angle::NonCopyable ...@@ -86,7 +81,7 @@ class ANGLE_UTIL_EXPORT Process : angle::NonCopyable
std::string mStderr; std::string mStderr;
}; };
class ANGLE_UTIL_EXPORT ProcessHandle final : angle::NonCopyable class ProcessHandle final : angle::NonCopyable
{ {
public: public:
ProcessHandle(); ProcessHandle();
...@@ -115,11 +110,11 @@ class ANGLE_UTIL_EXPORT ProcessHandle final : angle::NonCopyable ...@@ -115,11 +110,11 @@ class ANGLE_UTIL_EXPORT ProcessHandle final : angle::NonCopyable
// //
// On success, returns a Process pointer with started() == true. // On success, returns a Process pointer with started() == true.
// On failure, returns a Process pointer with started() == false. // On failure, returns a Process pointer with started() == false.
ANGLE_UTIL_EXPORT Process *LaunchProcess(const std::vector<const char *> &args, Process *LaunchProcess(const std::vector<const char *> &args,
bool captureStdout, bool captureStdout,
bool captureStderr); bool captureStderr);
ANGLE_UTIL_EXPORT int NumberOfProcessors(); int NumberOfProcessors();
} // namespace angle } // namespace angle
......
...@@ -12,8 +12,6 @@ util_sources = [ ...@@ -12,8 +12,6 @@ util_sources = [
"util/random_utils.h", "util/random_utils.h",
"util/shader_utils.cpp", "util/shader_utils.cpp",
"util/shader_utils.h", "util/shader_utils.h",
"util/test_utils.cpp",
"util/test_utils.h",
"util/util_export.h", "util/util_export.h",
"util/util_gl.h", "util/util_gl.h",
"util/Event.h", "util/Event.h",
...@@ -25,13 +23,9 @@ util_sources = [ ...@@ -25,13 +23,9 @@ util_sources = [
"util/OSPixmap.h", "util/OSPixmap.h",
"util/OSWindow.cpp", "util/OSWindow.cpp",
"util/OSWindow.h", "util/OSWindow.h",
"util/Timer.h",
"util/Timer.cpp",
] ]
util_win_sources = [ util_win_sources = [
"util/windows/test_utils_win.cpp",
"util/windows/win32/test_utils_win32.cpp",
"util/windows/win32/Win32Pixmap.cpp", "util/windows/win32/Win32Pixmap.cpp",
"util/windows/win32/Win32Pixmap.h", "util/windows/win32/Win32Pixmap.h",
"util/windows/win32/Win32Window.cpp", "util/windows/win32/Win32Window.cpp",
...@@ -43,13 +37,6 @@ if (current_os != "winuwp") { ...@@ -43,13 +37,6 @@ if (current_os != "winuwp") {
util_win_shared_sources = [ "util/windows/WGLWindow.cpp" ] util_win_shared_sources = [ "util/windows/WGLWindow.cpp" ]
} }
util_posix_sources = [
"util/posix/crash_handler_posix.cpp",
"util/posix/test_utils_posix.cpp",
]
util_linux_sources = util_posix_sources
util_x11_sources = [ util_x11_sources = [
"util/x11/X11Pixmap.cpp", "util/x11/X11Pixmap.cpp",
"util/x11/X11Pixmap.h", "util/x11/X11Pixmap.h",
...@@ -57,10 +44,10 @@ util_x11_sources = [ ...@@ -57,10 +44,10 @@ util_x11_sources = [
"util/x11/X11Window.h", "util/x11/X11Window.h",
] ]
util_fuchsia_sources = util_posix_sources + [ util_fuchsia_sources = [
"util/fuchsia/ScenicWindow.cpp", "util/fuchsia/ScenicWindow.cpp",
"util/fuchsia/ScenicWindow.h", "util/fuchsia/ScenicWindow.h",
] ]
util_ozone_sources = [ util_ozone_sources = [
"util/ozone/OzonePixmap.cpp", "util/ozone/OzonePixmap.cpp",
...@@ -68,17 +55,17 @@ util_ozone_sources = [ ...@@ -68,17 +55,17 @@ util_ozone_sources = [
"util/ozone/OzoneWindow.h", "util/ozone/OzoneWindow.h",
] ]
util_osx_sources = util_posix_sources + [ util_osx_sources = [
"util/osx/OSXPixmap.mm", "util/osx/OSXPixmap.mm",
"util/osx/OSXPixmap.h", "util/osx/OSXPixmap.h",
"util/osx/OSXWindow.mm", "util/osx/OSXWindow.mm",
"util/osx/OSXWindow.h", "util/osx/OSXWindow.h",
] ]
util_android_sources = util_posix_sources + [ util_android_sources = [
"util/android/AndroidPixmap.cpp", "util/android/AndroidPixmap.cpp",
"util/android/AndroidWindow.cpp", "util/android/AndroidWindow.cpp",
"util/android/AndroidWindow.h", "util/android/AndroidWindow.h",
"util/android/third_party/android_native_app_glue.c", "util/android/third_party/android_native_app_glue.c",
"util/android/third_party/android_native_app_glue.h", "util/android/third_party/android_native_app_glue.h",
] ]
...@@ -11,13 +11,11 @@ ...@@ -11,13 +11,11 @@
#include <windows.h> #include <windows.h>
#include <array> #include <array>
#include "util/random_utils.h"
namespace angle namespace angle
{ {
void SetLowPriorityProcess() void SetLowPriorityProcess()
{ {
SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); ::SetPriorityClass(::GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
} }
bool StabilizeCPUForBenchmarking() bool StabilizeCPUForBenchmarking()
......
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