extlz4 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +43 -3
  4. data/contrib/lz4/CODING_STYLE +57 -0
  5. data/contrib/lz4/LICENSE +3 -2
  6. data/contrib/lz4/Makefile.inc +56 -30
  7. data/contrib/lz4/NEWS +46 -0
  8. data/contrib/lz4/README.md +17 -6
  9. data/contrib/lz4/SECURITY.md +17 -0
  10. data/contrib/lz4/build/README.md +4 -15
  11. data/contrib/lz4/build/VS2022/_build.bat +39 -0
  12. data/contrib/lz4/build/VS2022/_setup.bat +35 -0
  13. data/contrib/lz4/build/VS2022/_test.bat +38 -0
  14. data/contrib/lz4/build/VS2022/build-and-test-win32-debug.bat +26 -0
  15. data/contrib/lz4/build/VS2022/build-and-test-win32-release.bat +26 -0
  16. data/contrib/lz4/build/VS2022/build-and-test-x64-debug.bat +26 -0
  17. data/contrib/lz4/build/VS2022/build-and-test-x64-release.bat +26 -0
  18. data/contrib/lz4/build/{VS2017 → VS2022}/datagen/datagen.vcxproj +11 -7
  19. data/contrib/lz4/build/{VS2017 → VS2022}/frametest/frametest.vcxproj +4 -4
  20. data/contrib/lz4/build/{VS2017 → VS2022}/fullbench/fullbench.vcxproj +4 -4
  21. data/contrib/lz4/build/{VS2017 → VS2022}/fullbench-dll/fullbench-dll.vcxproj +4 -4
  22. data/contrib/lz4/build/{VS2017 → VS2022}/fuzzer/fuzzer.vcxproj +4 -4
  23. data/contrib/lz4/build/{VS2017 → VS2022}/liblz4/liblz4.vcxproj +4 -4
  24. data/contrib/lz4/build/{VS2010 → VS2022}/liblz4-dll/liblz4-dll.rc +1 -1
  25. data/contrib/lz4/build/{VS2017 → VS2022}/liblz4-dll/liblz4-dll.vcxproj +4 -4
  26. data/contrib/lz4/build/{VS2010 → VS2022}/lz4/lz4.rc +1 -1
  27. data/contrib/lz4/build/{VS2017 → VS2022}/lz4/lz4.vcxproj +33 -8
  28. data/contrib/lz4/build/{VS2017 → VS2022}/lz4.sln +5 -2
  29. data/contrib/lz4/build/cmake/CMakeLists.txt +133 -100
  30. data/contrib/lz4/build/cmake/lz4Config.cmake.in +2 -0
  31. data/contrib/lz4/build/meson/GetLz4LibraryVersion.py +39 -0
  32. data/contrib/lz4/build/meson/README.md +34 -0
  33. data/contrib/lz4/build/meson/meson/contrib/gen_manual/meson.build +42 -0
  34. data/contrib/lz4/build/meson/meson/contrib/meson.build +11 -0
  35. data/contrib/lz4/build/meson/meson/examples/meson.build +32 -0
  36. data/contrib/lz4/build/meson/meson/lib/meson.build +87 -0
  37. data/contrib/lz4/build/meson/meson/meson.build +135 -0
  38. data/contrib/lz4/build/meson/meson/ossfuzz/meson.build +35 -0
  39. data/contrib/lz4/build/meson/meson/programs/meson.build +91 -0
  40. data/contrib/lz4/build/meson/meson/tests/meson.build +162 -0
  41. data/contrib/lz4/build/meson/meson.build +31 -0
  42. data/contrib/lz4/build/meson/meson_options.txt +44 -0
  43. data/contrib/lz4/build/visual/README.md +5 -0
  44. data/contrib/lz4/build/visual/generate_solution.cmd +55 -0
  45. data/contrib/lz4/build/visual/generate_vs2015.cmd +3 -0
  46. data/contrib/lz4/build/visual/generate_vs2017.cmd +3 -0
  47. data/contrib/lz4/build/visual/generate_vs2019.cmd +3 -0
  48. data/contrib/lz4/build/visual/generate_vs2022.cmd +3 -0
  49. data/contrib/lz4/lib/LICENSE +1 -1
  50. data/contrib/lz4/lib/README.md +69 -13
  51. data/contrib/lz4/lib/liblz4-dll.rc.in +1 -1
  52. data/contrib/lz4/lib/liblz4.pc.in +3 -3
  53. data/contrib/lz4/lib/lz4.c +608 -274
  54. data/contrib/lz4/lib/lz4.h +212 -102
  55. data/contrib/lz4/lib/lz4file.c +341 -0
  56. data/contrib/lz4/lib/lz4file.h +93 -0
  57. data/contrib/lz4/lib/lz4frame.c +545 -308
  58. data/contrib/lz4/lib/lz4frame.h +252 -124
  59. data/contrib/lz4/lib/lz4frame_static.h +1 -1
  60. data/contrib/lz4/lib/lz4hc.c +1038 -461
  61. data/contrib/lz4/lib/lz4hc.h +57 -56
  62. data/contrib/lz4/lib/xxhash.c +21 -21
  63. data/contrib/lz4/ossfuzz/Makefile +1 -0
  64. data/contrib/lz4/ossfuzz/decompress_fuzzer.c +18 -2
  65. data/contrib/lz4/ossfuzz/fuzz_helpers.h +4 -3
  66. data/contrib/lz4/ossfuzz/round_trip_frame_uncompressed_fuzzer.c +134 -0
  67. data/contrib/lz4/ossfuzz/round_trip_fuzzer.c +66 -6
  68. data/ext/blockapi.c +19 -19
  69. data/ext/extlz4.h +12 -0
  70. data/ext/frameapi.c +26 -26
  71. data/ext/hashargs.c +7 -1
  72. metadata +47 -30
  73. data/contrib/lz4/build/VS2010/datagen/datagen.vcxproj +0 -169
  74. data/contrib/lz4/build/VS2010/frametest/frametest.vcxproj +0 -176
  75. data/contrib/lz4/build/VS2010/fullbench/fullbench.vcxproj +0 -176
  76. data/contrib/lz4/build/VS2010/fullbench-dll/fullbench-dll.vcxproj +0 -180
  77. data/contrib/lz4/build/VS2010/fuzzer/fuzzer.vcxproj +0 -173
  78. data/contrib/lz4/build/VS2010/liblz4/liblz4.vcxproj +0 -175
  79. data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.vcxproj +0 -179
  80. data/contrib/lz4/build/VS2010/lz4/lz4.vcxproj +0 -189
  81. data/contrib/lz4/build/VS2010/lz4.sln +0 -98
  82. data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.rc +0 -51
  83. data/contrib/lz4/build/VS2017/lz4/lz4.rc +0 -51
  84. data/contrib/lz4/tmp +0 -0
  85. data/contrib/lz4/tmpsparse +0 -0
