Skip to content

Commit bb61b6f

Browse files
committed
Merge pull request #1 from open-source-parsers/master
Updating the JsonCpp
2 parents 24682e3 + 9dad198 commit bb61b6f

25 files changed

+301
-203
lines changed

.travis.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,42 @@
22
# http://about.travis-ci.org/docs/user/build-configuration/
33
# This file can be validated on:
44
# http://lint.travis-ci.org/
5-
before_install: sudo apt-get install cmake
5+
# See also
6+
# http://stackoverflow.com/questions/22111549/travis-ci-with-clang-3-4-and-c11/30925448#30925448
7+
# to allow C++11, though we are not yet building with -std=c++11
8+
9+
install:
10+
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
11+
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
12+
# /usr/bin/clang is our version already, and clang-X.Y does not exist.
13+
#- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
14+
- echo ${PATH}
15+
- ls /usr/local
16+
- ls /usr/local/bin
17+
- export PATH=/usr/local/bin:/usr/bin:${PATH}
18+
- echo ${CXX}
19+
- ${CXX} --version
20+
- which valgrind
21+
addons:
22+
apt:
23+
sources:
24+
- ubuntu-toolchain-r-test
25+
packages:
26+
- gcc-4.9
27+
- g++-4.9
28+
- clang
29+
- valgrind
30+
os:
31+
- linux
632
language: cpp
733
compiler:
834
- gcc
935
- clang
10-
script: cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DJSONCPP_LIB_BUILD_SHARED=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE . && make && make jsoncpp_check
36+
script: ./travis.sh
1137
env:
1238
matrix:
1339
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
1440
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
1541
notifications:
16-
email:
17-
42+
email: false
43+
sudo: false

CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post
99
OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
1010
OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
1111
OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
12+
OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
13+
OPTION(BUILD_STATIC_LIBS "Build jsoncpp_lib static library." ON)
1214

1315
# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
1416
IF(NOT WIN32)
@@ -19,15 +21,16 @@ IF(NOT WIN32)
1921
ENDIF(NOT CMAKE_BUILD_TYPE)
2022
ENDIF(NOT WIN32)
2123

24+
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
2225
SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory")
2326

2427
SET(RUNTIME_INSTALL_DIR bin
2528
CACHE PATH "Install dir for executables and dlls")
26-
SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX}
29+
SET(ARCHIVE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
2730
CACHE PATH "Install dir for static libraries")
28-
SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX}
31+
SET(LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
2932
CACHE PATH "Install dir for shared libraries")
30-
SET(INCLUDE_INSTALL_DIR include
33+
SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include
3134
CACHE PATH "Install dir for headers")
3235
SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
3336
CACHE PATH "Install dir for cmake package config files")
@@ -60,7 +63,7 @@ ENDMACRO(jsoncpp_parse_version)
6063
#SET( JSONCPP_VERSION_MAJOR X )
6164
#SET( JSONCPP_VERSION_MINOR Y )
6265
#SET( JSONCPP_VERSION_PATCH Z )
63-
SET( JSONCPP_VERSION 1.6.2 )
66+
SET( JSONCPP_VERSION 1.6.5 )
6467
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
6568
#IF(NOT JSONCPP_VERSION_FOUND)
6669
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
@@ -94,10 +97,11 @@ endif( MSVC )
9497

9598
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9699
# using regular Clang or AppleClang
97-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
100+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wconversion -Wshadow -Wno-sign-conversion")
98101
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
99102
# using GCC
100-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -pedantic")
103+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wconversion -Wshadow -Wextra -pedantic")
104+
# not yet ready for -Wsign-conversion
101105
endif()
102106

103107
IF(JSONCPP_WITH_WARNING_AS_ERROR)

README.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ format to store user input files.
1919
* `0.y.z` can be used with older compilers.
2020
* Major versions maintain binary-compatibility.
2121

