diff options
author | alk3pInjection <webmaster@raspii.tech> | 2021-08-30 16:43:38 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2021-08-30 16:43:38 +0800 |
commit | cbe033a53bfe49d980774e59025e3b2af91778b7 (patch) | |
tree | 558535f91276162e0be70d07b34ed2e6577e38ad /contrib | |
parent | fdd43c66dd9e77283aa8f7e52a881be44d622441 (diff) | |
parent | d44371841a2f1728a3f36839fd4b7e872d0927d3 (diff) |
Merge tag 'v1.9.3' into lineage-18.1HEADlineage-18.1
Change-Id: Iad56c1b17a32f9f356a4c1ff9557f0e79addf481
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/cmake_unofficial/.gitignore | 9 | ||||
-rw-r--r-- | contrib/cmake_unofficial/CMakeLists.txt | 227 | ||||
-rw-r--r-- | contrib/debian/copyright | 4 | ||||
-rwxr-xr-x | contrib/debian/rules | 3 | ||||
-rw-r--r-- | contrib/gen_manual/gen_manual.cpp | 35 | ||||
-rw-r--r-- | contrib/meson/README.md | 34 | ||||
-rw-r--r-- | contrib/meson/meson.build | 21 | ||||
-rw-r--r-- | contrib/meson/meson/GetLz4LibraryVersion.py | 39 | ||||
-rw-r--r-- | contrib/meson/meson/InstallSymlink.py | 55 | ||||
-rw-r--r-- | contrib/meson/meson/contrib/gen_manual/meson.build | 43 | ||||
-rw-r--r-- | contrib/meson/meson/contrib/meson.build | 10 | ||||
-rw-r--r-- | contrib/meson/meson/examples/meson.build | 49 | ||||
-rw-r--r-- | contrib/meson/meson/lib/meson.build | 57 | ||||
-rw-r--r-- | contrib/meson/meson/meson.build | 117 | ||||
-rw-r--r-- | contrib/meson/meson/programs/meson.build | 52 | ||||
-rw-r--r-- | contrib/meson/meson/tests/meson.build | 93 | ||||
-rw-r--r-- | contrib/meson/meson_options.txt | 24 | ||||
-rw-r--r-- | contrib/snap/README.md | 29 | ||||
-rw-r--r-- | contrib/snap/snapcraft.yaml | 31 |
19 files changed, 675 insertions, 257 deletions
diff --git a/contrib/cmake_unofficial/.gitignore b/contrib/cmake_unofficial/.gitignore deleted file mode 100644 index d39505d..0000000 --- a/contrib/cmake_unofficial/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# cmake artefact - -CMakeCache.txt -CMakeFiles -*.cmake -Makefile -liblz4.pc -lz4c -install_manifest.txt diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt deleted file mode 100644 index b09c4fb..0000000 --- a/contrib/cmake_unofficial/CMakeLists.txt +++ /dev/null @@ -1,227 +0,0 @@ -# CMake support for LZ4 -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to -# the public domain worldwide. This software is distributed without -# any warranty. -# -# For details, see <http://creativecommons.org/publicdomain/zero/1.0/>. -# -# LZ4's CMake support is maintained by Evan Nemerson; when filing -# bugs please mention @nemequ to make sure I see it. - -set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") - -option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON) - -# Parse version information -file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$") -string(REGEX REPLACE "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MAJOR "${LZ4_VERSION_MAJOR}") -file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MINOR REGEX "^#define LZ4_VERSION_MINOR +([0-9]+) +.*$") -string(REGEX REPLACE "^#define LZ4_VERSION_MINOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MINOR "${LZ4_VERSION_MINOR}") -file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_RELEASE REGEX "^#define LZ4_VERSION_RELEASE +([0-9]+) +.*$") -string(REGEX REPLACE "^#define LZ4_VERSION_RELEASE +([0-9]+) +.*$" "\\1" LZ4_VERSION_RELEASE "${LZ4_VERSION_RELEASE}") -set(LZ4_VERSION_STRING "${LZ4_VERSION_MAJOR}.${LZ4_VERSION_MINOR}.${LZ4_VERSION_RELEASE}") -mark_as_advanced(LZ4_VERSION_STRING LZ4_VERSION_MAJOR LZ4_VERSION_MINOR LZ4_VERSION_RELEASE) - -if("${CMAKE_VERSION}" VERSION_LESS "3.0") - project(LZ4 C) -else() - cmake_policy (SET CMP0048 NEW) - project(LZ4 - VERSION ${LZ4_VERSION_STRING} - LANGUAGES C) -endif() - -cmake_minimum_required (VERSION 2.8.6) - -# If LZ4 is being bundled in another project, we don't want to -# install anything. However, we want to let people override this, so -# we'll use the LZ4_BUNDLED_MODE variable to let them do that; just -# set it to OFF in your project before you add_subdirectory(lz4/contrib/cmake_unofficial). -get_directory_property(LZ4_PARENT_DIRECTORY PARENT_DIRECTORY) -if("${LZ4_BUNDLED_MODE}" STREQUAL "") - # Bundled mode hasn't been set one way or the other, set the default - # depending on whether or not we are the top-level project. - if("${LZ4_PARENT_DIRECTORY}" STREQUAL "") - set(LZ4_BUNDLED_MODE OFF) - else() - set(LZ4_BUNDLED_MODE ON) - endif() -endif() -mark_as_advanced(LZ4_BUNDLED_MODE) - -# CPack -if(NOT LZ4_BUNDLED_MODE AND NOT CPack_CMake_INCLUDED) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library") - set(CPACK_PACKAGE_DESCRIPTION_FILE "${LZ4_TOP_SOURCE_DIR}/README.md") - set(CPACK_RESOURCE_FILE_LICENSE "${LZ4_TOP_SOURCE_DIR}/LICENSE") - set(CPACK_PACKAGE_VERSION_MAJOR ${LZ4_VERSION_MAJOR}) - set(CPACK_PACKAGE_VERSION_MINOR ${LZ4_VERSION_MINOR}) - set(CPACK_PACKAGE_VERSION_PATCH ${LZ4_VERSION_RELEASE}) - include(CPack) -endif(NOT LZ4_BUNDLED_MODE AND NOT CPack_CMake_INCLUDED) - -# Allow people to choose whether to build shared or static libraries -# via the BUILD_SHARED_LIBS option unless we are in bundled mode, in -# which case we always use static libraries. -include(CMakeDependentOption) -CMAKE_DEPENDENT_OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON "NOT LZ4_BUNDLED_MODE" OFF) -CMAKE_DEPENDENT_OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF "BUILD_SHARED_LIBS" ON) - -if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - message(FATAL_ERROR "Both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS have been disabled") -endif() - -set(LZ4_LIB_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/lib") -set(LZ4_PROG_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/programs") - -include_directories("${LZ4_LIB_SOURCE_DIR}") - -# CLI sources -set(LZ4_SOURCES - "${LZ4_LIB_SOURCE_DIR}/lz4.c" - "${LZ4_LIB_SOURCE_DIR}/lz4hc.c" - "${LZ4_LIB_SOURCE_DIR}/lz4.h" - "${LZ4_LIB_SOURCE_DIR}/lz4hc.h" - "${LZ4_LIB_SOURCE_DIR}/lz4frame.c" - "${LZ4_LIB_SOURCE_DIR}/lz4frame.h" - "${LZ4_LIB_SOURCE_DIR}/xxhash.c") -set(LZ4_CLI_SOURCES - "${LZ4_PROG_SOURCE_DIR}/bench.c" - "${LZ4_PROG_SOURCE_DIR}/lz4cli.c" - "${LZ4_PROG_SOURCE_DIR}/lz4io.c" - "${LZ4_PROG_SOURCE_DIR}/datagen.c") - -# Whether to use position independent code for the static library. If -# we're building a shared library this is ignored and PIC is always -# used. -option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ON) - -# liblz4 -set(LZ4_LIBRARIES_BUILT) -if(BUILD_SHARED_LIBS) - add_library(lz4_shared SHARED ${LZ4_SOURCES}) - set_target_properties(lz4_shared PROPERTIES - OUTPUT_NAME lz4 - SOVERSION "${LZ4_VERSION_MAJOR}" - VERSION "${LZ4_VERSION_STRING}") - list(APPEND LZ4_LIBRARIES_BUILT lz4_shared) -endif() -if(BUILD_STATIC_LIBS) - add_library(lz4_static STATIC ${LZ4_SOURCES}) - set_target_properties(lz4_static PROPERTIES - OUTPUT_NAME lz4 - POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB}) - list(APPEND LZ4_LIBRARIES_BUILT lz4_static) -endif() - -# link to shared whenever possible, to static otherwise -if(BUILD_SHARED_LIBS) - set(LZ4_LINK_LIBRARY lz4_shared) -else() - set(LZ4_LINK_LIBRARY lz4_static) -endif() - -# lz4 -set(LZ4_PROGRAMS_BUILT lz4cli) -add_executable(lz4cli ${LZ4_CLI_SOURCES}) -set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4) -target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY}) - -# lz4c -if (LZ4_BUILD_LEGACY_LZ4C) - list(APPEND LZ4_PROGRAMS_BUILT lz4c) - add_executable(lz4c ${LZ4_CLI_SOURCES}) - set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS") - target_link_libraries(lz4c ${LZ4_LINK_LIBRARY}) -endif() - -# Extra warning flags -include (CheckCCompilerFlag) -foreach (flag - # GCC-style - -Wall - -Wextra - -Wundef - -Wcast-qual - -Wcast-align - -Wshadow - -Wswitch-enum - -Wdeclaration-after-statement - -Wstrict-prototypes - -Wpointer-arith - - # MSVC-style - /W4) - # Because https://gcc.gnu.org/wiki/FAQ#wnowarning - string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}") - string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" test_name "CFLAG_${flag_to_test}") - - check_c_compiler_flag("${ADD_COMPILER_FLAGS_PREPEND} ${flag_to_test}" ${test_name}) - - if(${test_name}) - set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}") - endif() - - unset(test_name) - unset(flag_to_test) -endforeach (flag) - -if(NOT LZ4_BUNDLED_MODE) - include(GNUInstallDirs) - - install(TARGETS ${LZ4_PROGRAMS_BUILT} - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(TARGETS ${LZ4_LIBRARIES_BUILT} - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(FILES - "${LZ4_LIB_SOURCE_DIR}/lz4.h" - "${LZ4_LIB_SOURCE_DIR}/lz4frame.h" - "${LZ4_LIB_SOURCE_DIR}/lz4hc.h" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - install(FILES "${LZ4_PROG_SOURCE_DIR}/lz4.1" - DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - - # install lz4cat and unlz4 symlinks on *nix - if(UNIX) - install(CODE " - foreach(f lz4cat unlz4) - set(dest \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/\${f}\") - message(STATUS \"Symlinking: \${dest} -> lz4\") - execute_process( - COMMAND \"${CMAKE_COMMAND}\" -E create_symlink lz4 \"\${dest}\") - endforeach() - ") - - # create manpage aliases - foreach(f lz4cat unlz4) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${f}.1" ".so man1/lz4.1\n") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${f}.1" - DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") - endforeach() - endif(UNIX) -endif(NOT LZ4_BUNDLED_MODE) - -# pkg-config -set(PREFIX "${CMAKE_INSTALL_PREFIX}") - -if("${CMAKE_INSTALL_FULL_LIBDIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") - set(LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}") -else() - set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") -endif() - -if("${CMAKE_INSTALL_FULL_INCLUDEDIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") - set(INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") -else() - set(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") -endif() - -# for liblz4.pc substitution -set(VERSION ${LZ4_VERSION_STRING}) -configure_file(${LZ4_LIB_SOURCE_DIR}/liblz4.pc.in liblz4.pc @ONLY) diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 18a7f48..0914768 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -4,6 +4,6 @@ Upstream-Contact: Yann Collet <Cyan4973@github.com> Source: https://github.com/lz4/lz4 Files: * -Copyright: (C) 2011+ Yann Collet +Copyright: (C) 2011-2020 Yann Collet License: GPL-2+ - The full text of license: https://github.com/Cyan4973/lz4/blob/master/lib/LICENSE + The full text of license: https://github.com/lz4/lz4/blob/dev/lib/LICENSE diff --git a/contrib/debian/rules b/contrib/debian/rules index 748e68d..c897bc5 100755 --- a/contrib/debian/rules +++ b/contrib/debian/rules @@ -4,5 +4,4 @@ include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/cmake.mk -DEB_CMAKE_EXTRA_FLAGS := -DCMAKE_BUILD_TYPE=RelWithDebInfo ../cmake_unofficial - +DEB_CMAKE_EXTRA_FLAGS := -DCMAKE_BUILD_TYPE=RelWithDebInfo ../../build/cmake diff --git a/contrib/gen_manual/gen_manual.cpp b/contrib/gen_manual/gen_manual.cpp index 65abd3a..d5fe702 100644 --- a/contrib/gen_manual/gen_manual.cpp +++ b/contrib/gen_manual/gen_manual.cpp @@ -44,7 +44,7 @@ void trim(string& s, string characters) { size_t p = s.find_first_not_of(characters); s.erase(0, p); - + p = s.find_last_not_of(characters); if (string::npos != p) s.erase(p+1); @@ -67,14 +67,13 @@ vector<string> get_lines(vector<string>& input, int& linenum, string terminator) { vector<string> out; string line; - size_t epos; while ((size_t)linenum < input.size()) { line = input[linenum]; if (terminator.empty() && line.empty()) { linenum--; break; } - - epos = line.find(terminator); + + size_t const epos = line.find(terminator); if (!terminator.empty() && epos!=string::npos) { out.push_back(line); break; @@ -97,10 +96,9 @@ void print_line(stringstream &sout, string line) epos = line.find("*/"); if (spos!=string::npos && epos!=string::npos) { sout << line.substr(0, spos); - sout << "</b>" << line.substr(spos) << "<b>" << endl; + sout << "</b>" << line.substr(spos) << "<b>" << '\n'; } else { - // fprintf(stderr, "lines=%s\n", line.c_str()); - sout << line << endl; + sout << line << '\n'; } } @@ -152,8 +150,9 @@ int main(int argc, char *argv[]) { continue; } - /* comments of type /**< and /*!< are detected and only function declaration is highlighted (bold) */ - if ((line.find("/**<")!=string::npos || line.find("/*!<")!=string::npos) && line.find("*/")!=string::npos) { + /* comments of type / * * < and / * ! < are detected, and only function declaration is highlighted (bold) */ + if ((line.find("/**<")!=string::npos || line.find("/*!<")!=string::npos) + && line.find("*/")!=string::npos) { sout << "<pre><b>"; print_line(sout, line); sout << "</b></pre><BR>" << endl; @@ -177,16 +176,19 @@ int main(int argc, char *argv[]) { comments = get_lines(input, linenum, "*/"); if (!comments.empty()) comments[0] = line.substr(spos+3); - if (!comments.empty()) comments[comments.size()-1] = comments[comments.size()-1].substr(0, comments[comments.size()-1].find("*/")); + if (!comments.empty()) + comments[comments.size()-1] = comments[comments.size()-1].substr(0, comments[comments.size()-1].find("*/")); for (l=0; l<comments.size(); l++) { - if (comments[l].find(" *")==0) comments[l] = comments[l].substr(2); - else if (comments[l].find(" *")==0) comments[l] = comments[l].substr(3); + if (comments[l].compare(0, 2, " *") == 0) + comments[l] = comments[l].substr(2); + else if (comments[l].compare(0, 3, " *") == 0) + comments[l] = comments[l].substr(3); trim(comments[l], "*-="); } while (!comments.empty() && comments[comments.size()-1].empty()) comments.pop_back(); // remove empty line at the end while (!comments.empty() && comments[0].empty()) comments.erase(comments.begin()); // remove empty line at the start - /* comments of type /*! mean: this is a function declaration; switch comments with declarations */ + /* comments of type / * ! mean: this is a function declaration; switch comments with declarations */ if (exclam == '!') { if (!comments.empty()) comments.erase(comments.begin()); /* remove first line like "LZ4_XXX() :" */ linenum++; @@ -194,7 +196,6 @@ int main(int argc, char *argv[]) { sout << "<pre><b>"; for (l=0; l<lines.size(); l++) { - // fprintf(stderr, "line[%d]=%s\n", l, lines[l].c_str()); print_line(sout, lines[l]); } sout << "</b><p>"; @@ -202,7 +203,7 @@ int main(int argc, char *argv[]) { print_line(sout, comments[l]); } sout << "</p></pre><BR>" << endl << endl; - } else if (exclam == '=') { /* comments of type /*= and /**= mean: use a <H3> header and show also all functions until first empty line */ + } else if (exclam == '=') { /* comments of type / * = and / * * = mean: use a <H3> header and show also all functions until first empty line */ trim(comments[0], " "); sout << "<h3>" << comments[0] << "</h3><pre>"; for (l=1; l<comments.size(); l++) { @@ -214,7 +215,7 @@ int main(int argc, char *argv[]) { print_line(sout, lines[l]); } sout << "</pre></b><BR>" << endl; - } else { /* comments of type /** and /*- mean: this is a comment; use a <H2> header for the first line */ + } else { /* comments of type / * * and / * - mean: this is a comment; use a <H2> header for the first line */ if (comments.empty()) continue; trim(comments[0], " "); @@ -244,4 +245,4 @@ int main(int argc, char *argv[]) { ostream << "</html>" << endl << "</body>" << endl; return 0; -}
\ No newline at end of file +} diff --git a/contrib/meson/README.md b/contrib/meson/README.md new file mode 100644 index 0000000..a44850a --- /dev/null +++ b/contrib/meson/README.md @@ -0,0 +1,34 @@ +Meson build system for lz4 +========================== + +Meson is a build system designed to optimize programmer productivity. +It aims to do this by providing simple, out-of-the-box support for +modern software development tools and practices, such as unit tests, +coverage reports, Valgrind, CCache and the like. + +This Meson build system is provided with no guarantee. + +## How to build + +`cd` to this meson directory (`contrib/meson`) + +```sh +meson setup --buildtype=release -Ddefault_library=shared -Dbin_programs=true builddir +cd builddir +ninja # to build +ninja install # to install +``` + +You might want to install it in staging directory: + +```sh +DESTDIR=./staging ninja install +``` + +To configure build options, use: + +```sh +meson configure +``` + +See [man meson(1)](https://manpages.debian.org/testing/meson/meson.1.en.html). diff --git a/contrib/meson/meson.build b/contrib/meson/meson.build new file mode 100644 index 0000000..d1e97d9 --- /dev/null +++ b/contrib/meson/meson.build @@ -0,0 +1,21 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +# This is a dummy meson file. +# The intention is that it can be easily moved to the root of the project +# (together with meson_options.txt) and packaged for wrapdb. + +project('lz4', ['c'], + license: ['BSD', 'GPLv2'], + default_options : ['c_std=c99', + 'buildtype=release'], + version: 'DUMMY', + meson_version: '>=0.47.0') + +subdir('meson') diff --git a/contrib/meson/meson/GetLz4LibraryVersion.py b/contrib/meson/meson/GetLz4LibraryVersion.py new file mode 100644 index 0000000..d8abfcb --- /dev/null +++ b/contrib/meson/meson/GetLz4LibraryVersion.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# +import re + + +def find_version_tuple(filepath): + version_file_data = None + with open(filepath) as fd: + version_file_data = fd.read() + + patterns = r"""#\s*define\s+LZ4_VERSION_MAJOR\s+([0-9]+).*$ +#\s*define\s+LZ4_VERSION_MINOR\s+([0-9]+).*$ +#\s*define\s+LZ4_VERSION_RELEASE\s+([0-9]+).*$ +""" + regex = re.compile(patterns, re.MULTILINE) + version_match = regex.search(version_file_data) + if version_match: + return version_match.groups() + raise Exception("Unable to find version string.") + + +def main(): + import argparse + parser = argparse.ArgumentParser(description='Print lz4 version from lib/lz4.h') + parser.add_argument('file', help='path to lib/lz4.h') + args = parser.parse_args() + version_tuple = find_version_tuple(args.file) + print('.'.join(version_tuple)) + + +if __name__ == '__main__': + main() diff --git a/contrib/meson/meson/InstallSymlink.py b/contrib/meson/meson/InstallSymlink.py new file mode 100644 index 0000000..3f2998c --- /dev/null +++ b/contrib/meson/meson/InstallSymlink.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# +# This file should be synced with https://github.com/lzutao/meson-symlink + +import os +import pathlib # since Python 3.4 + + +def install_symlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): + if not install_dir.exists(): + install_dir.mkdir(mode=dir_mode, parents=True, exist_ok=True) + if not install_dir.is_dir(): + raise NotADirectoryError(install_dir) + + new_dst = install_dir.joinpath(dst) + if new_dst.is_symlink() and os.readlink(new_dst) == src: + print('File exists: {!r} -> {!r}'.format(new_dst, src)) + return + print('Installing symlink {!r} -> {!r}'.format(new_dst, src)) + new_dst.symlink_to(src, target_is_directory=dst_is_dir) + + +def main(): + import argparse + parser = argparse.ArgumentParser(description='Install a symlink', + usage='{0} [-h] [-d] [-m MODE] source dest install_dir\n\n' + 'example:\n' + ' {0} dash sh /bin'.format(pathlib.Path(__file__).name)) + parser.add_argument('source', help='target to link') + parser.add_argument('dest', help='link name') + parser.add_argument('install_dir', help='installation directory') + parser.add_argument('-d', '--isdir', + action='store_true', + help='dest is a directory') + parser.add_argument('-m', '--mode', + help='directory mode on creating if not exist', + default='0o755') + args = parser.parse_args() + + dir_mode = int(args.mode, 8) + + meson_destdir = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX', default='') + install_dir = pathlib.Path(meson_destdir, args.install_dir) + install_symlink(args.source, args.dest, install_dir, args.isdir, dir_mode) + + +if __name__ == '__main__': + main() diff --git a/contrib/meson/meson/contrib/gen_manual/meson.build b/contrib/meson/meson/contrib/gen_manual/meson.build new file mode 100644 index 0000000..a872bd6 --- /dev/null +++ b/contrib/meson/meson/contrib/gen_manual/meson.build @@ -0,0 +1,43 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +lz4_root_dir = '../../../../..' + +add_languages('cpp') +cxx = meson.get_compiler('cpp') + +gen_manual_includes = include_directories(join_paths(lz4_root_dir, 'contrib/gen_manual')) + +gen_manual_cppflags = cxx.get_supported_arguments(['-Wextra', '-Wcast-qual', + '-Wcast-align', '-Wshadow', '-Wstrict-aliasing=1', '-Wswitch-enum', + '-Wno-comment']) + +gen_manual = executable('gen_manual', + join_paths(lz4_root_dir, 'contrib/gen_manual/gen_manual.cpp'), + cpp_args: gen_manual_cppflags, + include_directories: gen_manual_includes, + native: true, + install: false) + +# Update lz4 manual +lz4_manual_html = custom_target('lz4_manual.html', + output : 'lz4_manual.html', + command : [gen_manual, + lz4_version, + join_paths(meson.current_source_dir(), lz4_root_dir, 'lib/lz4.h'), + '@OUTPUT@'], + install : false) +# Update lz4frame manual +lz4_manual_html = custom_target('lz4frame_manual.html', + output : 'lz4frame_manual.html', + command : [gen_manual, + lz4_version, + join_paths(meson.current_source_dir(), lz4_root_dir, 'lib/lz4frame.h'), + '@OUTPUT@'], + install : false) diff --git a/contrib/meson/meson/contrib/meson.build b/contrib/meson/meson/contrib/meson.build new file mode 100644 index 0000000..5249a4c --- /dev/null +++ b/contrib/meson/meson/contrib/meson.build @@ -0,0 +1,10 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +subdir('gen_manual') diff --git a/contrib/meson/meson/examples/meson.build b/contrib/meson/meson/examples/meson.build new file mode 100644 index 0000000..493049d --- /dev/null +++ b/contrib/meson/meson/examples/meson.build @@ -0,0 +1,49 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +lz4_root_dir = '../../../..' + +#examples_c_args = ['-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wstrict-prototypes'] + +printVersion = executable('printVersion', + join_paths(lz4_root_dir, 'examples/printVersion.c'), + dependencies: liblz4_dep, + install: false) +doubleBuffer = executable('doubleBuffer', + join_paths(lz4_root_dir, 'examples/blockStreaming_doubleBuffer.c'), + dependencies: liblz4_dep, + install: false) +dictionaryRandomAccess = executable('dictionaryRandomAccess', + join_paths(lz4_root_dir, 'examples/dictionaryRandomAccess.c'), + dependencies: liblz4_dep, + install: false) +ringBuffer = executable('ringBuffer', + join_paths(lz4_root_dir, 'examples/blockStreaming_ringBuffer.c'), + dependencies: liblz4_dep, + install: false) +ringBufferHC = executable('ringBufferHC', + join_paths(lz4_root_dir, 'examples/HCStreaming_ringBuffer.c'), + dependencies: liblz4_dep, + install: false) +lineCompress = executable('lineCompress', + join_paths(lz4_root_dir, 'examples/blockStreaming_lineByLine.c'), + dependencies: liblz4_dep, + install: false) +frameCompress = executable('frameCompress', + join_paths(lz4_root_dir, 'examples/frameCompress.c'), + dependencies: liblz4_dep, + install: false) +compressFunctions = executable('compressFunctions', + join_paths(lz4_root_dir, 'examples/compress_functions.c'), + dependencies: liblz4_dep, + install: false) +simpleBuffer = executable('simpleBuffer', + join_paths(lz4_root_dir, 'examples/simple_buffer.c'), + dependencies: liblz4_dep, + install: false) diff --git a/contrib/meson/meson/lib/meson.build b/contrib/meson/meson/lib/meson.build new file mode 100644 index 0000000..131edcb --- /dev/null +++ b/contrib/meson/meson/lib/meson.build @@ -0,0 +1,57 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +lz4_root_dir = '../../../..' + +liblz4_includes = [include_directories(join_paths(lz4_root_dir, 'lib'))] +liblz4_sources = [join_paths(lz4_root_dir, 'lib/lz4.c'), + join_paths(lz4_root_dir, 'lib/lz4frame.c'), + join_paths(lz4_root_dir, 'lib/lz4hc.c'), + join_paths(lz4_root_dir, 'lib/xxhash.c')] +liblz4_c_args = [] + +liblz4_debug_cflags = [] +if use_debug + liblz4_c_args += '-DLZ4_DEBUG=@0@'.format(debug_level) + if [compiler_gcc, compiler_clang].contains(cc_id) + liblz4_debug_cflags = ['-Wextra', '-Wcast-qual', '-Wcast-align', '-Wshadow', + '-Wswitch-enum', '-Wdeclaration-after-statement', '-Wstrict-prototypes', + '-Wundef', '-Wpointer-arith', '-Wstrict-aliasing=1'] + endif +endif +liblz4_c_args += cc.get_supported_arguments(liblz4_debug_cflags) + +if host_machine_os == os_windows and default_library != 'static' + liblz4_c_args += '-DLZ4_DLL_EXPORT=1' +endif + +liblz4 = library('lz4', + liblz4_sources, + include_directories: liblz4_includes, + c_args: liblz4_c_args, + install: true, + version: lz4_libversion) + +liblz4_dep = declare_dependency(link_with: liblz4, + include_directories: liblz4_includes) + +pkgconfig.generate(liblz4, + name: 'lz4', + filebase: 'liblz4', + description: 'extremely fast lossless compression algorithm library', + version: lz4_libversion, + url: 'http://www.lz4.org/') + +install_headers(join_paths(lz4_root_dir, 'lib/lz4.h'), + join_paths(lz4_root_dir, 'lib/lz4hc.h'), + join_paths(lz4_root_dir, 'lib/lz4frame.h')) + +if default_library != 'shared' + install_headers(join_paths(lz4_root_dir, 'lib/lz4frame_static.h')) +endif diff --git a/contrib/meson/meson/meson.build b/contrib/meson/meson/meson.build new file mode 100644 index 0000000..b278b7c --- /dev/null +++ b/contrib/meson/meson/meson.build @@ -0,0 +1,117 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +cc = meson.get_compiler('c') +pkgconfig = import('pkgconfig') +c_std = get_option('c_std') +default_library = get_option('default_library') + +host_machine_os = host_machine.system() +os_windows = 'windows' +os_linux = 'linux' +os_darwin = 'darwin' +os_freebsd = 'freebsd' +os_sun = 'sunos' + +cc_id = cc.get_id() +compiler_gcc = 'gcc' +compiler_clang = 'clang' +compiler_msvc = 'msvc' + +lz4_version = meson.project_version() + +lz4_h_file = join_paths(meson.current_source_dir(), '../../../lib/lz4.h') +GetLz4LibraryVersion_py = find_program('GetLz4LibraryVersion.py', native : true) +r = run_command(GetLz4LibraryVersion_py, lz4_h_file) +if r.returncode() == 0 + lz4_version = r.stdout().strip() + message('Project version is now: @0@'.format(lz4_version)) +else + error('Cannot find project version in @0@'.format(lz4_h_file)) +endif + +lz4_libversion = lz4_version + +# ============================================================================= +# Installation directories +# ============================================================================= + +lz4_prefix = get_option('prefix') +lz4_bindir = get_option('bindir') +lz4_datadir = get_option('datadir') +lz4_mandir = get_option('mandir') +lz4_docdir = join_paths(lz4_datadir, 'doc', meson.project_name()) + +# ============================================================================= +# Project options +# ============================================================================= + +buildtype = get_option('buildtype') + +# Built-in options +use_debug = get_option('debug') + +# Custom options +debug_level = get_option('debug_level') +use_backtrace = get_option('backtrace') + +bin_programs = get_option('bin_programs') +bin_contrib = get_option('bin_contrib') +bin_tests = get_option('bin_tests') +bin_examples = get_option('bin_examples') +#feature_multi_thread = get_option('multi_thread') + +# ============================================================================= +# Dependencies +# ============================================================================= + +#libm_dep = cc.find_library('m', required: bin_tests) +#thread_dep = dependency('threads', required: feature_multi_thread) +#use_multi_thread = thread_dep.found() + +# ============================================================================= +# Compiler flags +# ============================================================================= + +add_project_arguments(['-DXXH_NAMESPACE=LZ4_'], language: 'c') + +if [compiler_gcc, compiler_clang].contains(cc_id) + common_warning_flags = [] + # Should use Meson's own --werror build option + #common_warning_flags += ['-Werror'] + if c_std == 'c89' or c_std == 'gnu89' + common_warning_flags += ['-pedantic', '-Wno-long-long', '-Wno-variadic-macros'] + elif c_std == 'c99' or c_std == 'gnu99' + common_warning_flags += ['-pedantic'] + endif + cc_compile_flags = cc.get_supported_arguments(common_warning_flags) + add_project_arguments(cc_compile_flags, language: 'c') +endif + +# ============================================================================= +# Subdirs +# ============================================================================= + +subdir('lib') + +if bin_programs + subdir('programs') +endif + +if bin_tests + subdir('tests') +endif + +if bin_contrib + subdir('contrib') +endif + +if bin_examples + subdir('examples') +endif diff --git a/contrib/meson/meson/programs/meson.build b/contrib/meson/meson/programs/meson.build new file mode 100644 index 0000000..705dbf5 --- /dev/null +++ b/contrib/meson/meson/programs/meson.build @@ -0,0 +1,52 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +lz4_root_dir = '../../../..' + +lz4_includes = include_directories(join_paths(lz4_root_dir, 'programs')) +lz4_sources = [join_paths(lz4_root_dir, 'programs/bench.c'), + join_paths(lz4_root_dir, 'programs/datagen.c'), + join_paths(lz4_root_dir, 'programs/lz4cli.c'), + join_paths(lz4_root_dir, 'programs/lz4io.c')] +lz4_c_args = [] + +export_dynamic_on_windows = false +# explicit backtrace enable/disable for Linux & Darwin +if not use_backtrace + lz4_c_args += '-DBACKTRACE_ENABLE=0' +elif use_debug and host_machine_os == os_windows # MinGW target + lz4_c_args += '-DBACKTRACE_ENABLE=1' + export_dynamic_on_windows = true +endif + +lz4_deps = [ liblz4_dep ] + +lz4 = executable('lz4', + lz4_sources, + include_directories: lz4_includes, + c_args: lz4_c_args, + dependencies: lz4_deps, + export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0 + install: true) + +# ============================================================================= +# Programs and manpages installing +# ============================================================================= + +install_man(join_paths(lz4_root_dir, 'programs/lz4.1')) + +InstallSymlink_py = '../InstallSymlink.py' +lz4_man1_dir = join_paths(lz4_mandir, 'man1') +bin_EXT = host_machine_os == os_windows ? '.exe' : '' +man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz' + +foreach f : ['lz4c', 'lz4cat', 'unlz4'] + meson.add_install_script(InstallSymlink_py, 'lz4' + bin_EXT, f + bin_EXT, lz4_bindir) + meson.add_install_script(InstallSymlink_py, 'lz4' + man1_EXT, f + man1_EXT, lz4_man1_dir) +endforeach diff --git a/contrib/meson/meson/tests/meson.build b/contrib/meson/meson/tests/meson.build new file mode 100644 index 0000000..7800475 --- /dev/null +++ b/contrib/meson/meson/tests/meson.build @@ -0,0 +1,93 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +lz4_root_dir = '../../../..' +programs_dir_inc = include_directories(join_paths(lz4_root_dir, 'programs')) +lib_dir_inc = include_directories(join_paths(lz4_root_dir, 'lib')) + +# ============================================================================= +# Test flags +# ============================================================================= + +TEST_FILES = join_paths(meson.current_source_dir(), lz4_root_dir, 'tests/COPYING') +FUZZER_TIME = '-T90s' +NB_LOOPS = '-i1' + +# ============================================================================= +# Executables +# ============================================================================= + +fullbench_sources = [join_paths(lz4_root_dir, 'tests/fullbench.c')] +fullbench = executable('fullbench', + fullbench_sources, + include_directories: programs_dir_inc, + dependencies: liblz4_dep, + install: false) + +fuzzer_sources = [join_paths(lz4_root_dir, 'tests/fuzzer.c')] +fuzzer = executable('fuzzer', + fuzzer_sources, + c_args: ['-D_DEFAULT_SOURCE', '-D_BSD_SOURCE'], # since glibc 2.19 + include_directories: programs_dir_inc, + dependencies: liblz4_dep, + install: false) + +frametest_sources = [join_paths(lz4_root_dir, 'tests/frametest.c')] +frametest = executable('frametest', + frametest_sources, + include_directories: programs_dir_inc, + dependencies: liblz4_dep, + install: false) + +roundTripTest_sources = [join_paths(lz4_root_dir, 'tests/roundTripTest.c')] +roundTripTest = executable('roundTripTest', + roundTripTest_sources, + dependencies: [ liblz4_dep ], + install: false) + +datagen_sources = [join_paths(lz4_root_dir, 'tests/datagencli.c')] +datagen = executable('datagen', + datagen_sources, + objects: lz4.extract_objects(join_paths(lz4_root_dir, 'programs/datagen.c')), + include_directories: lz4_includes, + dependencies: [ liblz4_dep ], + install: false) + +checkFrame_sources = [join_paths(lz4_root_dir, 'tests/checkFrame.c')] +checkFrame = executable('checkFrame', + checkFrame_sources, + include_directories: programs_dir_inc, + dependencies: [ liblz4_dep ], + install: false) + +checkTag_sources = [join_paths(lz4_root_dir, 'tests/checkTag.c')] +checkTag = executable('checkTag', + checkTag_sources, + include_directories: lib_dir_inc, + install: false) + +# ============================================================================= +# Tests (Use "meson test --list" to list all tests) +# ============================================================================= + +# XXX: (Need TEST) These timeouts (in seconds) when running on a HDD should be +# at least six times bigger than on a SSD + +test('test-fullbench', + fullbench, + args: ['--no-prompt', NB_LOOPS, TEST_FILES], + timeout: 420) # Should enough when running on HDD +test('test-fuzzer', + fuzzer, + args: [FUZZER_TIME], + timeout: 100) +test('test-frametest', + frametest, + args: [FUZZER_TIME], + timeout: 100) diff --git a/contrib/meson/meson_options.txt b/contrib/meson/meson_options.txt new file mode 100644 index 0000000..a409c2d --- /dev/null +++ b/contrib/meson/meson_options.txt @@ -0,0 +1,24 @@ +# ############################################################################# +# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com> +# All rights reserved. +# +# This source code is licensed under both the BSD-style license (found in the +# LICENSE file in the root directory of this source tree) and the GPLv2 (found +# in the COPYING file in the root directory of this source tree). +# ############################################################################# + +# Read guidelines from https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting + +option('debug_level', type: 'integer', min: 0, max: 7, value: 1, + description: 'Enable run-time debug. See lib/lz4hc.c') +option('backtrace', type: 'boolean', value: false, + description: 'Display a stack backtrace when execution generates a runtime exception') + +option('bin_programs', type: 'boolean', value: false, + description: 'Enable programs build') +option('bin_tests', type: 'boolean', value: false, + description: 'Enable tests build') +option('bin_contrib', type: 'boolean', value: false, + description: 'Enable contrib build') +option('bin_examples', type: 'boolean', value: false, + description: 'Enable examples build') diff --git a/contrib/snap/README.md b/contrib/snap/README.md new file mode 100644 index 0000000..612d6d7 --- /dev/null +++ b/contrib/snap/README.md @@ -0,0 +1,29 @@ +Snap Packaging +-------------- + +This directory contains the config required to generate a snap package +of lz4. Snaps are universal Linux packages that allow you to easily +build your application from any source and ship it to any Linux +distribution by publishing it to https://snapcraft.io/. A key attribute +of a snap package is that it is (ideally) confined such that it +executes within a controlled environmenti with all its dependencies +bundled with it and does not share dependencies with of from any other +package on the system (with a couple of minor exceptions). + +The basic anatomy and workflow is: + + * ensure snap.snapcraft.yaml is up-to-date e.g. with version info + + * build the snap by installing the snapcraft package and running it + + * push snap/* changes to the repo (excluding any crud generated by a build of course) + + * register yourself as owner of lz4 name in snapstore + + * publish new snap to the snap store + + * install snap by doing 'snap install lz4' on any Linux distro + + * all installed copies of lz4 will be automatically updated to your new version + +For more information on Snaps see https://docs.snapcraft.io and https://forum.snapcraft.io/ diff --git a/contrib/snap/snapcraft.yaml b/contrib/snap/snapcraft.yaml new file mode 100644 index 0000000..2793c0e --- /dev/null +++ b/contrib/snap/snapcraft.yaml @@ -0,0 +1,31 @@ +name: lz4 +version: 1.8.4 +summary: Extremely Fast Compression algorithm +description: > + LZ4 is lossless compression algorithm, providing compression + speed > 500 MB/s per core, scalable with multi-cores CPU. It features an + extremely fast decoder, with speed in multiple GB/s per core, typically + reaching RAM speed limits on multi-core systems. + . + Speed can be tuned dynamically, selecting an "acceleration" factor which + trades compression ratio for faster speed. On the other end, a high + compression derivative, LZ4_HC, is also provided, trading CPU time for + improved compression ratio. All versions feature the same decompression + speed. + . + LZ4 is also compatible with dictionary compression, and can ingest any + input file as dictionary, including those created by Zstandard Dictionary + Builder. (note: only the final 64KB are used). + . + LZ4 library is provided as open-source software using BSD 2-Clause license. +confinement: strict +grade: stable + +apps: + lz4: + command: usr/local/bin/lz4 + plugs: [home] +parts: + lz4: + source: ../ + plugin: make |