From 8ae1c971ea833fed0640dd87abdeb3374ce890e7 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Tue, 4 Nov 2014 00:36:24 +0200 Subject: [PATCH 01/54] Add initial CMake support * Support for both in-source and out-of-source builds * Set library version to 0.12 to map Debian package * Add separate options to build tests, examples and documentation * Add pkgconfig lookup support (if installed with `make install`) * Add CMake lookup support (if isntalled with `make install`) * Add Google Test Source lookup * Add CTest support for running tests (use `make test` or `ctest -V`) --- CMakeLists.txt | 85 +++++++++++++++++++++++++++++++ CMakeModules/FindGTestSrc.cmake | 22 ++++++++ RapidJSON.pc.in | 4 ++ RapidJSONConfig.cmake.in | 3 ++ RapidJSONConfigVersion.cmake.in | 10 ++++ doc/CMakeLists.txt | 23 +++++++++ build/Doxyfile => doc/Doxyfile.in | 2 +- example/CMakeLists.txt | 19 +++++++ test/CMakeLists.txt | 17 +++++++ test/perftest/CMakeLists.txt | 11 ++++ test/unittest/CMakeLists.txt | 17 +++++++ 11 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 CMakeModules/FindGTestSrc.cmake create mode 100644 RapidJSON.pc.in create mode 100644 RapidJSONConfig.cmake.in create mode 100644 RapidJSONConfigVersion.cmake.in create mode 100644 doc/CMakeLists.txt rename build/Doxyfile => doc/Doxyfile.in (99%) create mode 100644 example/CMakeLists.txt create mode 100644 test/CMakeLists.txt create mode 100644 test/perftest/CMakeLists.txt create mode 100644 test/unittest/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..b7a4961b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,85 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) +SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules) + +PROJECT(RapidJSON CXX) + +set(LIB_MAJOR_VERSION "0") +set(LIB_MINOR_VERSION "12") +set(LIB_PATCH_VERSION "0") +set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}") + +# compile in release with debug info mode by default +SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build Type") + +option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON) +option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON) +option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON) + +#add extra search paths for libraries and includes +SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") +SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install") +SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation") + +IF(UNIX OR CYGWIN) + SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}") +ELSEIF(WIN32) + SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake") +ENDIF() +SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in") + + +include_directories(${CMAKE_SOURCE_DIR}/include) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}") + +if(RAPIDJSON_BUILD_DOC) + add_subdirectory(doc) +endif() + +if(RAPIDJSON_BUILD_EXAMPLES) + add_subdirectory(example) +endif() + +if(RAPIDJSON_BUILD_TESTS) + add_subdirectory(test) + include(CTest) +endif() + +# pkg-config +IF (UNIX OR CYGWIN) + CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + @ONLY) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION "${LIB_INSTALL_DIR}/pkgconfig" + COMPONENT pkgconfig) +ENDIF() + +install(FILES readme.md + DESTINATION "${DOC_INSTALL_DIR}" + COMPONENT doc) + +install(DIRECTORY include/rapidjson + DESTINATION "${INCLUDE_INSTALL_DIR}" + COMPONENT dev) + +install(DIRECTORY example/ + DESTINATION "${DOC_INSTALL_DIR}/examples" + COMPONENT examples) + +# Provide config and version files to be used by other applications +# =============================== + +export(PACKAGE ${PROJECT_NAME}) + +# cmake-modules +CONFIGURE_FILE(${PROJECT_NAME}Config.cmake.in + ${PROJECT_NAME}Config.cmake + @ONLY) +CONFIGURE_FILE(${PROJECT_NAME}ConfigVersion.cmake.in + ${PROJECT_NAME}ConfigVersion.cmake + @ONLY) +INSTALL(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION "${CMAKE_INSTALL_DIR}" + COMPONENT dev) diff --git a/CMakeModules/FindGTestSrc.cmake b/CMakeModules/FindGTestSrc.cmake new file mode 100644 index 00000000..89f132e5 --- /dev/null +++ b/CMakeModules/FindGTestSrc.cmake @@ -0,0 +1,22 @@ +SET(GTEST_SEARCH_PATH + "${GTEST_SOURCE_DIR}" + "${CMAKE_SOURCE_DIR}/thirdparty/gtest") + +IF(UNIX) + LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest") +ENDIF() + +FIND_PATH(GTEST_SOURCE_DIR + NAMES CMakeLists.txt src/gtest_main.cc + PATHS ${GTEST_SEARCH_PATH}) + +# Debian installs gtest include directory in /usr/include, thus need to look +# for include directory separately from source directory. +FIND_PATH(GTEST_INCLUDE_DIR + NAMES gtest/gtest.h + PATH_SUFFIXES include + PATHS ${GTEST_SEARCH_PATH}) + +find_package_handle_standard_args(GTestSrc DEFAULT_MSG + GTEST_SOURCE_DIR + GTEST_INCLUDE_DIR) diff --git a/RapidJSON.pc.in b/RapidJSON.pc.in new file mode 100644 index 00000000..be4f7887 --- /dev/null +++ b/RapidJSON.pc.in @@ -0,0 +1,4 @@ +Name: @PROJECT_NAME@ +Description: RapidJSON is a JSON parser and generator for C++ inspired by RapidXml. +Version: @LIB_VERSION_STRING@ +Cflags: -I${includedir} diff --git a/RapidJSONConfig.cmake.in b/RapidJSONConfig.cmake.in new file mode 100644 index 00000000..9fa12186 --- /dev/null +++ b/RapidJSONConfig.cmake.in @@ -0,0 +1,3 @@ +get_filename_component(RAPIDJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(RAPIDJSON_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@") +message(STATUS "RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}") diff --git a/RapidJSONConfigVersion.cmake.in b/RapidJSONConfigVersion.cmake.in new file mode 100644 index 00000000..25741fc0 --- /dev/null +++ b/RapidJSONConfigVersion.cmake.in @@ -0,0 +1,10 @@ +SET(PACKAGE_VERSION "@LIB_VERSION_STRING@") + +IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + SET(PACKAGE_VERSION_EXACT "true") +ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) +IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + SET(PACKAGE_VERSION_COMPATIBLE "true") +ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + SET(PACKAGE_VERSION_UNSUITABLE "true") +ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..685a00e8 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,23 @@ +find_package(Doxygen) + +IF(NOT DOXYGEN_FOUND) + MESSAGE(STATUS "No Doxygen found. Documentation won't be built") +ELSE() + file(GLOB SOURCES ${CMAKE_SOURCE_DIR}/include/*) + file(GLOB MARKDOWN_DOC ${CMAKE_SOURCE_DIR}/doc/*.md) + list(APPEND MARKDOWN_DOC ${CMAKE_SOURCE_DIR}/readme.md) + + CONFIGURE_FILE(Doxyfile.in Doxyfile @ONLY) + + add_custom_command(OUTPUT html + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/html + DEPENDS ${MARKDOWN_DOC} ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + + add_custom_target(doc ALL DEPENDS html) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html + DESTINATION ${DOC_INSTALL_DIR} + COMPONENT doc) +ENDIF() diff --git a/build/Doxyfile b/doc/Doxyfile.in similarity index 99% rename from build/Doxyfile rename to doc/Doxyfile.in index d2a03bed..d11a02fc 100644 --- a/build/Doxyfile +++ b/doc/Doxyfile.in @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = ./doc +OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@ # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 00000000..cd355b42 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) 2011 Milo Yip (miloyip@gmail.com) +# Copyright (c) 2013 Rafal Jeczalik (rjeczalik@gmail.com) +# Distributed under the MIT License (see license.txt file) + +set(EXAMPLES + capitalize + condense + messagereader + pretty + prettyauto + serialize + simpledom + simplereader + simplewriter + tutorial) + +foreach (example ${EXAMPLES}) + add_executable(${example}_ ${example}/${example}.cpp) +endforeach() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..92d43094 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,17 @@ +find_package(GTestSrc) + +IF(GTESTSRC_FOUND) + enable_testing() + + if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW)) + set(gtest_disable_pthreads ON) + endif() + + add_subdirectory(${GTEST_SOURCE_DIR} ${CMAKE_BINARY_DIR}/googletest) + include_directories(${GTEST_INCLUDE_DIR}) + + set(TEST_LIBRARIES gtest gtest_main) + + add_subdirectory(perftest) + add_subdirectory(unittest) +ENDIF(GTESTSRC_FOUND) diff --git a/test/perftest/CMakeLists.txt b/test/perftest/CMakeLists.txt new file mode 100644 index 00000000..35895670 --- /dev/null +++ b/test/perftest/CMakeLists.txt @@ -0,0 +1,11 @@ +set(PERFTEST_SOURCES + misctest.cpp + perftest.cpp + platformtest.cpp + rapidjsontest.cpp) + +add_executable(perftest ${PERFTEST_SOURCES}) +target_link_libraries(perftest ${TEST_LIBRARIES}) +add_test(NAME perftest + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/perftest + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt new file mode 100644 index 00000000..fa687e76 --- /dev/null +++ b/test/unittest/CMakeLists.txt @@ -0,0 +1,17 @@ +set(UNITTEST_SOURCES + documenttest.cpp + encodedstreamtest.cpp + encodingstest.cpp + filestreamtest.cpp + jsoncheckertest.cpp + readertest.cpp + unittest.cpp + unittest.h + valuetest.cpp + writertest.cpp) + +add_executable(unittest ${UNITTEST_SOURCES}) +target_link_libraries(unittest ${TEST_LIBRARIES}) +add_test(NAME unittest + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unittest + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) From 5cceb9e37aecda8f8d703cd44cafd94f035b5ff3 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Tue, 4 Nov 2014 01:17:43 +0200 Subject: [PATCH 02/54] Fix broken references in documentation --- doc/Doxyfile.in | 26 +++++++++++++------------- doc/dom.md | 4 ++-- doc/faq.md | 2 +- doc/tutorial.md | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index d11a02fc..69201431 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -764,18 +764,18 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = ./include/rapidjson/rapidjson.h \ - ./include/ \ - ./readme.md \ - ./doc/features.md \ - ./doc/tutorial.md \ - ./doc/stream.md \ - ./doc/encoding.md \ - ./doc/dom.md \ - ./doc/sax.md \ - ./doc/performance.md \ - ./doc/internals.md \ - ./doc/faq.md +INPUT = readme.md \ + include/rapidjson/rapidjson.h \ + include/ \ + doc/features.md \ + doc/tutorial.md \ + doc/stream.md \ + doc/encoding.md \ + doc/dom.md \ + doc/sax.md \ + doc/performance.md \ + doc/internals.md \ + doc/faq.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -920,7 +920,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = ./readme.md +USE_MDFILE_AS_MAINPAGE = readme.md #--------------------------------------------------------------------------- # Configuration options related to source browsing diff --git a/doc/dom.md b/doc/dom.md index d2274de2..f8315920 100644 --- a/doc/dom.md +++ b/doc/dom.md @@ -31,7 +31,7 @@ User can customize these template parameters. ## Encoding {#Encoding} -The `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8`, which means using char to store the characters. You may refer to [Encoding](encoding.md) for details. +The `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8`, which means using char to store the characters. You may refer to [Encoding](doc/encoding.md) for details. Suppose a Windows application would query localization strings stored in JSON files. Unicode-enabled functions in Windows use UTF-16 (wide character) encoding. No matter what encoding was used in JSON files, we can store the strings in UTF-16 in memory. @@ -106,7 +106,7 @@ GenericDocument& GenericDocument::Parse(const Ch* str); GenericDocument& GenericDocument::Parse(const Ch* str); ~~~~~~~~~~ -The examples of [tutorial](tutorial.md) uses (9) for normal parsing of string. The examples of [stream](stream.md) uses the first three. *In situ* parsing will be described soon. +The examples of [tutorial](doc/tutorial.md) uses (9) for normal parsing of string. The examples of [stream](doc/stream.md) uses the first three. *In situ* parsing will be described soon. The `parseFlags` are combination of the following bit-flags: diff --git a/doc/faq.md b/doc/faq.md index 46eb967e..22c4cf73 100644 --- a/doc/faq.md +++ b/doc/faq.md @@ -4,7 +4,7 @@ 1. What is RapidJSON? - RapidJSON is a C++ library for parsing and generating JSON. You may check all [features](features.md) of it. + RapidJSON is a C++ library for parsing and generating JSON. You may check all [features](doc/features.md) of it. 2. Why is it named so? diff --git a/doc/tutorial.md b/doc/tutorial.md index 40e061ca..72e26704 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2,7 +2,7 @@ This tutorial introduces the basics of the Document Object Model(DOM) API. -As shown in [Usage at a glance](readme.md), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. +As shown in [Usage at a glance](@ref index), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. [TOC] @@ -512,4 +512,4 @@ This tutorial shows the basics of DOM tree query and manipulation. There are sev 5. [Performance](doc/performance.md) shows some in-house and third-party benchmarks. 6. [Internals](doc/internals.md) describes some internal designs and techniques of RapidJSON. -You may also refer to the [FAQ](faq.md), API documentation, examples and unit tests. +You may also refer to the [FAQ](doc/faq.md), API documentation, examples and unit tests. From d69991fa11cac8dea91f60f5e7a75970873262c7 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Tue, 11 Nov 2014 17:16:51 +0200 Subject: [PATCH 03/54] Set separate directory to place binaries --- CMakeLists.txt | 3 +++ example/CMakeLists.txt | 2 +- test/perftest/CMakeLists.txt | 2 +- test/unittest/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7a4961b..36e7d1d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,9 @@ set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VE # compile in release with debug info mode by default SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build Type") +# Build all binaries in a separate directory +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON) option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON) option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index cd355b42..1523c638 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -15,5 +15,5 @@ set(EXAMPLES tutorial) foreach (example ${EXAMPLES}) - add_executable(${example}_ ${example}/${example}.cpp) + add_executable(${example} ${example}/${example}.cpp) endforeach() diff --git a/test/perftest/CMakeLists.txt b/test/perftest/CMakeLists.txt index 35895670..8d5d4e37 100644 --- a/test/perftest/CMakeLists.txt +++ b/test/perftest/CMakeLists.txt @@ -7,5 +7,5 @@ set(PERFTEST_SOURCES add_executable(perftest ${PERFTEST_SOURCES}) target_link_libraries(perftest ${TEST_LIBRARIES}) add_test(NAME perftest - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/perftest + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perftest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index fa687e76..2e8c05f3 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -13,5 +13,5 @@ set(UNITTEST_SOURCES add_executable(unittest ${UNITTEST_SOURCES}) target_link_libraries(unittest ${TEST_LIBRARIES}) add_test(NAME unittest - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unittest + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) From 1f1aab1061006250801aaf5d1cd30c0fd1ced9cf Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Wed, 5 Nov 2014 04:00:05 +0200 Subject: [PATCH 04/54] Ignore files generated by CMake --- .gitignore | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index 304456ff..8ea8f005 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,17 @@ /doc/doxygen_*.db /thirdparty/lib /intermediate + +# Temporary files created during CMake build +CMakeCache.txt +CMakeFiles +cmake_install.cmake +CTestTestfile.cmake +Makefile +RapidJSON*.cmake +RapidJSON.pc +Testing +/googletest +install_manifest.txt +Doxyfile +DartConfiguration.tcl From 6f7789ef6d8a681ecc0fb3244b8c431556f0b7eb Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Tue, 11 Nov 2014 17:17:23 +0200 Subject: [PATCH 05/54] Update readme with changes to CMake build process --- readme.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 3c53cc2b..c695a164 100644 --- a/readme.md +++ b/readme.md @@ -41,21 +41,28 @@ Users can build and run the unit tests on their platform/compiler. RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder to system or project's include path. -To build the tests and examples: +RapidJSON uses following software as its dependencies: +* [CMake](http://www.cmake.org) as a general build tool +* (optional)[Doxygen](http://www.goxygen.org) to build documentation +* (optional)[googletest](https://code.google.com/p/googletest/) for unit and performance testing +To generate user documentation and run tests please proceed with the steps below: 1. Execute `git submodule update --init` to get the files of thirdparty submodules (google test). -2. Obtain [premake4](http://industriousone.com/premake/download). -3. Copy premake4 executable to `rapidjson/build` (or system path). -4. Change directory to `rapidjson/build/`, run `premake.bat` on Windows, `premake.sh` on Linux or other platforms. -5. On Windows, build the solution at `rapidjson/build/vs2008/` or `/vs2010/`. -6. On other platforms, run GNU `make` at `rapidjson/build/gmake/` (e.g., `make -f test.make config=release32`; `make -f example.make config=debug32`). -7. On success, the executables are generated at `rapidjson/bin`. +2. Create directory called `build` nearby rapidjson source directory. +3. Change to `build` directory and run `cmake ../rapidjson` command to configure your build. Windows users can do the same with cmake-gui application. +4. On Windows, build the solution found in the build directory. On Linux, run `make` from the build directory. -To build the [Doxygen](http://doxygen.org) documentation: +On successfull build you will find compiled test and example binaries in `bin` +directory. The generated documentation will be available in `doc/html` +directory of the build tree. To run tests after finished build please run `make +test` or `ctest` from your build tree. You can get detailed output using `ctest +-V` command. -1. Obtain and install [Doxygen](http://doxygen.org/download.html). -2. In the top-level directory, run `doxygen build/Doxyfile`. -3. Browse the generated documentation in `doc/html`. +It is possible to install library system-wide by running `make install` command +from the build tree with administrative privileges. This will install all files +according to system preferences. Once RapidJSON is installed, it is possible +to use it from other CMake projects by adding `find_package(RapidJSON)` line to +your CMakeLists.txt. ## Usage at a glance From 8f3f0ea16784b4bce3f4c3d9ec36a0325aca7162 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Tue, 11 Nov 2014 17:50:32 +0200 Subject: [PATCH 06/54] Add separate targets for examples and tests --- example/CMakeLists.txt | 2 ++ test/CMakeLists.txt | 2 ++ test/perftest/CMakeLists.txt | 3 +++ test/unittest/CMakeLists.txt | 3 +++ 4 files changed, 10 insertions(+) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 1523c638..ae498345 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -17,3 +17,5 @@ set(EXAMPLES foreach (example ${EXAMPLES}) add_executable(${example} ${example}/${example}.cpp) endforeach() + +add_custom_target(examples ALL DEPENDS ${EXAMPLES}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 92d43094..af09c62a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,6 +12,8 @@ IF(GTESTSRC_FOUND) set(TEST_LIBRARIES gtest gtest_main) + add_custom_target(tests ALL) add_subdirectory(perftest) add_subdirectory(unittest) + ENDIF(GTESTSRC_FOUND) diff --git a/test/perftest/CMakeLists.txt b/test/perftest/CMakeLists.txt index 8d5d4e37..4185f12a 100644 --- a/test/perftest/CMakeLists.txt +++ b/test/perftest/CMakeLists.txt @@ -6,6 +6,9 @@ set(PERFTEST_SOURCES add_executable(perftest ${PERFTEST_SOURCES}) target_link_libraries(perftest ${TEST_LIBRARIES}) + +add_dependencies(tests perftest) + add_test(NAME perftest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perftest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 2e8c05f3..720c0632 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -12,6 +12,9 @@ set(UNITTEST_SOURCES add_executable(unittest ${UNITTEST_SOURCES}) target_link_libraries(unittest ${TEST_LIBRARIES}) + +add_dependencies(tests unittest) + add_test(NAME unittest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) From 40648f164b7a925d31aae8daa5ecbdeaa5bf2a3c Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Tue, 11 Nov 2014 18:10:55 +0200 Subject: [PATCH 07/54] Add namespacetest to the unit tests --- test/unittest/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 720c0632..fb728781 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UNITTEST_SOURCES encodingstest.cpp filestreamtest.cpp jsoncheckertest.cpp + namespacetest.cpp readertest.cpp unittest.cpp unittest.h From bff9625e866376e21ef7aafbfbb123d5e7523826 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Wed, 12 Nov 2014 01:57:00 +0200 Subject: [PATCH 08/54] Add travis tests to be run from CTest --- test/perftest/CMakeLists.txt | 2 ++ test/unittest/CMakeLists.txt | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/perftest/CMakeLists.txt b/test/perftest/CMakeLists.txt index 4185f12a..4121bf9f 100644 --- a/test/perftest/CMakeLists.txt +++ b/test/perftest/CMakeLists.txt @@ -9,6 +9,8 @@ target_link_libraries(perftest ${TEST_LIBRARIES}) add_dependencies(tests perftest) +IF(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug")) add_test(NAME perftest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perftest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) +ENDIF() diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index fb728781..41e56952 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -4,18 +4,29 @@ set(UNITTEST_SOURCES encodingstest.cpp filestreamtest.cpp jsoncheckertest.cpp - namespacetest.cpp readertest.cpp unittest.cpp unittest.h valuetest.cpp writertest.cpp) +add_library(namespacetest STATIC namespacetest.cpp) + add_executable(unittest ${UNITTEST_SOURCES}) -target_link_libraries(unittest ${TEST_LIBRARIES}) +target_link_libraries(unittest ${TEST_LIBRARIES} namespacetest) add_dependencies(tests unittest) add_test(NAME unittest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) + +add_test(NAME valgrind_unittest + COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) + +IF((NOT MSVC) AND (CMAKE_BUILD_TYPE STREQUAL "Debug")) +add_test(NAME symbol_check + COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +ENDIF() From 40c03114e3b4a0751faa134e2ef917fcaf6fee63 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Wed, 12 Nov 2014 01:57:25 +0200 Subject: [PATCH 09/54] Try new travis configuration --- .travis.yml | 39 +++-- CMakeLists.txt | 12 +- build/premake.bat | 5 - build/premake.sh | 5 - build/premake4.lua | 161 ------------------- readme.md | 4 +- build/travis-doxygen.sh => travis-doxygen.sh | 10 +- 7 files changed, 37 insertions(+), 199 deletions(-) delete mode 100644 build/premake.bat delete mode 100755 build/premake.sh delete mode 100644 build/premake4.lua rename build/travis-doxygen.sh => travis-doxygen.sh (94%) diff --git a/.travis.yml b/.travis.yml index 986ca0e0..cbc5c0f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,36 +6,35 @@ compiler: env: matrix: - - CONF=debug BITS=64 - - CONF=release BITS=64 - - CONF=debug BITS=32 - - CONF=release BITS=32 + - CONF=debug ARCH=x86_64 ARCH_FLAGS="" + - CONF=release ARCH=x86_64 ARCH_FLAGS="" + - CONF=debug ARCH=x86 ARCH_FLAGS="-m32" + - CONF=release ARCH=x86 ARCH_FLAGS="-m32" global: - GITHUB_REPO='miloyip/rapidjson' - - DEFINES='-DRAPIDJSON_HAS_STDSTRING' - secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk=" before_install: - - sudo add-apt-repository -y ppa:codegear/release - - sudo apt-get update -qq - - sudo apt-get install -qq premake4 valgrind - - if [ "$BITS" = 32 ]; then sudo apt-get install -qq g++-multilib libc6-dbg:i386; fi + - sudo apt-get install -qq cmake doxygen valgrind + - if [ "$ARCH" = "x86" ]; then sudo apt-get install -qq g++-multilib libc6-dbg:i386; fi install: true before_script: - - (cd build && premake4 'gmake') + - mkdir build + - > + (cd build && cmake + -DRAPIDJSON_HAS_STDSTRING=ON + -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_BUILD_TYPE=$CONF + -DCMAKE_C_FLAGS="$ARCH_FLAGS" ..) # hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469), # exposed by merging PR#163 (using -march=native) - - (cd build/gmake && sed -i 's/march=native/msse4.2/' *.make) +# - (cd build/gmake && sed -i 's/march=native/msse4.2/' *.make) script: - - make -C build/gmake -f test.make config=${CONF}${BITS} - - make -C build/gmake -f example.make config=${CONF}${BITS} - - if [ "$CONF" = "debug" ] && ( objdump -t -C intermediate/${CONF}/gmake/unittest/x${BITS}/namespacetest.o | grep rapidjson ) ; then echo "Symbol check failed!" ; false; fi - - pushd bin - - ./unittest_${CONF}_x${BITS}_gmake - - valgrind --leak-check=full --error-exitcode=1 ./unittest_${CONF}_x${BITS}_gmake - - if [ "$CONF" = "release" ]; then ./perftest_${CONF}_x${BITS}_gmake; fi - - popd - - ./build/travis-doxygen.sh; + - cd build + - make tests + - make examples + - ctest -V + - make travis_doc diff --git a/CMakeLists.txt b/CMakeLists.txt index 36e7d1d5..8ed65c89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules) PROJECT(RapidJSON CXX) @@ -18,6 +18,12 @@ option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON) option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON) option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON) +option(RAPIDJSON_HAS_STDSTRING "" OFF) +if(RAPIDJSON_HAS_STDSTRING) + add_definitions(-DRAPIDJSON_HAS_STDSTRING) +endif() + + #add extra search paths for libraries and includes SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install") @@ -38,6 +44,10 @@ if(RAPIDJSON_BUILD_DOC) add_subdirectory(doc) endif() +add_custom_target(travis_doc) +add_custom_command(TARGET travis_doc + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/travis-doxygen.sh) + if(RAPIDJSON_BUILD_EXAMPLES) add_subdirectory(example) endif() diff --git a/build/premake.bat b/build/premake.bat deleted file mode 100644 index fe1941a2..00000000 --- a/build/premake.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -premake4 vs2005 -premake4 vs2008 -premake4 vs2010 -premake4 gmake \ No newline at end of file diff --git a/build/premake.sh b/build/premake.sh deleted file mode 100755 index eaefce82..00000000 --- a/build/premake.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -premake4 vs2005 -premake4 vs2008 -premake4 vs2010 -premake4 gmake diff --git a/build/premake4.lua b/build/premake4.lua deleted file mode 100644 index cabc2e7b..00000000 --- a/build/premake4.lua +++ /dev/null @@ -1,161 +0,0 @@ -function setTargetObjDir(outDir) - for _, cfg in ipairs(configurations()) do - for _, plat in ipairs(platforms()) do - local action = _ACTION or "" - - local prj = project() - - --"_debug_win32_vs2008" - local suffix = "_" .. cfg .. "_" .. plat .. "_" .. action - - targetPath = outDir - - suffix = string.lower(suffix) - - local obj_path = "../intermediate/" .. cfg .. "/" .. action .. "/" .. prj.name - - obj_path = string.lower(obj_path) - - configuration {cfg, plat} - targetdir(targetPath) - objdir(obj_path) - targetsuffix(suffix) - end - end -end - -function linkLib(libBaseName) - for _, cfg in ipairs(configurations()) do - for _, plat in ipairs(platforms()) do - local action = _ACTION or "" - - local prj = project() - - local cfgName = cfg - - --"_debug_win32_vs2008" - local suffix = "_" .. cfgName .. "_" .. plat .. "_" .. action - - libFullName = libBaseName .. string.lower(suffix) - - configuration {cfg, plat} - links(libFullName) - end - end -end - -solution "test" - configurations { "debug", "release" } - platforms { "x32", "x64" } - - location ("./" .. (_ACTION or "")) - language "C++" - flags { "ExtraWarnings" } - - configuration "debug" - defines { "DEBUG" } - flags { "Symbols" } - - configuration "release" - defines { "NDEBUG" } - flags { "Optimize" } - - configuration "vs*" - defines { "_CRT_SECURE_NO_WARNINGS" } - - configuration "gmake" - buildoptions "-march=native -Wall -Wextra" - - project "gtest" - kind "StaticLib" - - defines { "GTEST_HAS_PTHREAD=0" } - - files { - "../thirdparty/gtest/src/gtest-all.cc", - "../thirdparty/gtest/src/**.h", - } - - includedirs { - "../thirdparty/gtest/", - "../thirdparty/gtest/include", - } - - setTargetObjDir("../thirdparty/lib") - - project "unittest" - kind "ConsoleApp" - - if _ACTION == "gmake" then - buildoptions "-Werror -Weffc++ -Wswitch-default" - end - - files { - "../include/**.h", - "../test/unittest/**.cpp", - "../test/unittest/**.h", - } - - includedirs { - "../include/", - "../thirdparty/gtest/include/", - } - - libdirs "../thirdparty/lib" - - setTargetObjDir("../bin") - - linkLib "gtest" - links "gtest" - - project "perftest" - kind "ConsoleApp" - - files { - "../include/**.h", - "../test/perftest/**.cpp", - "../test/perftest/**.h", - } - - includedirs { - "../include/", - "../thirdparty/gtest/include/", - "../thirdparty/", - } - - libdirs "../thirdparty/lib" - - setTargetObjDir("../bin") - - linkLib "gtest" - links "gtest" - -solution "example" - configurations { "debug", "release" } - platforms { "x32", "x64" } - location ("./" .. (_ACTION or "")) - language "C++" - flags { "ExtraWarnings" } - includedirs "../include/" - - configuration "debug" - defines { "DEBUG" } - flags { "Symbols" } - - configuration "release" - defines { "NDEBUG" } - flags { "Optimize", "EnableSSE2" } - - configuration "vs*" - defines { "_CRT_SECURE_NO_WARNINGS" } - - configuration "gmake" - buildoptions "-Werror -Wall -Wextra -Weffc++ -Wswitch-default" - - local examplepaths = os.matchdirs("../example/*") - for _, examplepath in ipairs(examplepaths) do - project(path.getname(examplepath)) - kind "ConsoleApp" - files(examplepath .. "/*") - setTargetObjDir("../bin") - end diff --git a/readme.md b/readme.md index c695a164..81f48110 100644 --- a/readme.md +++ b/readme.md @@ -48,8 +48,8 @@ RapidJSON uses following software as its dependencies: To generate user documentation and run tests please proceed with the steps below: 1. Execute `git submodule update --init` to get the files of thirdparty submodules (google test). -2. Create directory called `build` nearby rapidjson source directory. -3. Change to `build` directory and run `cmake ../rapidjson` command to configure your build. Windows users can do the same with cmake-gui application. +2. Create directory called `build` in rapidjson source directory. +3. Change to `build` directory and run `cmake ..` command to configure your build. Windows users can do the same with cmake-gui application. 4. On Windows, build the solution found in the build directory. On Linux, run `make` from the build directory. On successfull build you will find compiled test and example binaries in `bin` diff --git a/build/travis-doxygen.sh b/travis-doxygen.sh similarity index 94% rename from build/travis-doxygen.sh rename to travis-doxygen.sh index 5c4d4a1d..a7586297 100755 --- a/build/travis-doxygen.sh +++ b/travis-doxygen.sh @@ -57,13 +57,13 @@ doxygen_install() doxygen_run() { - cd "${TRAVIS_BUILD_DIR}"; - doxygen build/Doxyfile; + cd "${TRAVIS_BUILD_DIR}/build/doc"; + doxygen Doxyfile; } gh_pages_prepare() { - cd "${TRAVIS_BUILD_DIR}/doc"; + cd "${TRAVIS_BUILD_DIR}/build/doc"; [ ! -d "html" ] || \ abort "Doxygen target directory already exists." git --version @@ -78,7 +78,7 @@ gh_pages_prepare() } gh_pages_commit() { - cd "${TRAVIS_BUILD_DIR}/doc/html"; + cd "${TRAVIS_BUILD_DIR}/build/doc/html"; git add --all; git diff-index --quiet HEAD || git commit -m "Automatic doxygen build"; } @@ -102,7 +102,7 @@ gh_pages_push() { [ "${#GH_TOKEN}" -eq 40 ] || \ abort "GitHub token invalid: found ${#GH_TOKEN} characters, expected 40." - cd "${TRAVIS_BUILD_DIR}/doc/html"; + cd "${TRAVIS_BUILD_DIR}/build/doc/html"; # setup credentials (hide in "set -x" mode) git remote set-url --push origin "${GITHUB_URL}" git config credential.helper 'store' From d2b235edbf1187fb061a3da66a32eb78309d3d92 Mon Sep 17 00:00:00 2001 From: Andriy Senkovych Date: Wed, 19 Nov 2014 02:45:09 +0200 Subject: [PATCH 10/54] Modify PATH variable instead of using sudo --- travis-doxygen.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/travis-doxygen.sh b/travis-doxygen.sh index a7586297..0e715a79 100755 --- a/travis-doxygen.sh +++ b/travis-doxygen.sh @@ -4,7 +4,6 @@ set -e -SUDO=sudo DOXYGEN_VER=doxygen-1.8.7 DOXYGEN_TAR=${DOXYGEN_VER}.linux.bin.tar.gz DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}" @@ -51,14 +50,13 @@ doxygen_install() { wget -O - "${DOXYGEN_URL}" | \ tar xz -C ${TMPDIR-/tmp} ${DOXYGEN_VER}/bin/doxygen - $SUDO install -m 755 ${TMPDIR-/tmp}/${DOXYGEN_VER}/bin/doxygen \ - ${DOXYGEN_BIN}; + export PATH="${TMPDIR-/tmp}/${DOXYGEN_VER}/bin:$PATH" } doxygen_run() { - cd "${TRAVIS_BUILD_DIR}/build/doc"; - doxygen Doxyfile; + cd "${TRAVIS_BUILD_DIR}"; + doxygen ${TRAVIS_BUILD_DIR}/build/doc/Doxyfile; } gh_pages_prepare() From 38dace775c359e1913648ac52b1092aac3e41b14 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 7 Feb 2015 14:49:25 +0100 Subject: [PATCH 11/54] warning fixes (closes #235, closes #236) --- include/rapidjson/reader.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index f0aa318c..5f545819 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -382,7 +382,7 @@ public: typedef typename SourceEncoding::Ch Ch; //!< SourceEncoding character type //! Constructor. - /*! \param allocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing) + /*! \param stackAllocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing) \param stackCapacity stack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing) */ GenericReader(StackAllocator* stackAllocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(stackAllocator, stackCapacity), parseResult_() {} @@ -728,12 +728,12 @@ private: } template - class NumberStream {}; + class NumberStream; template class NumberStream { public: - NumberStream(GenericReader& reader, InputStream& is) : is(is) { (void)reader; } + NumberStream(GenericReader& reader, InputStream& s) : is(s) { (void)reader; } ~NumberStream() {} RAPIDJSON_FORCEINLINE Ch Peek() const { return is.Peek(); } From 10b6a133f6c2b8eb4f089f9da92fbd0da144d4f2 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Wed, 11 Feb 2015 12:06:18 +0800 Subject: [PATCH 12/54] Update readme.md Fix typesetting --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index b1936bd5..05c0ec3d 100644 --- a/readme.md +++ b/readme.md @@ -47,6 +47,7 @@ RapidJSON uses following software as its dependencies: * (optional)[googletest](https://code.google.com/p/googletest/) for unit and performance testing To generate user documentation and run tests please proceed with the steps below: + 1. Execute `git submodule update --init` to get the files of thirdparty submodules (google test). 2. Create directory called `build` in rapidjson source directory. 3. Change to `build` directory and run `cmake ..` command to configure your build. Windows users can do the same with cmake-gui application. From 8b3d72467b591002c676566e85a49e6326c56489 Mon Sep 17 00:00:00 2001 From: miloyip Date: Wed, 11 Feb 2015 18:34:56 +0800 Subject: [PATCH 13/54] Fix VC linkage error for CMAKE Mentioned in #240 --- test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index af09c62a..64033b31 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,6 +2,7 @@ find_package(GTestSrc) IF(GTESTSRC_FOUND) enable_testing() + set(gtest_force_shared_crt ON) if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW)) set(gtest_disable_pthreads ON) From 1b0fe576d701673f07b2d2cb05c22f2935d286fe Mon Sep 17 00:00:00 2001 From: miloyip Date: Thu, 12 Feb 2015 10:09:52 +0800 Subject: [PATCH 14/54] Revise gitignore for cmake --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8ea8f005..e4478e0f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,6 @@ !/bin/data !/bin/encodings !/bin/jsonchecker -/build/*.exe -/build/gmake -/build/vs*/ /doc/html /doc/doxygen_*.db /thirdparty/lib @@ -23,3 +20,4 @@ Testing install_manifest.txt Doxyfile DartConfiguration.tcl +/build/* \ No newline at end of file From edfde4bfa24d71bc13c4bbb34366de34bacc994f Mon Sep 17 00:00:00 2001 From: Janusz Chorko Date: Sat, 14 Feb 2015 17:17:16 +0100 Subject: [PATCH 15/54] Fix ambiguous overload when uint32_t is not unsigned int but unsigned long. --- include/rapidjson/internal/biginteger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/internal/biginteger.h b/include/rapidjson/internal/biginteger.h index 72acfc38..a3a0c7ff 100755 --- a/include/rapidjson/internal/biginteger.h +++ b/include/rapidjson/internal/biginteger.h @@ -172,7 +172,7 @@ public: }; if (exp == 0) return *this; for (; exp >= 27; exp -= 27) *this *= RAPIDJSON_UINT64_C2(0X6765C793, 0XFA10079D); // 5^27 - for (; exp >= 13; exp -= 13) *this *= 1220703125u; // 5^13 + for (; exp >= 13; exp -= 13) *this *= static_cast(1220703125u); // 5^13 if (exp > 0) *this *= kPow5[exp - 1]; return *this; } From 78befee2bd6cd8a54c24972a96fa9d50af509b33 Mon Sep 17 00:00:00 2001 From: Janusz Chorko Date: Sat, 14 Feb 2015 17:18:45 +0100 Subject: [PATCH 16/54] Fix compilation error when cstring does not import std::memcmp into global namespace. --- include/rapidjson/internal/biginteger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/internal/biginteger.h b/include/rapidjson/internal/biginteger.h index a3a0c7ff..3e97920d 100755 --- a/include/rapidjson/internal/biginteger.h +++ b/include/rapidjson/internal/biginteger.h @@ -148,7 +148,7 @@ public: } bool operator==(const BigInteger& rhs) const { - return count_ == rhs.count_ && memcmp(digits_, rhs.digits_, count_ * sizeof(Type)) == 0; + return count_ == rhs.count_ && std::memcmp(digits_, rhs.digits_, count_ * sizeof(Type)) == 0; } bool operator==(const Type rhs) const { From ecc14866e0e500999b42de0e91e77f004977719f Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sun, 15 Feb 2015 14:19:56 +0800 Subject: [PATCH 17/54] Update CMakeLists.txt Move `gtest_force_shared_crt` option to Win32 VC only. --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 64033b31..c698af4f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,10 +2,10 @@ find_package(GTestSrc) IF(GTESTSRC_FOUND) enable_testing() - set(gtest_force_shared_crt ON) if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW)) set(gtest_disable_pthreads ON) + set(gtest_force_shared_crt ON) endif() add_subdirectory(${GTEST_SOURCE_DIR} ${CMAKE_BINARY_DIR}/googletest) From 63ad11c367cb986c0601a0353a8373dda8832ab8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 10:42:43 +0100 Subject: [PATCH 18/54] add support for `AppVeyor` CI for checking Windows builds --- CMakeLists.txt | 4 ++++ appveyor.yml | 28 ++++++++++++++++++++++++++++ readme.md | 4 ++++ test/unittest/documenttest.cpp | 2 +- test/unittest/valuetest.cpp | 2 -- 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 appveyor.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ed65c89..c96a5992 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,10 @@ if(RAPIDJSON_BUILD_EXAMPLES) endif() if(RAPIDJSON_BUILD_TESTS) + if(MSVC11) + # required for VS2012 due to missing support for variadic templates + add_definitions(-D_VARIADIC_MAX=10) + endif(MSVC11) add_subdirectory(test) include(CTest) endif() diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..76ca6ce5 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,28 @@ +version: 0.12.{build} + +configuration: +- Debug +- Release + +platform: +- x86 +- x64 + +environment: + matrix: + - VS_VERSION: 11 + - VS_VERSION: 12 + - VS_VERSION: 14 + +before_build: +- git submodule update --init --recursive +- if "%PLATFORM%" == "x86" set PLATFORM=win32 +- cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%PLATFORM% -DBUILD_SHARED_LIBS=true -Wno-dev + +build: + project: Build\VS\RapidJSON.sln + parallel: true + verbosity: minimal + +test_script: +- cd Build\VS && ctest --verbose --timeout 120 --build-config %CONFIGURATION% diff --git a/readme.md b/readme.md index 05c0ec3d..ee64108f 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,10 @@ Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) [RapidJSON Documentation](http://miloyip.github.io/rapidjson/) +## Build status +* Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/Kosta-Github/rapidjson)](https://travis-ci.org/Kosta-Github/rapidjson) +* AppVeyor (Windows): [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/3xw2isxomp5r4do7/branch/master?svg=true)](https://ci.appveyor.com/project/Kosta-Github/rapidjson/branch/master) + ## Introduction RapidJSON is a JSON parser and generator for C++. It was inspired by [RapidXml](http://rapidxml.sourceforge.net/). diff --git a/test/unittest/documenttest.cpp b/test/unittest/documenttest.cpp index f8be65ad..93f7a3dc 100644 --- a/test/unittest/documenttest.cpp +++ b/test/unittest/documenttest.cpp @@ -253,8 +253,8 @@ TEST(Document, Traits) { static_assert(!std::is_nothrow_constructible::value, ""); static_assert(!std::is_nothrow_default_constructible::value, ""); - static_assert(!std::is_nothrow_copy_constructible::value, ""); #ifndef _MSC_VER + static_assert(!std::is_nothrow_copy_constructible::value, ""); static_assert(std::is_nothrow_move_constructible::value, ""); #endif diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 8644e1f9..f09d4c12 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -54,9 +54,7 @@ TEST(Value, Traits) { #ifndef _MSC_VER static_assert(std::is_nothrow_constructible::value, ""); static_assert(std::is_nothrow_default_constructible::value, ""); -#endif static_assert(!std::is_nothrow_copy_constructible::value, ""); -#ifndef _MSC_VER static_assert(std::is_nothrow_move_constructible::value, ""); #endif From 0cbafabe53aa633a19cae02b912b193e6c8befe0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 11:14:47 +0100 Subject: [PATCH 19/54] omit `valgrind` tests for `Visual Studio` builds --- test/unittest/CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 41e56952..66cf0c6c 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -21,12 +21,15 @@ add_test(NAME unittest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) -add_test(NAME valgrind_unittest - COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) +if(NOT MSVC) + add_test(NAME valgrind_unittest + COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) -IF((NOT MSVC) AND (CMAKE_BUILD_TYPE STREQUAL "Debug")) -add_test(NAME symbol_check - COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -ENDIF() + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_test(NAME symbol_check + COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif(CMAKE_BUILD_TYPE STREQUAL "Debug") + +endif(NOT MSVC) From f7e3752f0d84563f849c8d2330c99f021f8c9473 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 11:24:21 +0100 Subject: [PATCH 20/54] try to fix platform builds for `win32` --- appveyor.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 76ca6ce5..7bac1dda 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,23 +1,23 @@ -version: 0.12.{build} +ersion: 0.12.{build} configuration: - Debug - Release -platform: -- x86 -- x64 - environment: matrix: - VS_VERSION: 11 + VS_PLATFORM: win32 + - VS_VERSION: 11 + VS_PLATFORM: x64 - VS_VERSION: 12 - - VS_VERSION: 14 - + VS_PLATFORM: win32 + - VS_VERSION: 12 + VS_PLATFORM: x64 + before_build: - git submodule update --init --recursive -- if "%PLATFORM%" == "x86" set PLATFORM=win32 -- cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%PLATFORM% -DBUILD_SHARED_LIBS=true -Wno-dev +- cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%VS_PLATFORM% -DBUILD_SHARED_LIBS=true -Wno-dev build: project: Build\VS\RapidJSON.sln From 1338985a161d70949f065692099ad2233f3bf837 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 11:26:33 +0100 Subject: [PATCH 21/54] removed `tab` from `appveyor.yml` file --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7bac1dda..893c8dfd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ environment: VS_PLATFORM: win32 - VS_VERSION: 12 VS_PLATFORM: x64 - + before_build: - git submodule update --init --recursive - cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%VS_PLATFORM% -DBUILD_SHARED_LIBS=true -Wno-dev From cb69b2a6af90396030af643063368e5b9c3ebcb8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 11:27:25 +0100 Subject: [PATCH 22/54] fixed spelling of `version` --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 893c8dfd..39a08e2f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -ersion: 0.12.{build} +version: 0.12.{build} configuration: - Debug From 119f1ddb04f52eda3dec94529ec598bdf63f9d4b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 11:36:46 +0100 Subject: [PATCH 23/54] [skip CI] fixed Travis CI badge to point to Milo's travis account --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index ee64108f..7f5a7e9e 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) [RapidJSON Documentation](http://miloyip.github.io/rapidjson/) ## Build status -* Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/Kosta-Github/rapidjson)](https://travis-ci.org/Kosta-Github/rapidjson) +* Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/miloyip/rapidjson)](https://travis-ci.org/miloyip/rapidjson) * AppVeyor (Windows): [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/3xw2isxomp5r4do7/branch/master?svg=true)](https://ci.appveyor.com/project/Kosta-Github/rapidjson/branch/master) ## Introduction From a843e639936489c544f45f7a9d55b022371d8d38 Mon Sep 17 00:00:00 2001 From: Kosta Date: Tue, 17 Feb 2015 11:39:30 +0100 Subject: [PATCH 24/54] fixed travis badge icon --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 7f5a7e9e..7def42ec 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) [RapidJSON Documentation](http://miloyip.github.io/rapidjson/) ## Build status -* Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/miloyip/rapidjson)](https://travis-ci.org/miloyip/rapidjson) +* Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/miloyip/rapidjson.png)](https://travis-ci.org/miloyip/rapidjson) * AppVeyor (Windows): [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/3xw2isxomp5r4do7/branch/master?svg=true)](https://ci.appveyor.com/project/Kosta-Github/rapidjson/branch/master) ## Introduction From 2c3b00341ab3249d6860f89a04f9f79dfbd5cd88 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 11:51:45 +0100 Subject: [PATCH 25/54] remove timeout parameter from `ctest` call (since AppVeyor HW seems to be very very slow...) --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 39a08e2f..4c3928ee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,4 +25,4 @@ build: verbosity: minimal test_script: -- cd Build\VS && ctest --verbose --timeout 120 --build-config %CONFIGURATION% +- cd Build\VS && ctest --verbose --build-config %CONFIGURATION% From c7672553decbc53f3616747802f5c89577e25ca3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 12:42:29 +0100 Subject: [PATCH 26/54] fix `doxygen` link --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 7def42ec..965f4368 100644 --- a/readme.md +++ b/readme.md @@ -47,7 +47,7 @@ RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder RapidJSON uses following software as its dependencies: * [CMake](http://www.cmake.org) as a general build tool -* (optional)[Doxygen](http://www.goxygen.org) to build documentation +* (optional)[Doxygen](http://www.doxygen.org) to build documentation * (optional)[googletest](https://code.google.com/p/googletest/) for unit and performance testing To generate user documentation and run tests please proceed with the steps below: From a3398a862b768801c2c9160a216373b14f17bff0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2015 13:58:31 +0100 Subject: [PATCH 27/54] removed tabs from cmake config file --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c96a5992..b30625fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,9 +54,9 @@ endif() if(RAPIDJSON_BUILD_TESTS) if(MSVC11) - # required for VS2012 due to missing support for variadic templates - add_definitions(-D_VARIADIC_MAX=10) - endif(MSVC11) + # required for VS2012 due to missing support for variadic templates + add_definitions(-D_VARIADIC_MAX=10) + endif(MSVC11) add_subdirectory(test) include(CTest) endif() From 80119a6a743943d6da38afbabbcbfdf54823034d Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Wed, 18 Feb 2015 14:11:10 +0800 Subject: [PATCH 28/54] Change AppVeyor badge --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 965f4368..9c866672 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) ## Build status * Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/miloyip/rapidjson.png)](https://travis-ci.org/miloyip/rapidjson) -* AppVeyor (Windows): [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/3xw2isxomp5r4do7/branch/master?svg=true)](https://ci.appveyor.com/project/Kosta-Github/rapidjson/branch/master) +* AppVeyor (Windows): [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master?svg=true)](https://ci.appveyor.com/project/miloyip/rapidjson/branch/master) ## Introduction From 9122a78a46fe2f08ff520d075806e918eda7cfa5 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Wed, 11 Feb 2015 12:50:36 +0200 Subject: [PATCH 29/54] Add new unittests. Refs #240. --- test/unittest/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 66cf0c6c..fb98d140 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -1,12 +1,15 @@ set(UNITTEST_SOURCES + bigintegertest.cpp documenttest.cpp encodedstreamtest.cpp encodingstest.cpp filestreamtest.cpp jsoncheckertest.cpp + namespacetest.cpp readertest.cpp + stringbuffertest.cpp + strtodtest.cpp unittest.cpp - unittest.h valuetest.cpp writertest.cpp) From 3ae2a29986c56cdb4dc50b1b903b72aeb433bb97 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Wed, 11 Feb 2015 14:10:09 +0200 Subject: [PATCH 30/54] Backport compiler options from premake configuration. Refs #240. --- CMakeLists.txt | 9 +++++++-- example/CMakeLists.txt | 8 ++++++++ test/unittest/CMakeLists.txt | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b30625fe..9ae444c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,13 @@ if(RAPIDJSON_HAS_STDSTRING) add_definitions(-DRAPIDJSON_HAS_STDSTRING) endif() +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions(_CRT_SECURE_NO_WARNINGS) +endif() #add extra search paths for libraries and includes SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") @@ -36,9 +43,7 @@ ELSEIF(WIN32) ENDIF() SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in") - include_directories(${CMAKE_SOURCE_DIR}/include) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}") if(RAPIDJSON_BUILD_DOC) add_subdirectory(doc) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index ae498345..2856e6be 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -14,6 +14,14 @@ set(EXAMPLES simplewriter tutorial) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + foreach (example ${EXAMPLES}) add_executable(${example} ${example}/${example}.cpp) endforeach() diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index fb98d140..3e9752d0 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -13,6 +13,14 @@ set(UNITTEST_SOURCES valuetest.cpp writertest.cpp) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + add_library(namespacetest STATIC namespacetest.cpp) add_executable(unittest ${UNITTEST_SOURCES}) From aa0fdd3b0dbe9929d186a7c5b562bb93d1630e84 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Wed, 11 Feb 2015 17:18:27 +0200 Subject: [PATCH 31/54] Cleaning up gitignore. Refs #240. --- .gitignore | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e4478e0f..95acb0cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,10 @@ !/bin/data !/bin/encodings !/bin/jsonchecker +/build /doc/html /doc/doxygen_*.db -/thirdparty/lib -/intermediate +*.a # Temporary files created during CMake build CMakeCache.txt @@ -20,4 +20,3 @@ Testing install_manifest.txt Doxyfile DartConfiguration.tcl -/build/* \ No newline at end of file From 553dc0a8b09e883e2fe6dd6faa2fa341e021f056 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Thu, 19 Feb 2015 18:09:14 +0200 Subject: [PATCH 32/54] Add a workaround for valgrind bug. Refs: #171, #240 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cbc5c0f6..aa65e163 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ before_install: install: true before_script: + - sed -i 's/march=native/msse4.2/' CMakeLists.txt - mkdir build - > (cd build && cmake From a7319330cb3e0eaa6c05d53ec10ed372cdbe05be Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 20 Feb 2015 08:15:20 +0100 Subject: [PATCH 33/54] error.h: drop trailing comma in enum In C++'98/03, trailing commas in enumerations are not allowed, but have been introduced in C++11. This patch drops the trailing commas in order to avoid compiler warnings (e.g. GCC with -pedantic). See #9 and http://code.google.com/p/rapidjson/issues/detail?id=49 for previous instances of this issue. --- include/rapidjson/error/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/error/error.h b/include/rapidjson/error/error.h index 161ef878..729142ab 100644 --- a/include/rapidjson/error/error.h +++ b/include/rapidjson/error/error.h @@ -85,7 +85,7 @@ enum ParseErrorCode { kParseErrorNumberMissExponent, //!< Miss exponent in number. kParseErrorTermination, //!< Parsing was terminated. - kParseErrorUnspecificSyntaxError, //!< Unspecific syntax error. + kParseErrorUnspecificSyntaxError //!< Unspecific syntax error. }; //! Result of parsing (wraps ParseErrorCode) From 3735542cc2dd7d76384e9f0476fd01b25b54fd2b Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 20 Feb 2015 19:38:52 +0100 Subject: [PATCH 34/54] readme.md: improve build status rendering by Doxygen Doxygen currently does not support images with links, which breaks the current rendering of the front page at https://miloyip.github.io/rapidjson. Move the status badges to a table with the links in the top-row instead. While at it, add a description below the logo and put the GitHub and documentation links into in itemisation. --- readme.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 9c866672..72abc8bc 100644 --- a/readme.md +++ b/readme.md @@ -1,14 +1,21 @@ ![](doc/logo/rapidjson.png) +## A fast JSON parser/generator for C++ with both SAX/DOM style API Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) -[RapidJSON GitHub](https://github.com/miloyip/rapidjson/) - -[RapidJSON Documentation](http://miloyip.github.io/rapidjson/) +* [RapidJSON GitHub](https://github.com/miloyip/rapidjson/) +* [RapidJSON Documentation](http://miloyip.github.io/rapidjson/) ## Build status -* Tavis CI (Linux): [![Travis Build status](https://travis-ci.org/miloyip/rapidjson.png)](https://travis-ci.org/miloyip/rapidjson) -* AppVeyor (Windows): [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master?svg=true)](https://ci.appveyor.com/project/miloyip/rapidjson/branch/master) + +| [Linux][lin-link] | [Windows][win-link] | +| :---------------: | :-----------------: | +| ![lin-badge] | ![win-badge] | + +[lin-badge]: https://travis-ci.org/miloyip/rapidjson.png "Travis build status" +[lin-link]: https://travis-ci.org/miloyip/rapidjson "Travis build status" +[win-badge]: https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master?svg=true "AppVeyor build status" +[win-link]: https://ci.appveyor.com/project/miloyip/rapidjson/branch/master "AppVeyor build status" ## Introduction From 8341c413ddda2c524e0dfca64a9289cbd4dad762 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 20 Feb 2015 20:29:31 +0100 Subject: [PATCH 35/54] unittest.h: make sure to #include See https://github.com/miloyip/rapidjson/commit/a2a0d161#commitcomment-9838110 --- test/unittest/unittest.h | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unittest/unittest.h b/test/unittest/unittest.h index 7dfcca21..800fbab5 100644 --- a/test/unittest/unittest.h +++ b/test/unittest/unittest.h @@ -41,6 +41,7 @@ #endif #include "gtest/gtest.h" +#include #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic pop From 122170b362e98aaec401764cd89000a628ff3d50 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Thu, 19 Feb 2015 22:41:31 +0200 Subject: [PATCH 36/54] Fix definitions for VS compiler --- CMakeLists.txt | 2 +- example/CMakeLists.txt | 2 +- test/unittest/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ae444c4..4cde7e2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_definitions(_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() #add extra search paths for libraries and includes diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2856e6be..64632127 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -19,7 +19,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_definitions(_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() foreach (example ${EXAMPLES}) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 3e9752d0..5e4a3e9d 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -18,7 +18,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_definitions(_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() add_library(namespacetest STATIC namespacetest.cpp) From 46554603fc9ae5f46c5d6b5c599ad4d2559bd7ab Mon Sep 17 00:00:00 2001 From: Christian Hitz Date: Tue, 24 Feb 2015 15:35:12 +0100 Subject: [PATCH 37/54] RapidJSON.pc.in: include dir not set Variable in wrong format is not replaced --- RapidJSON.pc.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RapidJSON.pc.in b/RapidJSON.pc.in index be4f7887..7467f977 100644 --- a/RapidJSON.pc.in +++ b/RapidJSON.pc.in @@ -1,4 +1,7 @@ +includedir=@INCLUDE_INSTALL_DIR@ + Name: @PROJECT_NAME@ -Description: RapidJSON is a JSON parser and generator for C++ inspired by RapidXml. +Description: A fast JSON parser/generator for C++ with both SAX/DOM style API Version: @LIB_VERSION_STRING@ +URL: https://github.com/miloyip/rapidjson Cflags: -I${includedir} From 06c3ddbac5fb1ff3d5ad993b3682951e2dac92f0 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 19:11:27 +0100 Subject: [PATCH 38/54] GenericValue::AddMember: add missing overload (closes #254) As discovered by @felipegb94, there are missing overloads to the `GenericValue::AddMember` template function, taking an explicit `GenericValue&` as a name and accepting arbitrary primitive values. This patch adds the missing overloads. The `StringRefType` overload is needed to disambiguate the addition of a string literal as value. Some tests are added to `TEST(Value, Object)` in `valuetest.cpp`. --- include/rapidjson/document.h | 41 ++++++++++++++++++++++++++++++++++-- test/unittest/valuetest.cpp | 13 ++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 7656f446..85e2567d 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -954,6 +954,44 @@ public: return *this; } + //! Add a constant string value as member (name-value pair) to the object. + /*! \param name A string value as name of member. + \param value constant string reference as value of member. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). + \return The value itself for fluent API. + \pre IsObject() + \note This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below. + \note Amortized Constant time complexity. + */ + GenericValue& AddMember(GenericValue& name, StringRefType value, Allocator& allocator) { + GenericValue v(value); + return AddMember(name, v, allocator); + } + + //! Add any primitive value as member (name-value pair) to the object. + /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t + \param name A string value as name of member. + \param value Value of primitive type \c T as value of member + \param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator(). + \return The value itself for fluent API. + \pre IsObject() + + \note The source type \c T explicitly disallows all pointer types, + especially (\c const) \ref Ch*. This helps avoiding implicitly + referencing character strings with insufficient lifetime, use + \ref AddMember(StringRefType, GenericValue&, Allocator&) or \ref + AddMember(StringRefType, StringRefType, Allocator&). + All other pointer types would implicitly convert to \c bool, + use an explicit cast instead, if needed. + \note Amortized Constant time complexity. + */ + template + RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (GenericValue&)) + AddMember(GenericValue& name, T value, Allocator& allocator) { + GenericValue v(value); + return AddMember(name, v, allocator); + } + #if RAPIDJSON_HAS_CXX11_RVALUE_REFS GenericValue& AddMember(GenericValue&& name, GenericValue&& value, Allocator& allocator) { return AddMember(name, value, allocator); @@ -1021,8 +1059,7 @@ public: RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (GenericValue&)) AddMember(StringRefType name, T value, Allocator& allocator) { GenericValue n(name); - GenericValue v(value); - return AddMember(n, v, allocator); + return AddMember(n, value, allocator); } //! Remove all members in the object. diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index f09d4c12..b2647c08 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -919,6 +919,19 @@ TEST(Value, Object) { EXPECT_EQ(8u, o.MemberCount()); } + // AddMember(Value&, T, Allocator) + { + Value o(kObjectType); + + Value n("s"); + o.AddMember(n, "string", allocator); + EXPECT_EQ(1u, o.MemberCount()); + + Value count("#"); + o.AddMember(count, o.MemberCount(), allocator); + EXPECT_EQ(2u, o.MemberCount()); + } + #if RAPIDJSON_HAS_CXX11_RVALUE_REFS // AddMember(GenericValue&&, ...) variants { From 242b393aae8bf74ca05acc8f7d94e0c53f9e71a3 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 20:25:04 +0100 Subject: [PATCH 39/54] .travis.yml: cleanup ARCH configuration --- .travis.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa65e163..fcba9dac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,13 @@ compiler: env: matrix: - - CONF=debug ARCH=x86_64 ARCH_FLAGS="" - - CONF=release ARCH=x86_64 ARCH_FLAGS="" - - CONF=debug ARCH=x86 ARCH_FLAGS="-m32" - - CONF=release ARCH=x86 ARCH_FLAGS="-m32" + - CONF=debug ARCH=x86_64 + - CONF=release ARCH=x86_64 + - CONF=debug ARCH=x86 + - CONF=release ARCH=x86 global: + - ARCH_FLAGS_x86='-m32' + - ARCH_FLAGS_x86_64='' - GITHUB_REPO='miloyip/rapidjson' - secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk=" @@ -24,6 +26,7 @@ before_script: - sed -i 's/march=native/msse4.2/' CMakeLists.txt - mkdir build - > + eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" (cd build && cmake -DRAPIDJSON_HAS_STDSTRING=ON -DCMAKE_VERBOSE_MAKEFILE=ON From 429b3dcfab258fd4c0b42f5ba3e97e228e5ef87e Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 20:26:26 +0100 Subject: [PATCH 40/54] .travis.yml: move comment of workaround for #163 --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fcba9dac..f0a62eb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,8 @@ before_install: install: true before_script: +# hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469), +# exposed by merging PR#163 (using -march=native) - sed -i 's/march=native/msse4.2/' CMakeLists.txt - mkdir build - > @@ -32,9 +34,6 @@ before_script: -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=$CONF -DCMAKE_C_FLAGS="$ARCH_FLAGS" ..) -# hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469), -# exposed by merging PR#163 (using -march=native) -# - (cd build/gmake && sed -i 's/march=native/msse4.2/' *.make) script: - cd build From c26a2a64af7d498dc811c8fee5689ebd84065053 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 20:26:52 +0100 Subject: [PATCH 41/54] .travis.yml: skip perftest on debug builds --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0a62eb5..f0e92338 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,5 +39,5 @@ script: - cd build - make tests - make examples - - ctest -V + - ctest -V `[ "$CONF" = "release" ] || echo "-E perftest"` - make travis_doc From 0ed4cdfa463ff8038fec76ec4cfeb7692119ca5f Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 20:32:39 +0100 Subject: [PATCH 42/54] appveyor.yml: skip perftest on debug builds --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4c3928ee..d1a91089 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,4 +25,4 @@ build: verbosity: minimal test_script: -- cd Build\VS && ctest --verbose --build-config %CONFIGURATION% +- cd Build\VS && if %CONFIGURATION%==Debug (ctest --verbose -E perftest --build-config %CONFIGURATION%) else (ctest --verbose --build-config %CONFIGURATION%) From aae07f62388093c606ca2e9c7c2aaffc5470ea55 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 20:48:39 +0100 Subject: [PATCH 43/54] .travis.yml: re-add missing "apt-get update" call (Accidentally dropped in 40c03114) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f0e92338..34591d59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ env: - secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk=" before_install: + - sudo apt-get update -qq - sudo apt-get install -qq cmake doxygen valgrind - if [ "$ARCH" = "x86" ]; then sudo apt-get install -qq g++-multilib libc6-dbg:i386; fi From 66a2ccdd1d0831ff4a0efb87f0394d146f336d0b Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 21:15:41 +0100 Subject: [PATCH 44/54] .travis.yml: add missing semicolon --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 34591d59..fc9d64a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_script: - sed -i 's/march=native/msse4.2/' CMakeLists.txt - mkdir build - > - eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" + eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" ; (cd build && cmake -DRAPIDJSON_HAS_STDSTRING=ON -DCMAKE_VERBOSE_MAKEFILE=ON From 2b5654692c10d6a895d1b350d91a5b75c0e9dd99 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 10 Mar 2015 21:53:46 +0100 Subject: [PATCH 45/54] .travis.yml: properly pass $ARCH_FLAGS RapidJSON is C++, need to set CMAKE_CXX_FLAGS instead of CMAKE_C_FLAGS when configuring the build environment. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fc9d64a1..54f9d909 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ before_script: -DRAPIDJSON_HAS_STDSTRING=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=$CONF - -DCMAKE_C_FLAGS="$ARCH_FLAGS" ..) + -DCMAKE_CXX_FLAGS="$ARCH_FLAGS" ..) script: - cd build From 978a3ab830b484244621c8f2c0fad6e81c52060a Mon Sep 17 00:00:00 2001 From: miloyip Date: Mon, 23 Mar 2015 17:30:25 +0800 Subject: [PATCH 46/54] Fix VS2012 compilation fail in stringbuffertest --- test/unittest/stringbuffertest.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unittest/stringbuffertest.cpp b/test/unittest/stringbuffertest.cpp index 24a29cbe..71e0caf9 100644 --- a/test/unittest/stringbuffertest.cpp +++ b/test/unittest/stringbuffertest.cpp @@ -83,8 +83,11 @@ TEST(StringBuffer, Traits) { static_assert(!std::is_nothrow_constructible::value, ""); static_assert(!std::is_nothrow_default_constructible::value, ""); + +#if !defined(_MSC_VER) || _MSC_VER >= 1800 static_assert(!std::is_nothrow_copy_constructible::value, ""); static_assert(!std::is_nothrow_move_constructible::value, ""); +#endif static_assert( std::is_assignable::value, ""); #ifndef _MSC_VER @@ -92,7 +95,10 @@ TEST(StringBuffer, Traits) { #endif static_assert( std::is_move_assignable::value, ""); - static_assert(!std::is_nothrow_assignable::value, ""); +#if !defined(_MSC_VER) || _MSC_VER >= 1800 + static_assert(!std::is_nothrow_assignable::value, ""); +#endif + static_assert(!std::is_nothrow_copy_assignable::value, ""); static_assert(!std::is_nothrow_move_assignable::value, ""); From 58cd253f8f16be917f383a0d8b6793b99d7c0f04 Mon Sep 17 00:00:00 2001 From: thebusytypist Date: Tue, 24 Mar 2015 13:50:02 +0800 Subject: [PATCH 47/54] Exclude intermediate files from install. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cde7e2a..9c823ac3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,12 @@ install(DIRECTORY include/rapidjson install(DIRECTORY example/ DESTINATION "${DOC_INSTALL_DIR}/examples" - COMPONENT examples) + COMPONENT examples + # Following patterns are for excluding the intermediate/object files + # from an install of in-source CMake build. + PATTERN "CMakeFiles" EXCLUDE + PATTERN "Makefile" EXCLUDE + PATTERN "cmake_install.cmake" EXCLUDE) # Provide config and version files to be used by other applications # =============================== From 92c7485be031afc7b201f515538ee45c1c8e6efa Mon Sep 17 00:00:00 2001 From: thebusytypist Date: Tue, 24 Mar 2015 17:03:24 +0800 Subject: [PATCH 48/54] Check libstdc++ version to decide if enable rvalue ref support. --- include/rapidjson/rapidjson.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index b13e0b0a..70ef3fe8 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -413,7 +413,8 @@ RAPIDJSON_NAMESPACE_END #ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS #if defined(__clang__) -#define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references) +#define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references) && \ + (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306) #elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ (defined(_MSC_VER) && _MSC_VER >= 1600) From 107aff0c2822c74893abe24d4dbc1c85b30129e4 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 24 Mar 2015 21:04:38 +0100 Subject: [PATCH 49/54] .travis.yml: disable SSE4.2 on 32-bit (closes #266) --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54f9d909..ac7240d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ env: - CONF=debug ARCH=x86 - CONF=release ARCH=x86 global: - - ARCH_FLAGS_x86='-m32' - - ARCH_FLAGS_x86_64='' + - ARCH_FLAGS_x86='-m32' # #266: don't use SSE on 32-bit + - ARCH_FLAGS_x86_64='-msse4.2' # use SSE4.2 on 64-bit - GITHUB_REPO='miloyip/rapidjson' - secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk=" @@ -26,7 +26,7 @@ install: true before_script: # hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469), # exposed by merging PR#163 (using -march=native) - - sed -i 's/march=native/msse4.2/' CMakeLists.txt + - sed -i "s/-march=native//" CMakeLists.txt - mkdir build - > eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" ; From 2f010e6e4b21d4b02912b1b993f33d3d227096c7 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Mon, 30 Mar 2015 22:37:24 +0200 Subject: [PATCH 50/54] document.h: include , iff RAPIDJSON_HAS_STDSTRING==1 Reported-by: Janusz Chorko (@yachoor) See: https://github.com/miloyip/rapidjson/commit/c1c9ba7c#commitcomment-10434694 --- include/rapidjson/document.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 85e2567d..b0c0cdca 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -55,6 +55,9 @@ RAPIDJSON_DIAG_OFF(effc++) \hideinitializer */ +#endif // !defined(RAPIDJSON_HAS_STDSTRING) + +#if RAPIDJSON_HAS_STDSTRING #include #endif // RAPIDJSON_HAS_STDSTRING From 953cda14f709b4915f8cbcae187841641abb4821 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 31 Mar 2015 20:55:00 +0200 Subject: [PATCH 51/54] tutorial.cpp: fix insitu parsing (closes #273) The insitu parsing example in the tutorial is using a local char buffer inside a nested scope. After leaving the scope, the resulting Document object still references this (now invalid) memory locations. Some compilers reuse this space on the stack for other local variables later in the function, corrupting the original document. Drop the local scope to extend the lifetime of the buffer. --- example/tutorial/tutorial.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/example/tutorial/tutorial.cpp b/example/tutorial/tutorial.cpp index 57f94a5b..49704c19 100644 --- a/example/tutorial/tutorial.cpp +++ b/example/tutorial/tutorial.cpp @@ -24,12 +24,10 @@ int main(int, char*[]) { return 1; #else // In-situ parsing, decode strings directly in the source string. Source must be string. - { - char buffer[sizeof(json)]; - memcpy(buffer, json, sizeof(json)); - if (document.ParseInsitu(buffer).HasParseError()) - return 1; - } + char buffer[sizeof(json)]; + memcpy(buffer, json, sizeof(json)); + if (document.ParseInsitu(buffer).HasParseError()) + return 1; #endif printf("\nParsing to document succeeded.\n"); From 3b8158086dc6a6c82ec3c7bdf97b9674a2d8557f Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 1 Apr 2015 22:39:01 +0200 Subject: [PATCH 52/54] messagereader.cpp: drop trailing comma --- example/messagereader/messagereader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/messagereader/messagereader.cpp b/example/messagereader/messagereader.cpp index 436af852..50255b37 100644 --- a/example/messagereader/messagereader.cpp +++ b/example/messagereader/messagereader.cpp @@ -54,7 +54,7 @@ struct MessageHandler enum State { kExpectObjectStart, kExpectNameOrObjectEnd, - kExpectValue, + kExpectValue }state_; std::string name_; }; From 525e8c5770c433c7ca989e12bdf338939b3ebb2b Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 1 Apr 2015 22:39:26 +0200 Subject: [PATCH 53/54] biginteger/diyfp: mark __int128 as extension on GCC --- include/rapidjson/internal/biginteger.h | 3 ++- include/rapidjson/internal/diyfp.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/internal/biginteger.h b/include/rapidjson/internal/biginteger.h index 3e97920d..5719a2ad 100755 --- a/include/rapidjson/internal/biginteger.h +++ b/include/rapidjson/internal/biginteger.h @@ -252,7 +252,8 @@ private: (*outHigh)++; return low; #elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__) - unsigned __int128 p = static_cast(a) * static_cast(b); + __extension__ typedef unsigned __int128 uint128; + uint128 p = static_cast(a) * static_cast(b); p += k; *outHigh = p >> 64; return static_cast(p); diff --git a/include/rapidjson/internal/diyfp.h b/include/rapidjson/internal/diyfp.h index 174b9fac..1b36f662 100644 --- a/include/rapidjson/internal/diyfp.h +++ b/include/rapidjson/internal/diyfp.h @@ -75,7 +75,8 @@ struct DiyFp { h++; return DiyFp(h, e + rhs.e + 64); #elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__) - unsigned __int128 p = static_cast(f) * static_cast(rhs.f); + __extension__ typedef unsigned __int128 uint128; + uint128 p = static_cast(f) * static_cast(rhs.f); uint64_t h = p >> 64; uint64_t l = static_cast(p); if (l & (uint64_t(1) << 63)) // rounding From cda34f0033391165190c75c72e88a0eeaf15c6b3 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 1 Apr 2015 22:39:42 +0200 Subject: [PATCH 54/54] encodings.h: hide overflow warning --- include/rapidjson/encodings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/rapidjson/encodings.h b/include/rapidjson/encodings.h index 6bc8aec5..24a24b60 100644 --- a/include/rapidjson/encodings.h +++ b/include/rapidjson/encodings.h @@ -30,6 +30,7 @@ RAPIDJSON_DIAG_OFF(4702) // unreachable code #elif defined(__GNUC__) RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(effc++) +RAPIDJSON_DIAG_OFF(overflow) #endif RAPIDJSON_NAMESPACE_BEGIN