mirror of https://git.wownero.com/dsc/mxe.git
add zstd library
This commit is contained in:
parent
994ad47302
commit
e31f2f6ff6
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This file is part of MXE. See LICENSE.md for licensing information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zstd.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const char *data;
|
||||||
|
int data_len;
|
||||||
|
char compressed[100];
|
||||||
|
int compressed_size;
|
||||||
|
char decompressed[100];
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
|
||||||
|
data = "Some data to compress";
|
||||||
|
data_len = strlen(data);
|
||||||
|
|
||||||
|
/* compress */
|
||||||
|
compressed_size = ZSTD_compress(compressed, sizeof(compressed), data, data_len, 1);
|
||||||
|
if (compressed_size <= 0) {
|
||||||
|
printf("Error compressing the data\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZSTD_decompress(decompressed, data_len, compressed, compressed_size);
|
||||||
|
if (strcmp(data, decompressed) != 0) {
|
||||||
|
printf("Error: the compression was not lossless. Original='%s' Result='%s'\n", data, decompressed);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Successfully compressed and decompressed!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
# This file is part of MXE. See LICENSE.md for licensing information.
|
||||||
|
|
||||||
|
PKG := zstd
|
||||||
|
$(PKG)_WEBSITE := https://github.com/facebook/zstd
|
||||||
|
$(PKG)_DESCR := Zstandard is a fast lossless compression algorithm
|
||||||
|
$(PKG)_IGNORE :=
|
||||||
|
$(PKG)_VERSION := 1.3.2
|
||||||
|
$(PKG)_CHECKSUM := ac5054a3c64e6510bc1ae890d05e3d271cc33ceebc9d06ac9f08105766d2798a
|
||||||
|
$(PKG)_GH_CONF := facebook/zstd,v
|
||||||
|
$(PKG)_DEPS := gcc
|
||||||
|
|
||||||
|
define $(PKG)_BUILD
|
||||||
|
# build and install the library
|
||||||
|
cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)/build/cmake' \
|
||||||
|
-DZSTD_BUILD_STATIC=$(CMAKE_STATIC_BOOL) \
|
||||||
|
-DZSTD_BUILD_SHARED=$(CMAKE_SHARED_BOOL) \
|
||||||
|
-DZSTD_BUILD_PROGRAMS=OFF
|
||||||
|
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
|
||||||
|
$(MAKE) -C '$(BUILD_DIR)' -j 1 install
|
||||||
|
|
||||||
|
# create pkg-config files
|
||||||
|
$(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
|
||||||
|
(echo 'Name: $(PKG)'; \
|
||||||
|
echo 'Version: $($(PKG)_VERSION)'; \
|
||||||
|
echo 'Description: $($(PKG)_DESCR)'; \
|
||||||
|
echo 'Libs: -L$(PREFIX)/$(TARGET)/lib -l$(PKG)'; \
|
||||||
|
echo 'Cflags: -I$(PREFIX)/$(TARGET)/include';) \
|
||||||
|
> '$(PREFIX)/$(TARGET)/lib/pkgconfig/$(PKG).pc'
|
||||||
|
|
||||||
|
# compile test
|
||||||
|
'$(TARGET)-gcc' \
|
||||||
|
-W -Wall -Werror -ansi -pedantic \
|
||||||
|
'$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
|
||||||
|
`'$(TARGET)-pkg-config' $(PKG) --cflags --libs`
|
||||||
|
endef
|
Loading…
Reference in New Issue