boost, zstd, lz4 (#37)

Co-authored-by: Max Howell <mxcl@me.com>
This commit is contained in:
Pedro Cruz 2022-12-20 10:31:41 -04:00 committed by GitHub
parent 454fc591cf
commit 69ef92a7aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 136 additions and 0 deletions

View file

@ -0,0 +1,25 @@
distributable:
url: https://boostorg.jfrog.io/artifactory/main/release/{{ version }}/source/boost_{{version.major}}_{{version.minor}}_{{version.patch}}.tar.gz
strip-components: 1
versions:
github: boostorg/boost
strip: /^boost-/
dependencies:
facebook.com/zstd: ^1
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
./bootstrap.sh --prefix={{ prefix }}
./b2 install --prefix={{ prefix }}
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
c++ test.cpp -std=c++14 -lboost_iostreams -lzstd
./a.out

View file

@ -0,0 +1,39 @@
#include <boost/algorithm/string.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/zstd.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/stream.hpp>
#include <string>
#include <iostream>
#include <vector>
#include <assert.h>
using namespace boost::algorithm;
using namespace boost::iostreams;
using namespace std;
int main() {
string str("a,b");
vector<string> strVec;
split(strVec, str, is_any_of(","));
assert(strVec.size()==2);
assert(strVec[0]=="a");
assert(strVec[1]=="b");
// Test boost::iostreams::zstd_compressor() linking
std::vector<char> v;
back_insert_device<std::vector<char>> snk{v};
filtering_ostream os;
os.push(zstd_compressor());
os.push(snk);
os << "Boost" << std::flush;
os.pop();
array_source src{v.data(), v.size()};
filtering_istream is;
is.push(zstd_decompressor());
is.push(src);
std::string s;
is >> s;
assert(s == "Boost");
return 0;
}

View file

@ -0,0 +1,48 @@
distributable:
url: https://github.com/facebook/zstd/archive/v{{version}}.tar.gz
strip-components: 1
versions:
github: facebook/zstd/releases/tags
dependencies:
lz4.org: ^1
tukaani.org/xz: ^5
zlib.net: ^1
provides:
- bin/pzstd
- bin/unzstd
- bin/zstd
- bin/zstdcat
- bin/zstdgrep
- bin/zstdless
- bin/zstdmt
build:
dependencies:
tea.xyz/gx/cc: c99
cmake.org: ^3
ninja-build.org: ^1
working-directory: build/out
script: |
cmake ../cmake $ARGS
cmake --build .
cmake --install .
env:
ARGS:
- -GNinja
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX="{{prefix}}"
- -DZSTD_PROGRAMS_LINK_SHARED=ON # link `zstd` to `libzstd`
- -DZSTD_BUILD_CONTRIB=ON
- -DZSTD_LEGACY_SUPPORT=ON
- -DZSTD_ZLIB_SUPPORT=ON
- -DZSTD_LZMA_SUPPORT=ON
- -DZSTD_LZ4_SUPPORT=ON
test: |
export fixture="asdf123%!*"
for x in zstd pzstd xz lz4 gzip; do
test $(echo "$fixture" | $x | zstd -d) = "$fixture"
done

View file

@ -0,0 +1,24 @@
distributable:
url: https://github.com/lz4/lz4/archive/v{{version}}.tar.gz
strip-components: 1
versions:
github: lz4/lz4
strip: /^LZ4 /
provides:
- bin/lz4
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script:
make --jobs {{hw.concurrency}} install PREFIX="{{prefix}}"
test:
fixture:
testing compression and decompression
script: |
cat $FIXTURE | lz4 | lz4 -d > out
test "$(cat $FIXTURE)" = "$(cat out)"