22-
Using JsonCpp in your project
22+
# Using JsonCpp in your project
2323
-----------------------------
24-
The recommended approach to integrating JsonCpp in your project is to build
25-
the amalgamated source (a single `.cpp` file) with your own build system. This
26-
ensures consistency of compilation flags and ABI compatibility. See the section
27-
"Generating amalgamated source and header" for instructions.
24+
The recommended approach to integrating JsonCpp in your project is to include
25+
the [amalgamated source](#generating-amalgamated-source-and-header) (a single
26+
`.cpp` file and two `.h` files) in your project, and compile and build as you
27+
would any other source file. This ensures consistency of compilation flags and
28+
ABI compatibility, issues which arise when building shared or static
29+
libraries. See the next section for instructions.
2830

2931
The `include/` should be added to your compiler include path. Jsoncpp headers
3032
should be included as follow:
@@ -34,6 +36,31 @@ should be included as follow:
3436
If JsonCpp was built as a dynamic library on Windows, then your project needs to
3537
define the macro `JSON_DLL`.
3638

39+
Generating amalgamated source and header
40+
----------------------------------------
41+
JsonCpp is provided with a script to generate a single header and a single
42+
source file to ease inclusion into an existing project. The amalgamated source
43+
can be generated at any time by running the following command from the
44+
top-directory (this requires Python 2.6):
45+
46+
python amalgamate.py
47+
48+
It is possible to specify header name. See the `-h` option for detail.
49+
50+
By default, the following files are generated:
51+
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
52+
* `dist/json/json.h`: corresponding header file for use in your project. It is
53+
equivalent to including `json/json.h` in non-amalgamated source. This header
54+
only depends on standard headers.
55+
* `dist/json/json-forwards.h`: header that provides forward declaration of all
56+
JsonCpp types.
57+
58+
The amalgamated sources are generated by concatenating JsonCpp source in the
59+
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
60+
of other headers.
61+
62+
# Contributing to JsonCpp
63+
3764
Building and testing with CMake
3865
-------------------------------
3966
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most
@@ -58,7 +85,7 @@ Steps for generating solution/makefiles using `cmake-gui`:
5885
* Make "source code" point to the source directory.
5986
* Make "where to build the binary" point to the directory to use for the build.
6087
* Click on the "Grouped" check box.
61-
* Review JsonCpp build options (tick `JSONCPP_LIB_BUILD_SHARED` to build as a
88+
* Review JsonCpp build options (tick `BUILD_SHARED_LIBS` to build as a
6289
dynamic library).
6390
* Click the configure button at the bottom, then the generate button.
6491
* The generated solution/makefiles can be found in the binary directory.
@@ -67,10 +94,10 @@ Alternatively, from the command-line on Unix in the source directory:
6794

6895
mkdir -p build/debug
6996
cd build/debug
70-
cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../..
97+
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
7198
make
7299

73-
Running `cmake -`" will display the list of available generators (passed using
100+
Running `cmake -h` will display the list of available generators (passed using
74101
the `-G` option).
75102

76103
By default CMake hides compilation commands. This can be modified by specifying
@@ -106,7 +133,7 @@ If you are building with Microsoft Visual Studio 2008, you need to set up the
106133
environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before
107134
running SCons.
108135

109-
# Running the tests manually
136+
## Running the tests manually
110137
You need to run tests manually only if you are troubleshooting an issue.
111138

112139
In the instructions below, replace `path/to/jsontest` with the path of the
@@ -142,29 +169,6 @@ Run the Python script `doxybuild.py` from the top directory:
142169

143170
See `doxybuild.py --help` for options.
144171

145-
Generating amalgamated source and header
146-
----------------------------------------
147-
JsonCpp is provided with a script to generate a single header and a single
148-
source file to ease inclusion into an existing project. The amalgamated source
149-
can be generated at any time by running the following command from the
150-
top-directory (this requires Python 2.6):
151-
152-
python amalgamate.py
153-
154-
It is possible to specify header name. See the `-h` option for detail.
155-
156-
By default, the following files are generated:
157-
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
158-
* `dist/json/json.h`: corresponding header file for use in your project. It is
159-
equivalent to including `json/json.h` in non-amalgamated source. This header
160-
only depends on standard headers.
161-
* `dist/json/json-forwards.h`: header that provides forward declaration of all
162-
JsonCpp types.
163-
164-
The amalgamated sources are generated by concatenating JsonCpp source in the
165-
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
166-
of other headers.
167-
168172
Adding a reader/writer test
169173
---------------------------
170174
To add a test, you need to create two files in test/data:

appveyor.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This is a comment.
2+
3+
version: build.{build}
4+
5+
os: Windows Server 2012 R2
6+
7+
clone_folder: c:\projects\jsoncpp
8+
9+
platform:
10+
- Win32
11+
- x64
12+
13+
configuration:
14+
- Debug
15+
- Release
16+
17+
# scripts to run before build
18+
before_build:
19+
- echo "Running cmake..."
20+
- cd c:\projects\jsoncpp
21+
- cmake --version
22+
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
23+
- if %PLATFORM% == Win32 cmake .
24+
- if %PLATFORM% == x64 cmake -G "Visual Studio 12 2013 Win64" .
25+
26+
build:
27+
project: jsoncpp.sln # path to Visual Studio solution or project
28+
29+
deploy:
30+
provider: GitHub
31+
auth_token:
32+
secure: K2Tp1q8pIZ7rs0Ot24ZMWuwr12Ev6Tc6QkhMjGQxoQG3ng1pXtgPasiJ45IDXGdg
33+
on:
34+
branch: master
35+
appveyor_repo_tag: true

dev.makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dox:
1616
# Then 'git add -A' and 'git push' in jsoncpp-docs.
1717
build:
1818
mkdir -p build/debug
19-
cd build/debug; cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=ON -G "Unix Makefiles" ../..
19+
cd build/debug; cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_SHARED_LIBS=ON -G "Unix Makefiles" ../..
2020
make -C build/debug
2121

2222
# Currently, this depends on include/json/version.h generated
@@ -26,6 +26,9 @@ test-amalgamate:
2626
python3.4 amalgamate.py
2727
cd dist; gcc -I. -c jsoncpp.cpp
2828

29+
valgrind:
30+
valgrind --error-exitcode=42 --leak-check=full ./build/debug/src/test_lib_json/jsoncpp_test
31+
2932
clean:
3033
\rm -rf *.gz *.asc dist/
3134

devtools/agent_vmw7.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
},
2020
{"name": "shared_dll",
2121
"variables": [
22-
["JSONCPP_LIB_BUILD_SHARED=true"],
23-
["JSONCPP_LIB_BUILD_SHARED=false"]
22+
["BUILD_SHARED_LIBS=true"],
23+
["BUILD_SHARED_LIBS=false"]
2424
]
2525
},
2626
{"name": "build_type",

devtools/agent_vmxp.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
},
1313
{"name": "shared_dll",
1414
"variables": [
15-
["JSONCPP_LIB_BUILD_SHARED=true"],
16-
["JSONCPP_LIB_BUILD_SHARED=false"]
15+
["BUILD_SHARED_LIBS=true"],
16+
["BUILD_SHARED_LIBS=false"]
1717
]
1818
},
1919
{"name": "build_type",

devtools/fixeol.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import print_function
77
import os.path
8+
import sys
89

910
def fix_source_eol(path, is_dry_run = True, verbose = True, eol = '\n'):
1011
"""Makes sure that all sources have the specified eol sequence (default: unix)."""

doxybuild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def run_cmd(cmd, silent=False):
7272
if silent:
7373
status, output = getstatusoutput(cmd)
7474
else:
75-
status, output = os.system(' '.join(cmd)), ''
75+
status, output = subprocess.call(cmd), ''
7676
if status:
7777
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
7878
raise Exception(msg)

include/json/reader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
346346
/** Called by ctor, but you can use this to reset settings_.
347347
* \pre 'settings' != NULL (but Json::null is fine)
348348
* \remark Defaults:
349-
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
349+
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
350350
*/
351351
static void setDefaults(Json::Value* settings);
352352
/** Same as old Features::strictMode().
353353
* \pre 'settings' != NULL (but Json::null is fine)
354354
* \remark Defaults:
355-
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
355+
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
356356
*/
357357
static void strictMode(Json::Value* settings);
358358
};

0 commit comments

Comments
 (0)