зеркало из https://github.com/AvaloniaUI/angle.git
JsonSerializer: use stubs when building without rapidjson
Bug: angleproject:5805 Change-Id: Ibf51b8b75c3feb6efdef969effb3f50e2474c6b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2795772 Commit-Queue: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Родитель
4ed9c4f144
Коммит
b3a8033d77
15
BUILD.gn
15
BUILD.gn
|
@ -922,17 +922,24 @@ group("angle_compression") {
|
|||
}
|
||||
|
||||
angle_source_set("libjson_serializer") {
|
||||
sources = [ "src/libANGLE/serializer/JsonSerializer.h" ]
|
||||
|
||||
if (angle_has_build) {
|
||||
defines = [ "ANGLE_HAVE_RAPIDJSON" ]
|
||||
sources += [ "src/libANGLE/serializer/JsonSerializer.cpp" ]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
":libANGLE_base",
|
||||
"$angle_root/third_party/rapidjson",
|
||||
]
|
||||
sources = [
|
||||
"src/libANGLE/serializer/JsonSerializer.cpp",
|
||||
"src/libANGLE/serializer/JsonSerializer.h",
|
||||
]
|
||||
}
|
||||
|
||||
angle_source_set("libANGLE_with_capture") {
|
||||
if (angle_has_build) {
|
||||
defines = [ "ANGLE_HAVE_RAPIDJSON" ]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
":libANGLE_base",
|
||||
":libjson_serializer",
|
||||
|
|
|
@ -11,13 +11,12 @@
|
|||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <anglebase/sha1.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/filewritestream.h>
|
||||
#include <rapidjson/ostreamwrapper.h>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
|
||||
#include <anglebase/sha1.h>
|
||||
|
||||
namespace angle
|
||||
{
|
||||
|
||||
|
|
|
@ -11,12 +11,13 @@
|
|||
|
||||
#include "common/angleutils.h"
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#if defined(ANGLE_HAVE_RAPIDJSON)
|
||||
# include <rapidjson/document.h>
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <type_traits>
|
||||
# include <memory>
|
||||
# include <sstream>
|
||||
# include <stack>
|
||||
# include <type_traits>
|
||||
|
||||
namespace angle
|
||||
{
|
||||
|
@ -50,6 +51,22 @@ class JsonSerializer : public angle::NonCopyable
|
|||
void startDocument(const std::string &name);
|
||||
void endDocument();
|
||||
|
||||
void addCString(const std::string &name, const char *value);
|
||||
|
||||
void addString(const std::string &name, const std::string &value);
|
||||
|
||||
void addBlob(const std::string &name, const uint8_t *value, size_t length);
|
||||
|
||||
void startGroup(const std::string &name);
|
||||
|
||||
void endGroup();
|
||||
|
||||
const char *data() const;
|
||||
|
||||
std::vector<uint8_t> getData() const;
|
||||
|
||||
size_t length() const;
|
||||
|
||||
template <typename T>
|
||||
void addScalar(const std::string &name, T value)
|
||||
{
|
||||
|
@ -71,22 +88,6 @@ class JsonSerializer : public angle::NonCopyable
|
|||
mGroupValueStack.top()->AddMember(tag, array, mAllocator);
|
||||
}
|
||||
|
||||
void addCString(const std::string &name, const char *value);
|
||||
|
||||
void addString(const std::string &name, const std::string &value);
|
||||
|
||||
void addBlob(const std::string &name, const uint8_t *value, size_t length);
|
||||
|
||||
void startGroup(const std::string &name);
|
||||
|
||||
void endGroup();
|
||||
|
||||
const char *data() const;
|
||||
|
||||
std::vector<uint8_t> getData() const;
|
||||
|
||||
size_t length() const;
|
||||
|
||||
private:
|
||||
using ValuePointer = std::unique_ptr<rapidjson::Value>;
|
||||
|
||||
|
@ -98,5 +99,46 @@ class JsonSerializer : public angle::NonCopyable
|
|||
};
|
||||
|
||||
} // namespace angle
|
||||
#else
|
||||
namespace angle
|
||||
{
|
||||
|
||||
class JsonSerializer : public angle::NonCopyable
|
||||
{
|
||||
|
||||
JsonSerializer() {}
|
||||
~JsonSerializer() {}
|
||||
|
||||
void startDocument(const std::string &name) { (void)name; }
|
||||
void endDocument() {}
|
||||
|
||||
void addCString(const std::string &name, const char *value) {}
|
||||
|
||||
void addString(const std::string &name, const std::string &value) {}
|
||||
|
||||
void addBlob(const std::string &name, const uint8_t *value, size_t length) {}
|
||||
|
||||
void startGroup(const std::string &name) { (void)name; }
|
||||
|
||||
void endGroup() {}
|
||||
|
||||
const char *data() const { return ""; }
|
||||
|
||||
std::vector<uint8_t> getData() const { return std::vector<uint8_t>(); }
|
||||
|
||||
size_t length() const { return 0; }
|
||||
|
||||
template <typename T>
|
||||
void addScalar(const std::string &name, T value)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
void addVector(const std::string &name, const std::vector<T> &value)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace angle
|
||||
|
||||
#endif
|
||||
|
||||
#endif // JSONSERIALIZER_H
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
// JsonSerializer_unittests-cpp: Unit tests for the JSON based serializer
|
||||
//
|
||||
|
||||
#include "JsonSerializer.h"
|
||||
#if defined(ANGLE_HAVE_RAPIDJSON)
|
||||
# include "JsonSerializer.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
class JsonSerializerTest : public ::testing::Test
|
||||
{
|
||||
|
@ -183,3 +184,5 @@ void JsonSerializerTest::check(const std::string &expect)
|
|||
std::vector<uint8_t> expect_as_ubyte(expect.begin(), expect.end());
|
||||
EXPECT_EQ(js.getData(), expect_as_ubyte);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -135,9 +135,15 @@ angle_test("angle_unittests") {
|
|||
}
|
||||
}
|
||||
|
||||
defines = []
|
||||
|
||||
if (angle_enable_hlsl) {
|
||||
sources += angle_unittests_hlsl_sources
|
||||
defines = [ "ANGLE_ENABLE_HLSL" ]
|
||||
defines += [ "ANGLE_ENABLE_HLSL" ]
|
||||
}
|
||||
|
||||
if (angle_has_build) {
|
||||
defines += [ "ANGLE_HAS_RAPIDJSON" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
|
@ -151,6 +157,7 @@ angle_test("angle_unittests") {
|
|||
"$angle_root:translator",
|
||||
"$angle_root/util:angle_util_static",
|
||||
]
|
||||
|
||||
if (!is_android && !is_fuchsia) {
|
||||
# SystemUtils.RunApp, the only unittest using a helper binary, is not supported on these
|
||||
# platforms yet.
|
||||
|
|
Загрузка…
Ссылка в новой задаче