Skip to content

Commit 44f8eeb

Browse files
committed
amalgated build option for easier embedding elsewhere.
1 parent 5402e12 commit 44f8eeb

7 files changed

Lines changed: 60390 additions & 2 deletions

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ OUTPUT := tivars_tests tivars_cli
1414

1515
all: $(OUTPUT)
1616

17+
amalgamated:
18+
python3 scripts/amalgamate.py
19+
1720
%.o: %.cpp
1821
$(CXX) $(CXXFLAGS) -c $< -o $@
1922

@@ -29,4 +32,4 @@ tivars_cli: $(OBJS_CLI)
2932
clean:
3033
$(RM) -f $(OBJS_TESTS) $(OBJS_CLI) $(OUTPUT)
3134

32-
.PHONY: all clean
35+
.PHONY: all amalgamated clean

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ Several optional parameters for the functions are available. For instance, Frenc
2727

2828
_Note: The code throws exceptions for you to catch in case of trouble._
2929

30+
#### Embedding in another C++ app
31+
32+
For apps that want to vendor the library without Git submodules or a CMake integration, generate the amalgamated distribution files:
33+
34+
```sh
35+
make amalgamated
36+
```
37+
38+
This writes:
39+
40+
- `dist/tivars_lib_cpp.hpp`
41+
- `dist/tivars_lib_cpp.cpp`
42+
43+
Copy those two files into the host project and compile the `.cpp` once alongside the app:
44+
45+
```sh
46+
c++ -std=c++20 -Ipath/to/tivars-dist \
47+
path/to/tivars-dist/tivars_lib_cpp.cpp \
48+
app.cpp \
49+
-o app
50+
```
51+
52+
The generated `.cpp` contains the vendored JSON/pugixml code and token tables, so no other files from this repo are needed.
53+
3054
Graph DataBase (`.8xd`) readable JSON conversion is enabled automatically when the compiler/library support the required C++ features. If the host app does not need it, compile with `-DTH_GDB_SUPPORT=0` to force that implementation off:
3155

3256
```sh

0 commit comments

Comments
 (0)