@@ -6,48 +6,43 @@
6
6
  # any warranty.
7
7
  #
8
8
  # For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
9
- #
10
- # LZ4's CMake support is maintained by Evan Nemerson; when filing
11
- # bugs please mention @nemequ to make sure I see it.
12
9
 
13
- set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
14
10
 
15
- option(LZ4_BUILD_CLI "Build lz4 program" ON)
16
- option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON)
11
+ cmake_minimum_required(VERSION 3.5)
12
+
13
+ set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
17
14
 
18
15
  # Parse version information
19
- file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$")
20
- string(REGEX REPLACE "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MAJOR "${LZ4_VERSION_MAJOR}")
21
- file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MINOR REGEX "^#define LZ4_VERSION_MINOR +([0-9]+) +.*$")
22
- string(REGEX REPLACE "^#define LZ4_VERSION_MINOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MINOR "${LZ4_VERSION_MINOR}")
23
- file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_RELEASE REGEX "^#define LZ4_VERSION_RELEASE +([0-9]+) +.*$")
24
- string(REGEX REPLACE "^#define LZ4_VERSION_RELEASE +([0-9]+) +.*$" "\\1" LZ4_VERSION_RELEASE "${LZ4_VERSION_RELEASE}")
16
+ function(parse_lz4_version VERSION_TYPE)
17
+ file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" version_line REGEX "^#define LZ4_VERSION_${VERSION_TYPE} +([0-9]+).*$")
18
+ string(REGEX REPLACE "^#define LZ4_VERSION_${VERSION_TYPE} +([0-9]+).*$" "\\1" version_number "${version_line}")
19
+ set(LZ4_VERSION_${VERSION_TYPE} ${version_number} PARENT_SCOPE)
20
+ endfunction()
21
+
22
+ foreach(version_type IN ITEMS MAJOR MINOR RELEASE)
23
+ parse_lz4_version(${version_type})
24
+ endforeach()
25
+
25
26
  set(LZ4_VERSION_STRING "${LZ4_VERSION_MAJOR}.${LZ4_VERSION_MINOR}.${LZ4_VERSION_RELEASE}")
