Skip to content

Commit 2179730

Browse files
authored
docs: update amalgamation instructions and add github action (#1677)
The amalgamation approach is not outdated and works perfectly out-of-the-box. This updates the README to remove the 'possibly-outdated' warning and replaces it with direct, simple instructions for generating the amalgamated source files. A new GitHub Action workflow (`.github/workflows/amalgamate.yml`) has also been added to ensure the `amalgamate.py` script is run on every commit and that the resulting amalgamated C++ source files successfully compile, preventing any future regressions in the single-header distribution method.
1 parent 36f94b6 commit 2179730

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

.github/workflows/amalgamate.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Amalgamation
2+
3+
on: [check_run, push, pull_request]
4+
5+
env:
6+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
7+
8+
jobs:
9+
amalgamation:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: checkout project
14+
uses: actions/checkout@v4
15+
16+
- name: setup python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.x'
20+
21+
- name: run amalgamate script
22+
run: |
23+
python amalgamate.py
24+
25+
- name: test compile amalgamated source
26+
run: |
27+
cat << 'EOF' > test_amalgamation.cpp
28+
#include "json/json.h"
29+
#include <iostream>
30+
31+
int main() {
32+
Json::Value root;
33+
root["hello"] = "world";
34+
std::cout << root.toStyledString() << std::endl;
35+
return 0;
36+
}
37+
EOF
38+
c++ -std=c++11 -I dist dist/jsoncpp.cpp test_amalgamation.cpp -o test_amalgamation
39+
./test_amalgamation

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,15 @@ meson wrap install jsoncpp
8888

8989
### Amalgamated source
9090

91-
> [!NOTE]
92-
> This approach may be outdated.
91+
For projects requiring a single-header approach, JsonCpp provides a script to generate an amalgamated source and header file.
92+
93+
You can generate the amalgamated files by running the following Python script from the top-level directory:
94+
95+
```sh
96+
python3 amalgamate.py
97+
```
9398

94-
For projects requiring a single-header approach, see the [Wiki entry](https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated-(Possibly-outdated)).
99+
This will generate a `dist` directory containing `jsoncpp.cpp`, `json/json.h`, and `json/json-forwards.h`. You can then drop these files directly into your project's source tree and compile `jsoncpp.cpp` alongside your other source files.
95100

96101
## Documentation
97102

0 commit comments

Comments
 (0)