README.md
1
2# amalgamate.py - Amalgamate C source and header files
3
4Origin: https://bitbucket.org/erikedlund/amalgamate
5
6Mirror: https://github.com/edlund/amalgamate
7
8`amalgamate.py` aims to make it easy to use SQLite-style C source and header
9amalgamation in projects.
10
11For more information, please refer to: http://sqlite.org/amalgamation.html
12
13## Here be dragons
14
15`amalgamate.py` is quite dumb, it only knows the bare minimum about C code
16required in order to be able to handle trivial include directives. It can
17produce weird results for unexpected code.
18
19Things to be aware of:
20
21`amalgamate.py` will not handle complex include directives correctly:
22
23 #define HEADER_PATH "path/to/header.h"
24 #include HEADER_PATH
25
26In the above example, `path/to/header.h` will not be included in the
27amalgamation (HEADER_PATH is never expanded).
28
29`amalgamate.py` makes the assumption that each source and header file which
30is not empty will end in a new-line character, which is not immediately
31preceded by a backslash character (see 5.1.1.2p1.2 of ISO C99).
32
33`amalgamate.py` should be usable with C++ code, but raw string literals from
34C++11 will definitely cause problems:
35
36 R"delimiter(Terrible raw \ data " #include <sneaky.hpp>)delimiter"
37 R"delimiter(Terrible raw \ data " escaping)delimiter"
38
39In the examples above, `amalgamate.py` will stop parsing the raw string literal
40when it encounters the first quotation mark, which will produce unexpected
41results.
42
43## Installing amalgamate.py
44
45Python v.2.7.0 or higher is required.
46
47`amalgamate.py` can be tested and installed using the following commands:
48
49 ./test.sh && sudo -k cp ./amalgamate.py /usr/local/bin/
50
51## Using amalgamate.py
52
53 amalgamate.py [-v] -c path/to/config.json -s path/to/source/dir \
54 [-p path/to/prologue.(c|h)]
55
56 * The `-c, --config` option should specify the path to a JSON config file which
57 lists the source files, include paths and where to write the resulting
58 amalgamation. Have a look at `test/source.c.json` and `test/include.h.json`
59 to see two examples.
60
61 * The `-s, --source` option should specify the path to the source directory.
62 This is useful for supporting separate source and build directories.
63
64 * The `-p, --prologue` option should specify the path to a file which will be
65 added to the beginning of the amalgamation. It is optional.
66
67