26
27
  mark_as_advanced(LZ4_VERSION_STRING LZ4_VERSION_MAJOR LZ4_VERSION_MINOR LZ4_VERSION_RELEASE)
27
28
 
28
- if("${CMAKE_VERSION}" VERSION_LESS "3.0")
29
- project(LZ4 C)
30
- else()
31
- cmake_policy (SET CMP0048 NEW)
32
- project(LZ4
33
- VERSION ${LZ4_VERSION_STRING}
34
- LANGUAGES C)
35
- endif()
29
+ message(STATUS "Creating build script for LZ4 version: ${LZ4_VERSION_STRING}")
36
30
 
37
- cmake_minimum_required (VERSION 2.8.6)
38
-
39
- # If LZ4 is being bundled in another project, we don't want to
40
- # install anything. However, we want to let people override this, so
41
- # we'll use the LZ4_BUNDLED_MODE variable to let them do that; just
42
- # set it to OFF in your project before you add_subdirectory(lz4/contrib/cmake_unofficial).
43
- get_directory_property(LZ4_PARENT_DIRECTORY PARENT_DIRECTORY)
44
- if("${LZ4_BUNDLED_MODE}" STREQUAL "")
45
- # Bundled mode hasn't been set one way or the other, set the default
46
- # depending on whether or not we are the top-level project.
47
- if("${LZ4_PARENT_DIRECTORY}" STREQUAL "")
48
- set(LZ4_BUNDLED_MODE OFF)
49
- else()
31
+ project(LZ4 VERSION ${LZ4_VERSION_STRING} LANGUAGES C)
32
+
33
+
34
+ option(LZ4_BUILD_CLI "Build lz4 program" ON)
35
+
36
+
37
+ # Determine if LZ4 is being built as part of another project.
38
+ # If LZ4 is bundled in another project, we don't want to install anything.
39
+ # Default behavior can be overridden by setting the LZ4_BUNDLED_MODE variable.
40
+ if(NOT DEFINED LZ4_BUNDLED_MODE)
41
+ get_directory_property(LZ4_IS_SUBPROJECT PARENT_DIRECTORY)
42
+ if(LZ4_IS_SUBPROJECT)
50
43
  set(LZ4_BUNDLED_MODE ON)
44
+ else()
45
+ set(LZ4_BUNDLED_MODE OFF)
51
46
  endif()
52
47
  endif()
53
48
  mark_as_advanced(LZ4_BUNDLED_MODE)
