Skip to content

Commit 12461e5

Browse files
authored
Create CONTRIBUTING.md
1 parent 518875d commit 12461e5

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

CONTRIBUTING.md

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Contributing to JsonCpp
2+
3+
## Building
4+
5+
Both CMake and Meson tools are capable of generating a variety of build environments for you preferred development environment.
6+
Using cmake or meson you can generate an XCode, Visual Studio, Unix Makefile, Ninja, or other environment that fits your needs.
7+
8+
An example of a common Meson/Ninja environment is described next.
9+
10+
## Building and testing with Meson/Ninja
11+
Thanks to David Seifert (@SoapGentoo), we (the maintainers) now use
12+
[meson](http://mesonbuild.com/) and [ninja](https://ninja-build.org/) to build
13+
for debugging, as well as for continuous integration (see
14+
[`./travis_scripts/meson_builder.sh`](./travis_scripts/meson_builder.sh) ). Other systems may work, but minor
15+
things like version strings might break.
16+
17+
First, install both meson (which requires Python3) and ninja.
18+
If you wish to install to a directory other than /usr/local, set an environment variable called DESTDIR with the desired path:
19+
DESTDIR=/path/to/install/dir
20+
21+
Then,
22+
23+
cd jsoncpp/
24+
BUILD_TYPE=debug
25+
#BUILD_TYPE=release
26+
LIB_TYPE=shared
27+
#LIB_TYPE=static
28+
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
29+
#ninja -v -C build-${LIB_TYPE} test # This stopped working on my Mac.
30+
ninja -v -C build-${LIB_TYPE}
31+
cd build-${LIB_TYPE}
32+
meson test --no-rebuild --print-errorlogs
33+
sudo ninja install
34+
35+
## Building and testing with other build systems
36+
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
37+
38+
## Running the tests manually
39+
40+
You need to run tests manually only if you are troubleshooting an issue.
41+
42+
In the instructions below, replace `path/to/jsontest` with the path of the
43+
`jsontest` executable that was compiled on your platform.
44+
45+
cd test
46+
# This will run the Reader/Writer tests
47+
python runjsontests.py path/to/jsontest
48+
49+
# This will run the Reader/Writer tests, using JSONChecker test suite
50+
# (http://www.json.org/JSON_checker/).
51+
# Notes: not all tests pass: JsonCpp is too lenient (for example,
52+
# it allows an integer to start with '0'). The goal is to improve
53+
# strict mode parsing to get all tests to pass.
54+
python runjsontests.py --with-json-checker path/to/jsontest
55+
56+
# This will run the unit tests (mostly Value)
57+
python rununittests.py path/to/test_lib_json
58+
59+
# You can run the tests using valgrind:
60+
python rununittests.py --valgrind path/to/test_lib_json
61+
62+
## Building the documentation
63+
64+
Run the Python script `doxybuild.py` from the top directory:
65+
66+
python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
67+
68+
See `doxybuild.py --help` for options.
69+
70+
## Adding a reader/writer test
71+
72+
To add a test, you need to create two files in test/data:
73+
74+
* a `TESTNAME.json` file, that contains the input document in JSON format.
75+
* a `TESTNAME.expected` file, that contains a flatened representation of the
76+
input document.
77+
78+
The `TESTNAME.expected` file format is as follows:
79+
80+
* Each line represents a JSON element of the element tree represented by the
81+
input document.
82+
* Each line has two parts: the path to access the element separated from the
83+
element value by `=`. Array and object values are always empty (i.e.
84+
represented by either `[]` or `{}`).
85+
* Element path `.` represents the root element, and is used to separate object
86+
members. `[N]` is used to specify the value of an array element at index `N`.
87+
88+
See the examples `test_complex_01.json` and `test_complex_01.expected` to better understand element paths.
89+
90+
## Understanding reader/writer test output
91+
92+
When a test is run, output files are generated beside the input test files. Below is a short description of the content of each file:
93+
94+
* `test_complex_01.json`: input JSON document.
95+
* `test_complex_01.expected`: flattened JSON element tree used to check if
96+
parsing was corrected.
97+
* `test_complex_01.actual`: flattened JSON element tree produced by `jsontest`
98+
from reading `test_complex_01.json`.
99+
* `test_complex_01.rewrite`: JSON document written by `jsontest` using the
100+
`Json::Value` parsed from `test_complex_01.json` and serialized using
101+
`Json::StyledWritter`.
102+
* `test_complex_01.actual-rewrite`: flattened JSON element tree produced by
103+
`jsontest` from reading `test_complex_01.rewrite`.
104+
* `test_complex_01.process-output`: `jsontest` output, typically useful for
105+
understanding parsing errors.
106+
107+
## Versioning rules
108+
109+
Consumers of this library require a strict approach to incrementing versioning of the JsonCpp library. Currently, we follow the below set of rules:
110+
111+
* Any new public symbols require a minor version bump.
112+
* Any alteration or removal of public symbols requires a major version bump, including changing the size of a class. This is necessary for
113+
consumers to do dependency injection properly.

0 commit comments

Comments
 (0)