-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Revamp JSON BinPack with the new JSON Toolkit
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
368 changed files
with
27,983 additions
and
48,529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,79 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
project("JSON BinPack" VERSION 0.0.1 LANGUAGES CXX | ||
project(jsonbinpack VERSION 0.0.1 LANGUAGES C CXX | ||
DESCRIPTION "\ | ||
A space-efficient open-source binary JSON serialization \ | ||
format based on JSON Schema with \ | ||
both schema-driven and schema-less support.") | ||
include(vendor/noa/cmake/noa.cmake) | ||
both schema-driven and schema-less support." | ||
HOMEPAGE_URL "https://www.jsonbinpack.org") | ||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") | ||
|
||
include(cmake/warnings.cmake) | ||
# Dependencies | ||
find_package(JSONToolkit REQUIRED) | ||
|
||
# Options | ||
option(JSONBINPACK_CLI "Build the JSON BinPack CLI" ON) | ||
option(JSONBINPACK_TESTS "Build the JSON BinPack tests" ON) | ||
option(JSONBINPACK_TESTS "Build the JSON BinPack tests" OFF) | ||
option(JSONBINPACK_INSTALL "Install the JSON BinPack library" ON) | ||
|
||
# JSON Toolkit | ||
set(JSONTOOLKIT_BACKEND "rapidjson" CACHE STRING "Set JSON backend") | ||
set(JSONTOOLKIT_BACKEND_PATH "${PROJECT_SOURCE_DIR}/vendor/rapidjson" CACHE STRING "Use vendored backend") | ||
add_subdirectory(vendor/jsontoolkit) | ||
# Global includes | ||
include(vendor/noa/cmake/noa.cmake) | ||
include(cmake/CompilerOptions.cmake) | ||
|
||
if(PROJECT_IS_TOP_LEVEL) | ||
noa_target_clang_format(SOURCES | ||
src/*.h src/*.cc | ||
test/*.h test/*.cc) | ||
noa_target_clang_tidy(SOURCES | ||
src/*.h src/*.cc) | ||
noa_target_shellcheck(SOURCES | ||
test/*.sh scripts/*.sh) | ||
endif() | ||
|
||
# Sources | ||
add_subdirectory(src/alterschema) | ||
add_subdirectory(src/canonicalizer) | ||
add_subdirectory(src/encoding) | ||
add_subdirectory(src/parser) | ||
add_subdirectory(src/numeric) | ||
add_subdirectory(src/encoding) | ||
add_subdirectory(src/encoder) | ||
add_subdirectory(src/decoder) | ||
add_subdirectory(src/schemas) | ||
add_subdirectory(src/mapper) | ||
if(JSONBINPACK_CLI) | ||
add_subdirectory(src/cli) | ||
endif() | ||
|
||
# Sources | ||
# add_subdirectory(src/alterschema) | ||
# add_subdirectory(src/canonicalizer) | ||
# add_subdirectory(src/parser) | ||
# add_subdirectory(src/decoder) | ||
# add_subdirectory(src/schemas) | ||
# add_subdirectory(src/mapper) | ||
# if(JSONBINPACK_CLI) | ||
# add_subdirectory(src/cli) | ||
# endif() | ||
|
||
# Testing | ||
if(JSONBINPACK_TESTS) | ||
find_package(GoogleTest REQUIRED) | ||
enable_testing() | ||
set(BUILD_GMOCK OFF CACHE BOOL "disable googlemock") | ||
set(INSTALL_GTEST OFF CACHE BOOL "disable installation") | ||
include(GoogleTest) | ||
add_subdirectory(vendor/googletest) | ||
add_subdirectory(test/alterschema) | ||
add_subdirectory(test/canonicalizer) | ||
add_subdirectory(test/encoding) | ||
add_subdirectory(test/parser) | ||
|
||
add_subdirectory(test/numeric) | ||
add_subdirectory(test/encoding) | ||
add_subdirectory(test/encoder) | ||
add_subdirectory(test/decoder) | ||
add_subdirectory(test/schemas) | ||
add_subdirectory(test/mapper) | ||
if(JSONBINPACK_CLI) | ||
add_subdirectory(test/cli) | ||
endif() | ||
add_subdirectory(test/e2e) | ||
endif() | ||
|
||
# Only for top-level builds | ||
if(PROJECT_IS_TOP_LEVEL) | ||
file(GLOB_RECURSE JSONBINPACK_CXX_SOURCE_FILES src/*.cc src/*.h test/*.cc test/*.h) | ||
noa_target_clang_format(SOURCES ${JSONBINPACK_CXX_SOURCE_FILES}) | ||
noa_target_clang_tidy(SOURCES ${JSONBINPACK_CXX_SOURCE_FILES}) | ||
noa_target_shellcheck(SOURCES test/*.sh scripts/*.sh) | ||
# # Testing | ||
# if(JSONBINPACK_TESTS) | ||
# add_subdirectory(vendor/googletest) | ||
# add_subdirectory(test/alterschema) | ||
# add_subdirectory(test/canonicalizer) | ||
# add_subdirectory(test/parser) | ||
# add_subdirectory(test/decoder) | ||
# add_subdirectory(test/schemas) | ||
# add_subdirectory(test/mapper) | ||
# if(JSONBINPACK_CLI) | ||
# add_subdirectory(test/cli) | ||
# endif() | ||
# add_subdirectory(test/e2e) | ||
# endif() | ||
|
||
# Website | ||
if(PROJECT_IS_TOP_LEVEL) | ||
string(TOLOWER ${CMAKE_BUILD_TYPE} JSONBINPACK_BUILD_TYPE) | ||
set(JSONBINPACK_WEBSITE_OUT ${PROJECT_SOURCE_DIR}/build/${JSONBINPACK_BUILD_TYPE}/www) | ||
set(JSONBINPACK_WEBSITE_SRC ${PROJECT_SOURCE_DIR}/www) | ||
include(${PROJECT_SOURCE_DIR}/cmake/bundler.cmake) | ||
include(${PROJECT_SOURCE_DIR}/cmake/jekyll.cmake) | ||
include(${PROJECT_SOURCE_DIR}/cmake/doxygen.cmake) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
vendorpull https://github.com/sourcemeta/vendorpull 6c398482e30bd85d7e8138c606e01f28270c29ae | ||
rapidjson https://github.com/Tencent/rapidjson 06d58b9e848c650114556a23294d0b6440078c61 | ||
jsontoolkit https://github.com/sourcemeta/jsontoolkit e0efe63940e8c27b3a78ce27ac0c1be70922b741 | ||
googletest https://github.com/google/googletest e2239ee6043f73722e7aa812a459f54a28552929 | ||
jsontoolkit https://github.com/sourcemeta/jsontoolkit 6a81d733421e23813391be3fec4f97d7fd5e082f | ||
googletest https://github.com/google/googletest 987e225614755fec7253aa95bf959c09e0d380d7 | ||
bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e | ||
noa https://github.com/sourcemeta/noa f7dc92ef5bf95ade5f585494e3a6de3692efdf4f | ||
noa https://github.com/sourcemeta/noa 0862a96772362a6997ce2f5fda877b182a7b6f71 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
function(sourcemeta_jsonbinpack_add_compile_options visibility target) | ||
if(NOA_COMPILER_MSVC) | ||
# See https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category | ||
target_compile_options("${target}" ${visibility} | ||
/options:strict | ||
/W4 | ||
/WL | ||
/sdl) | ||
else() | ||
target_compile_options("${target}" ${visibility} | ||
-Wall | ||
-Wextra | ||
-Wpedantic | ||
-Wshadow | ||
-Wdouble-promotion | ||
-Wconversion | ||
-Wunused-parameter | ||
-Wtrigraphs | ||
-Wunreachable-code | ||
-Wmissing-braces | ||
-Wparentheses | ||
-Wswitch | ||
-Wunused-function | ||
-Wunused-label | ||
-Wunused-parameter | ||
-Wunused-variable | ||
-Wunused-value | ||
-Wempty-body | ||
-Wuninitialized | ||
-Wshadow | ||
-Wconversion | ||
-Wenum-conversion | ||
-Wfloat-conversion | ||
-Wimplicit-fallthrough | ||
-Wsign-compare | ||
# TODO: Enable this flag for safety | ||
-Wno-sign-conversion | ||
-Wunknown-pragmas | ||
-Wnon-virtual-dtor | ||
-Woverloaded-virtual | ||
-Winvalid-offsetof | ||
|
||
# Assume that signed arithmetic overflow of addition, subtraction and | ||
# multiplication wraps around using twos-complement representation | ||
# See https://users.cs.utah.edu/~regehr/papers/overflow12.pdf | ||
# See https://www.postgresql.org/message-id/[email protected] | ||
-fwrapv) | ||
endif() | ||
|
||
if(NOA_COMPILER_LLVM) | ||
target_compile_options("${target}" ${visibility} | ||
-Wbool-conversion | ||
-Wint-conversion | ||
-Wpointer-sign | ||
-Wconditional-uninitialized | ||
-Wconstant-conversion | ||
-Wnon-literal-null-conversion | ||
-Wshorten-64-to-32 | ||
-Wdeprecated-implementations | ||
-Winfinite-recursion | ||
-Wnewline-eof | ||
-Wfour-char-constants | ||
-Wselector | ||
-Wundeclared-selector | ||
-Wdocumentation | ||
-Wmove | ||
-Wc++11-extensions | ||
-Wcomma | ||
-Wno-exit-time-destructors | ||
-Wrange-loop-analysis) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
if(NOT GoogleTest_FOUND) | ||
set(BUILD_GMOCK OFF CACHE BOOL "disable googlemock") | ||
set(INSTALL_GTEST OFF CACHE BOOL "disable installation") | ||
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/googletest") | ||
include(GoogleTest) | ||
set(GoogleTest_FOUND ON) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if(NOT JSONToolkit_FOUND) | ||
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/jsontoolkit") | ||
set(JSONToolkit_FOUND ON) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.