@@ -80,19 +75,11 @@ set(LZ4_PROG_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/programs")
80
75
  include_directories("${LZ4_LIB_SOURCE_DIR}")
81
76
 
82
77
  # CLI sources
83
- set(LZ4_SOURCES
84
- "${LZ4_LIB_SOURCE_DIR}/lz4.c"
85
- "${LZ4_LIB_SOURCE_DIR}/lz4hc.c"
86
- "${LZ4_LIB_SOURCE_DIR}/lz4.h"
87
- "${LZ4_LIB_SOURCE_DIR}/lz4hc.h"
88
- "${LZ4_LIB_SOURCE_DIR}/lz4frame.c"
89
- "${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
90
- "${LZ4_LIB_SOURCE_DIR}/xxhash.c")
91
- set(LZ4_CLI_SOURCES
92
- "${LZ4_PROG_SOURCE_DIR}/bench.c"
93
- "${LZ4_PROG_SOURCE_DIR}/lz4cli.c"
94
- "${LZ4_PROG_SOURCE_DIR}/lz4io.c"
95
- "${LZ4_PROG_SOURCE_DIR}/datagen.c")
78
+ file(GLOB LZ4_SOURCES
79
+ "${LZ4_LIB_SOURCE_DIR}/*.c")
80
+ file(GLOB LZ4_CLI_SOURCES
81
+ "${LZ4_PROG_SOURCE_DIR}/*.c")
82
+ list(APPEND LZ4_CLI_SOURCES ${LZ4_SOURCES}) # LZ4_CLI always use liblz4 sources directly.
96
83
 
97
84
  # Whether to use position independent code for the static library. If
98
85
  # we're building a shared library this is ignored and PIC is always
@@ -100,9 +87,13 @@ set(LZ4_CLI_SOURCES
100
87
  option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ON)
101
88
 
102
89
  # liblz4
90
+ include(GNUInstallDirs)
103
91
  set(LZ4_LIBRARIES_BUILT)
104
92
  if(BUILD_SHARED_LIBS)
105
93
  add_library(lz4_shared SHARED ${LZ4_SOURCES})
94
+ target_include_directories(lz4_shared
95
+ PUBLIC $<BUILD_INTERFACE:${LZ4_LIB_SOURCE_DIR}>
96
+ INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
106
97
  set_target_properties(lz4_shared PROPERTIES
107
98
  OUTPUT_NAME lz4
108
99
  SOVERSION "${LZ4_VERSION_MAJOR}"
@@ -114,18 +105,36 @@ if(BUILD_SHARED_LIBS)
114
105
  list(APPEND LZ4_LIBRARIES_BUILT lz4_shared)
115
106
  endif()
116
107
  if(BUILD_STATIC_LIBS)
108
+ set(STATIC_LIB_NAME lz4)
109
+ if (MSVC AND BUILD_SHARED_LIBS)
110
+ set(STATIC_LIB_NAME lz4_static)
111
+ endif()
117
112
  add_library(lz4_static STATIC ${LZ4_SOURCES})
113
+ target_include_directories(lz4_static
114
+ PUBLIC $<BUILD_INTERFACE:${LZ4_LIB_SOURCE_DIR}>
115
+ INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
118
116
  set_target_properties(lz4_static PROPERTIES
119
- OUTPUT_NAME lz4
117
+ OUTPUT_NAME ${STATIC_LIB_NAME}
120
118
  POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB})
121
119
  list(APPEND LZ4_LIBRARIES_BUILT lz4_static)
122
120
  endif()
123
-
124
- # link to shared whenever possible, to static otherwise
121
+ # Add unified target.
122
+ add_library(lz4 INTERFACE)
123
+ list(APPEND LZ4_LIBRARIES_BUILT lz4)
125
124
  if(BUILD_SHARED_LIBS)
126
- set(LZ4_LINK_LIBRARY lz4_shared)
125
+ target_link_libraries(lz4 INTERFACE lz4_shared)
127
126
  else()
128
- set(LZ4_LINK_LIBRARY lz4_static)
127
+ target_link_libraries(lz4 INTERFACE lz4_static)
128
+ endif()
129
+
130
+ # xxhash namespace
131
+ if(BUILD_SHARED_LIBS)
132
+ target_compile_definitions(lz4_shared PRIVATE
133
+ XXH_NAMESPACE=LZ4_)
134
+ endif()
135
+ if(BUILD_STATIC_LIBS)
136
+ target_compile_definitions(lz4_static PRIVATE
137
+ XXH_NAMESPACE=LZ4_)
129
138
  endif()
130
139
 
131
140
  # lz4
@@ -133,78 +142,102 @@ if (LZ4_BUILD_CLI)
133
142
  set(LZ4_PROGRAMS_BUILT lz4cli)
134
143
  add_executable(lz4cli ${LZ4_CLI_SOURCES})
135
144
  set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4)
136
- target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY})
137
- endif()
138
-
139
- # lz4c
140
- if (LZ4_BUILD_LEGACY_LZ4C)
141
- list(APPEND LZ4_PROGRAMS_BUILT lz4c)
142
- add_executable(lz4c ${LZ4_CLI_SOURCES})
143
- set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS")
144
- target_link_libraries(lz4c ${LZ4_LINK_LIBRARY})
145
145
  endif()
