• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..07-May-2022-

examples/H07-May-2022-3,5373,303

.gitignoreH A D14-May-202183 107

README.mdH A D14-May-20212 KiB3423

build_decoder_test.shH A D14-May-20212 KiB9261

build_library_test.shH A D14-May-20212.2 KiB9863

combine.shH A D14-May-20216.2 KiB212153

create_single_file_decoder.shH A D14-May-2021325 158

create_single_file_library.shH A D14-May-2021313 158

zstd-in.cH A D14-May-20212.5 KiB8546

zstddeclib-in.cH A D14-May-20211.7 KiB5722

README.md

1# Single File Zstandard Libraries
2
3The script `combine.sh` creates an _amalgamated_ source file that can be used with or without `zstd.h`. This isn't a _header-only_ file but it does offer a similar level of simplicity when integrating into a project.
4
5All it now takes to support Zstd in your own projects is the addition of a single file, two if using the header, with no configuration or further build steps.
6
7Decompressor
8------------
9
10This is the most common use case. The decompression library is small, adding, for example, 26kB to an Emscripten compiled WebAssembly project. Native implementations add a little more, 40-70kB depending on the compiler and platform.
11
12Create `zstddeclib.c` from the Zstd source using:
13```
14cd zstd/build/single_file_libs
15./combine.sh -r ../../lib -o zstddeclib.c zstddeclib-in.c
16```
17Then add the resulting file to your project (see the [example files](examples)).
18
19`create_single_file_decoder.sh` will run the above script, creating the file `zstddeclib.c` (`build_decoder_test.sh` will also create `zstddeclib.c`, then compile and test the result).
20
21Full Library
22------------
23
24The same tool can amalgamate the entire Zstd library for ease of adding both compression and decompression to a project. The [roundtrip example](examples/roundtrip.c) uses the original `zstd.h` with the remaining source files combined into `zstd.c` (currently just over 1.2MB) created from `zstd-in.c`. As with the standalone decoder the most useful compile flags have already been rolled-in and the resulting file can be added to a project as-is.
25
26Create `zstd.c` from the Zstd source using:
27```
28cd zstd/build/single_file_libs
29./combine.sh -r ../../lib -o zstd.c zstd-in.c
30```
31It's possible to create a compressor-only library but since the decompressor is so small in comparison this doesn't bring much of a gain (but for the curious, simply remove the files in the _decompress_ section at the end of `zstd-in.c`).
32
33`create_single_file_library.sh` will run the script to create `zstd.c` (`build_library_test.sh` will also create `zstd.c`, then compile and test the result).
34