146
146
 
147
147
  # Extra warning flags
148
- include (CheckCCompilerFlag)
149
- foreach (flag
150
- # GCC-style
151
- -Wall
152
- -Wextra
153
- -Wundef
154
- -Wcast-qual
155
- -Wcast-align
156
- -Wshadow
157
- -Wswitch-enum
158
- -Wdeclaration-after-statement
159
- -Wstrict-prototypes
160
- -Wpointer-arith
161
-
162
- # MSVC-style
163
- /W4)
164
- # Because https://gcc.gnu.org/wiki/FAQ#wnowarning
165
- string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
166
- string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" test_name "CFLAG_${flag_to_test}")
167
-
168
- check_c_compiler_flag("${ADD_COMPILER_FLAGS_PREPEND} ${flag_to_test}" ${test_name})
169
-
170
- if(${test_name})
171
- set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
172
- endif()
148
+ if(MSVC)
149
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W4")
150
+ else()
151
+ include (CheckCCompilerFlag)
152
+ foreach (flag
153
+ # GCC-style
154
+ -pedantic-errors
155
+ -Wall
156
+ -Wextra
157
+ -Wundef
158
+ -Wcast-qual
159
+ -Wcast-align
160
+ -Wshadow
161
+ -Wswitch-enum
162
+ -Wdeclaration-after-statement
163
+ -Wstrict-prototypes
164
+ -Wpointer-arith)
173
165
 
174
- unset(test_name)
175
- unset(flag_to_test)
176
- endforeach (flag)
166
+ # Because https://gcc.gnu.org/wiki/FAQ#wnowarning
167
+ string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
168
+ string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" test_name "CFLAG_${flag_to_test}")
177
169
 
178
- if(NOT LZ4_BUNDLED_MODE)
179
- include(GNUInstallDirs)
170
+ check_c_compiler_flag("${ADD_COMPILER_FLAGS_PREPEND} ${flag_to_test}" ${test_name})
171
+
172
+ if(${test_name})
173
+ set(CMAKE_C_FLAGS_DEBUG "${flag} ${CMAKE_C_FLAGS_DEBUG}")
174
+ endif()
175
+
176
+ unset(test_name)
177
+ unset(flag_to_test)
178
+ endforeach (flag)
179
+ endif()
180
180
 
181
+
182
+ if(NOT LZ4_BUNDLED_MODE)
181
183
  install(TARGETS ${LZ4_PROGRAMS_BUILT}
182
184
  BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
183
185
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
184
186
  install(TARGETS ${LZ4_LIBRARIES_BUILT}
187
+ EXPORT lz4Targets
185
188
  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
186
189
  ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
187
190
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
188
191
  install(FILES
189
192
  "${LZ4_LIB_SOURCE_DIR}/lz4.h"
190
- "${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
191
193
  "${LZ4_LIB_SOURCE_DIR}/lz4hc.h"
194
+ "${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
195
+ "${LZ4_LIB_SOURCE_DIR}/lz4file.h"
192
196
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
193
197
  install(FILES "${LZ4_PROG_SOURCE_DIR}/lz4.1"
194
198
  DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
195
199
  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc"
196
200
  DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
197
201
 
198
- # install lz4cat and unlz4 symlinks on *nix
202
+ include(CMakePackageConfigHelpers)
203
+ write_basic_package_version_file(
204
+ "${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake"
205
+ VERSION ${LZ4_VERSION_STRING}
206
+ COMPATIBILITY SameMajorVersion)
207
+
208
+ set(LZ4_PKG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/cmake/lz4")
209
+ configure_package_config_file(
210
+ "${CMAKE_CURRENT_LIST_DIR}/lz4Config.cmake.in"
211
+ "${CMAKE_CURRENT_BINARY_DIR}/lz4Config.cmake"
212
+ INSTALL_DESTINATION ${LZ4_PKG_INSTALLDIR})
213
+ export(EXPORT lz4Targets
214
+ FILE ${CMAKE_CURRENT_BINARY_DIR}/lz4Targets.cmake
215
+ NAMESPACE LZ4::)
216
+
217
+ install(EXPORT lz4Targets
218
+ FILE lz4Targets.cmake
219
+ NAMESPACE LZ4::
220
+ DESTINATION ${LZ4_PKG_INSTALLDIR})
221
+ install(FILES
222
+ ${CMAKE_CURRENT_BINARY_DIR}/lz4Config.cmake
223
+ ${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake
224
+ DESTINATION ${LZ4_PKG_INSTALLDIR})
225
+
226
+ # Install lz4cat and unlz4 symlinks on Unix systems
199
227
  if(UNIX AND LZ4_BUILD_CLI)
200
- install(CODE "
201
- foreach(f lz4cat unlz4)
202
- set(dest \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/\${f}\")
203
- message(STATUS \"Symlinking: \${dest} -> lz4\")
204
- execute_process(
205
- COMMAND \"${CMAKE_COMMAND}\" -E create_symlink lz4 \"\${dest}\")
206
- endforeach()
207
- ")
228
+ foreach(cli_tool IN ITEMS lz4cat unlz4)
229
+ # Create a custom target for the symlink creation
230
+ add_custom_target("create_${cli_tool}_symlink" ALL
231
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
232
+ $<TARGET_FILE_NAME:lz4cli> ${cli_tool}
233
+ COMMENT "Creating symlink for ${cli_tool}"
234
+ VERBATIM)
235
+
236
+ # Install the symlink into the binary installation directory
237
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${cli_tool}"
238
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
239
+ RENAME ${cli_tool})
240
+ endforeach()
208
241
 
209
242
  # create manpage aliases
210
243
  foreach(f lz4cat unlz4)
@@ -0,0 +1,2 @@
1
+ @PACKAGE_INIT@
2
+ include( "${CMAKE_CURRENT_LIST_DIR}/lz4Targets.cmake" )
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python3
2
+ # #############################################################################
3
+ # Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
4
+ # All rights reserved.
5
+ #
6
+ # This source code is licensed under both the BSD-style license (found in the
7
+ # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8
+ # in the COPYING file in the root directory of this source tree).
9
+ # #############################################################################
10
+ import re
11
+
12
+
13
+ def find_version_tuple(filepath):
14
+ version_file_data = None
15
+ with open(filepath) as fd:
16
+ version_file_data = fd.read()
17
+
18
+ patterns = r"""\s*#\s*define\s+LZ4_VERSION_MAJOR\s+([0-9]+).*$
19
+ \s*#\s*define\s+LZ4_VERSION_MINOR\s+([0-9]+).*$
20
+ \s*#\s*define\s+LZ4_VERSION_RELEASE\s+([0-9]+).*$
21
+ """
22
+ regex = re.compile(patterns, re.MULTILINE)
23
+ version_match = regex.search(version_file_data)
24
+ if version_match:
25
+ return version_match.groups()
26
+ raise Exception("Unable to find version string.")
27
+
28
+
29
+ def main():
30
+ import argparse
31
+ parser = argparse.ArgumentParser(description='Print lz4 version from lib/lz4.h')
32
+ parser.add_argument('file', help='path to lib/lz4.h')
33
+ args = parser.parse_args()
34
+ version_tuple = find_version_tuple(args.file)
35
+ print('.'.join(version_tuple))
36
+
37
+
38
+ if __name__ == '__main__':
39
+ main()
@@ -0,0 +1,34 @@
1
+ Meson build system for lz4
2
+ ==========================
3
+
4
+ Meson is a build system designed to optimize programmer productivity.
5
+ It aims to do this by providing simple, out-of-the-box support for
6
+ modern software development tools and practices, such as unit tests,
7
+ coverage reports, Valgrind, CCache and the like.
8
+
9
+ This Meson build system is provided with no guarantee.
10
+
11
+ ## How to build
12
+
13
+ `cd` to this meson directory (`contrib/meson`)
14
+
15
+ ```sh
16
+ meson setup --buildtype=release -Ddefault_library=shared -Dprograms=true builddir
17
+ cd builddir
18
+ ninja # to build
19
+ ninja install # to install
20
+ ```
21
+
22
+ You might want to install it in staging directory:
23
+
24
+ ```sh
25
+ DESTDIR=./staging ninja install
26
+ ```
27
+
28
+ To configure build options, use:
29
+
30
+ ```sh
31
+ meson configure
32
+ ```
33
+
34
+ See [man meson(1)](https://manpages.debian.org/testing/meson/meson.1.en.html).
@@ -0,0 +1,42 @@
1
+ # #############################################################################
2
+ # Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
3
+ # Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
4
+ # All rights reserved.
5
+ #
6
+ # This source code is licensed under both the BSD-style license (found in the
7
+ # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8
+ # in the COPYING file in the root directory of this source tree).
9
+ # #############################################################################
10
+
11
+ lz4_source_root = '../../../../..'
12
+
13
+ add_languages('cpp', native: true)
14
+
15
+ sources = files(
16
+ lz4_source_root / 'contrib/gen_manual/gen_manual.cpp'
17
+ )
18
+
19
+ gen_manual = executable(
20
+ 'gen_manual',
21
+ sources,
22
+ native: true,
23
+ install: false
24
+ )
25
+
26
+ manual_pages = ['lz4', 'lz4frame']
27
+
28
+ foreach mp : manual_pages
29
+ custom_target(
30
+ '@0@_manual.html'.format(mp),
31
+ build_by_default: true,
32
+ input: lz4_source_root / 'lib/@0@.h'.format(mp),
33
+ output: '@0@_manual.html'.format(mp),
34
+ command: [
35
+ gen_manual,
36
+ meson.project_version(),
37
+ '@INPUT@',
38
+ '@OUTPUT@',
39
+ ],
40
+ install: false
41
+ )
42
+ endforeach
@@ -0,0 +1,11 @@
1
+ # #############################################################################
2
+ # Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
3
+ # Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
4
+ # All rights reserved.
5
+ #
6
+ # This source code is licensed under both the BSD-style license (found in the
7
+ # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8
+ # in the COPYING file in the root directory of this source tree).
9
+ # #############################################################################
10
+
11
+ subdir('gen_manual')
@@ -0,0 +1,32 @@
1
+ # #############################################################################
2
+ # Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
3
+ # Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
4
+ # All rights reserved.
5
+ #
6
+ # This source code is licensed under both the BSD-style license (found in the
7
+ # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8
+ # in the COPYING file in the root directory of this source tree).
9
+ # #############################################################################
10
+
11
+ lz4_source_root = '../../../..'
12
+
13
+ examples = {
14
+ 'print_version': 'print_version.c',
15
+ 'blockStreaming_doubleBuffer': 'blockStreaming_doubleBuffer.c',
16
+ 'dictionaryRandomAccess': 'dictionaryRandomAccess.c',
17
+ 'blockStreaming_ringBuffer': 'blockStreaming_ringBuffer.c',
18
+ 'streamingHC_ringBuffer': 'streamingHC_ringBuffer.c',
19
+ 'blockStreaming_lineByLine': 'blockStreaming_lineByLine.c',
20
+ 'frameCompress': 'frameCompress.c',
21
+ 'bench_functions': 'bench_functions.c',
22
+ 'simple_buffer': 'simple_buffer.c',
23
+ }
24
+
25
+ foreach e, src : examples
26
+ executable(
27
+ e,
28
+ lz4_source_root / 'examples' / src,
29
+ dependencies: [liblz4_internal_dep],
30
+ install: false
31
+ )
32
+ endforeach
@@ -0,0 +1,87 @@
1
+ # #############################################################################
2
+ # Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
3
+ # Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
4
+ # All rights reserved.
5
+ #
6
+ # This source code is licensed under both the BSD-style license (found in the
7
+ # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8
+ # in the COPYING file in the root directory of this source tree).
9
+ # #############################################################################
10
+
11
+ lz4_source_root = '../../../..'
12
+
13
+ sources = files(
14
+ lz4_source_root / 'lib/lz4.c',
15
+ lz4_source_root / 'lib/lz4frame.c',
16
+ lz4_source_root / 'lib/lz4hc.c',
17
+ lz4_source_root / 'lib/xxhash.c'
18
+ )
19
+
20
+ if get_option('unstable')
21
+ sources += files(lz4_source_root / 'lib/lz4file.c')
22
+ endif
23
+
24
+ c_args = []
25
+
26
+ if host_machine.system() == 'windows' and get_option('default_library') != 'static'
27
+ c_args += '-DLZ4_DLL_EXPORT=1'
28
+ endif
29
+
30
+ liblz4 = library(
31
+ 'lz4',
32
+ sources,
33
+ c_args: c_args,
34
+ install: true,
35
+ version: meson.project_version(),
36
+ gnu_symbol_visibility: 'hidden'
37
+ )
38
+
39
+ liblz4_dep = declare_dependency(
40
+ link_with: liblz4,
41
+ compile_args: compile_args,
42
+ include_directories: include_directories(lz4_source_root / 'lib')
43
+ )
44
+
45
+ meson.override_dependency('liblz4', liblz4_dep)
46
+
47
+ if get_option('tests') or get_option('programs') or get_option('examples') or get_option('ossfuzz')
48
+ if get_option('default_library') == 'shared'
49
+ liblz4_internal = static_library(
50
+ 'lz4-internal',
51
+ objects: liblz4.extract_all_objects(recursive: true),
52
+ gnu_symbol_visibility: 'hidden'
53
+ )
54
+ elif get_option('default_library') == 'static'
55
+ liblz4_internal = liblz4
56
+ elif get_option('default_library') == 'both'
57
+ liblz4_internal = liblz4.get_static_lib()
58
+ endif
59
+
60
+ liblz4_internal_dep = declare_dependency(
61
+ link_with: liblz4_internal,
62
+ compile_args: compile_args,
63
+ include_directories: include_directories(lz4_source_root / 'lib')
64
+ )
65
+ endif
66
+
67
+ pkgconfig.generate(
68
+ liblz4,
69
+ name: 'lz4',
70
+ filebase: 'liblz4',
71
+ description: 'extremely fast lossless compression algorithm library',
72
+ version: meson.project_version(),
73
+ url: 'http://www.lz4.org/'
74
+ )
75
+
76
+ install_headers(
77
+ lz4_source_root / 'lib/lz4.h',
78
+ lz4_source_root / 'lib/lz4hc.h',
79
+ lz4_source_root / 'lib/lz4frame.h'
80
+ )
81
+
82
+ if get_option('default_library') != 'shared'
83
+ install_headers(lz4_source_root / 'lib/lz4frame_static.h')
84
+ if get_option('unstable')
85
+ install_headers(lz4_source_root / 'lib/lz4file.h')
86
+ endif
87
+ endif