extlz4 0.3.4 → 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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +21 -3
  4. data/contrib/lz4/CODING_STYLE +57 -0
  5. data/contrib/lz4/LICENSE +1 -1
  6. data/contrib/lz4/Makefile.inc +17 -15
  7. data/contrib/lz4/NEWS +25 -0
  8. data/contrib/lz4/README.md +16 -5
  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/VS2022/datagen/datagen.vcxproj +7 -3
  19. data/contrib/lz4/build/{VS2017 → VS2022}/lz4/lz4.vcxproj +21 -7
  20. data/contrib/lz4/build/VS2022/lz4.sln +5 -2
  21. data/contrib/lz4/build/cmake/CMakeLists.txt +95 -100
  22. data/contrib/lz4/build/meson/GetLz4LibraryVersion.py +39 -0
  23. data/contrib/lz4/build/meson/README.md +34 -0
  24. data/contrib/lz4/build/meson/meson/contrib/gen_manual/meson.build +42 -0
  25. data/contrib/lz4/build/meson/meson/contrib/meson.build +11 -0
  26. data/contrib/lz4/build/meson/meson/examples/meson.build +32 -0
  27. data/contrib/lz4/build/meson/meson/lib/meson.build +87 -0
  28. data/contrib/lz4/build/meson/meson/meson.build +135 -0
  29. data/contrib/lz4/build/meson/meson/ossfuzz/meson.build +35 -0
  30. data/contrib/lz4/build/meson/meson/programs/meson.build +91 -0
  31. data/contrib/lz4/build/meson/meson/tests/meson.build +162 -0
  32. data/contrib/lz4/build/meson/meson.build +31 -0
  33. data/contrib/lz4/build/meson/meson_options.txt +44 -0
  34. data/contrib/lz4/build/visual/README.md +5 -0
  35. data/contrib/lz4/build/visual/generate_solution.cmd +55 -0
  36. data/contrib/lz4/build/visual/generate_vs2015.cmd +3 -0
  37. data/contrib/lz4/build/visual/generate_vs2017.cmd +3 -0
  38. data/contrib/lz4/build/visual/generate_vs2019.cmd +3 -0
  39. data/contrib/lz4/build/visual/generate_vs2022.cmd +3 -0
  40. data/contrib/lz4/lib/README.md +25 -1
  41. data/contrib/lz4/lib/lz4.c +206 -99
  42. data/contrib/lz4/lib/lz4.h +111 -69
  43. data/contrib/lz4/lib/lz4file.c +111 -81
  44. data/contrib/lz4/lib/lz4file.h +2 -2
  45. data/contrib/lz4/lib/lz4frame.c +179 -121
  46. data/contrib/lz4/lib/lz4frame.h +162 -103
  47. data/contrib/lz4/lib/lz4hc.c +943 -382
  48. data/contrib/lz4/lib/lz4hc.h +43 -42
  49. data/contrib/lz4/lib/xxhash.c +21 -21
  50. data/contrib/lz4/ossfuzz/decompress_fuzzer.c +1 -1
  51. data/contrib/lz4/ossfuzz/fuzz_helpers.h +1 -1
  52. data/ext/blockapi.c +11 -11
  53. data/ext/frameapi.c +23 -23
  54. metadata +34 -28
  55. data/contrib/lz4/build/VS2010/datagen/datagen.vcxproj +0 -169
  56. data/contrib/lz4/build/VS2010/frametest/frametest.vcxproj +0 -176
  57. data/contrib/lz4/build/VS2010/fullbench/fullbench.vcxproj +0 -176
  58. data/contrib/lz4/build/VS2010/fullbench-dll/fullbench-dll.vcxproj +0 -180
  59. data/contrib/lz4/build/VS2010/fuzzer/fuzzer.vcxproj +0 -173
  60. data/contrib/lz4/build/VS2010/liblz4/liblz4.vcxproj +0 -175
  61. data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.rc +0 -51
  62. data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.vcxproj +0 -179
  63. data/contrib/lz4/build/VS2010/lz4/lz4.vcxproj +0 -189
  64. data/contrib/lz4/build/VS2010/lz4.sln +0 -98
  65. data/contrib/lz4/build/VS2017/datagen/datagen.vcxproj +0 -173
  66. data/contrib/lz4/build/VS2017/frametest/frametest.vcxproj +0 -180
  67. data/contrib/lz4/build/VS2017/fullbench/fullbench.vcxproj +0 -180
  68. data/contrib/lz4/build/VS2017/fullbench-dll/fullbench-dll.vcxproj +0 -184
  69. data/contrib/lz4/build/VS2017/fuzzer/fuzzer.vcxproj +0 -177
  70. data/contrib/lz4/build/VS2017/liblz4/liblz4.vcxproj +0 -179
  71. data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.rc +0 -51
  72. data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.vcxproj +0 -183
  73. data/contrib/lz4/build/VS2017/lz4/lz4.rc +0 -51
  74. data/contrib/lz4/build/VS2017/lz4.sln +0 -103
  75. /data/contrib/lz4/build/{VS2010 → VS2022}/lz4/lz4.rc +0 -0
@@ -22,32 +22,32 @@
22
22
  <VCProjectVersion>15.0</VCProjectVersion>
23
23
  <ProjectGuid>{60A3115E-B988-41EE-8815-F4D4F253D866}</ProjectGuid>
24
24
  <RootNamespace>lz4</RootNamespace>
25
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
25
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
26
26
  </PropertyGroup>
27
27
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28
28
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29
29
  <ConfigurationType>Application</ConfigurationType>
30
30
  <UseDebugLibraries>true</UseDebugLibraries>
31
- <PlatformToolset>v141</PlatformToolset>
31
+ <PlatformToolset>v143</PlatformToolset>
32
32
  <CharacterSet>Unicode</CharacterSet>
33
33
  </PropertyGroup>
34
34
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35
35
  <ConfigurationType>Application</ConfigurationType>
36
36
  <UseDebugLibraries>false</UseDebugLibraries>
37
- <PlatformToolset>v141</PlatformToolset>
37
+ <PlatformToolset>v143</PlatformToolset>
38
38
  <WholeProgramOptimization>false</WholeProgramOptimization>
39
39
  <CharacterSet>Unicode</CharacterSet>
40
40
  </PropertyGroup>
41
41
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42
42
  <ConfigurationType>Application</ConfigurationType>
43
43
  <UseDebugLibraries>true</UseDebugLibraries>
44
- <PlatformToolset>v141</PlatformToolset>
44
+ <PlatformToolset>v143</PlatformToolset>
45
45
  <CharacterSet>MultiByte</CharacterSet>
46
46
  </PropertyGroup>
47
47
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48
48
  <ConfigurationType>Application</ConfigurationType>
49
49
  <UseDebugLibraries>false</UseDebugLibraries>
50
- <PlatformToolset>v141</PlatformToolset>
50
+ <PlatformToolset>v143</PlatformToolset>
51
51
  <WholeProgramOptimization>true</WholeProgramOptimization>
52
52
  <CharacterSet>MultiByte</CharacterSet>
53
53
  </PropertyGroup>
@@ -105,6 +105,8 @@
105
105
  <SubSystem>Console</SubSystem>
106
106
  <OptimizeReferences>false</OptimizeReferences>
107
107
  <EnableCOMDATFolding>false</EnableCOMDATFolding>
108
+ <AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
109
+ <AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
108
110
  </Link>
109
111
  </ItemDefinitionGroup>
110
112
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -114,6 +116,10 @@
114
116
  <SDLCheck>true</SDLCheck>
115
117
  <ConformanceMode>true</ConformanceMode>
116
118
  </ClCompile>
119
+ <Link>
120
+ <AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
121
+ <AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
122
+ </Link>
117
123
  </ItemDefinitionGroup>
118
124
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
119
125
  <ClCompile>
@@ -130,6 +136,8 @@
130
136
  <OptimizeReferences>true</OptimizeReferences>
131
137
  <GenerateDebugInformation>true</GenerateDebugInformation>
132
138
  <SubSystem>Console</SubSystem>
139
+ <AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
140
+ <AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
133
141
  </Link>
134
142
  </ItemDefinitionGroup>
135
143
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -144,6 +152,8 @@
144
152
  <Link>
145
153
  <EnableCOMDATFolding>true</EnableCOMDATFolding>
146
154
  <OptimizeReferences>true</OptimizeReferences>
155
+ <AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
156
+ <AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
147
157
  </Link>
148
158
  </ItemDefinitionGroup>
149
159
  <ItemGroup>
@@ -152,9 +162,12 @@
152
162
  <ClCompile Include="..\..\..\lib\lz4hc.c" />
153
163
  <ClCompile Include="..\..\..\lib\xxhash.c" />
154
164
  <ClCompile Include="..\..\..\programs\bench.c" />
155
- <ClCompile Include="..\..\..\programs\datagen.c" />
165
+ <ClCompile Include="..\..\..\programs\lorem.c" />
156
166
  <ClCompile Include="..\..\..\programs\lz4cli.c" />
157
167
  <ClCompile Include="..\..\..\programs\lz4io.c" />
168
+ <ClCompile Include="..\..\..\programs\threadpool.c" />
169
+ <ClCompile Include="..\..\..\programs\timefn.c" />
170
+ <ClCompile Include="..\..\..\programs\util.c" />
158
171
  </ItemGroup>
159
172
  <ItemGroup>
160
173
  <ClInclude Include="..\..\..\lib\lz4.h" />
@@ -163,8 +176,9 @@
163
176
  <ClInclude Include="..\..\..\lib\lz4hc.h" />
164
177
  <ClInclude Include="..\..\..\lib\xxhash.h" />
165
178
  <ClInclude Include="..\..\..\programs\bench.h" />
166
- <ClInclude Include="..\..\..\programs\datagen.h" />
179
+ <ClInclude Include="..\..\..\programs\lorem.h" />
167
180
  <ClInclude Include="..\..\..\programs\lz4io.h" />
181
+ <ClInclude Include="..\..\..\programs\util.h" />
168
182
  </ItemGroup>
169
183
  <ItemGroup>
170
184
  <ResourceCompile Include="lz4.rc" />
@@ -1,6 +1,6 @@
1
1
  Microsoft Visual Studio Solution File, Format Version 12.00
2
- # Visual Studio 15
3
- VisualStudioVersion = 15.0.28307.271
2
+ # Visual Studio Version 17
3
+ VisualStudioVersion = 17.6.33712.159
4
4
  MinimumVisualStudioVersion = 10.0.40219.1
5
5
  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4-dll", "liblz4-dll\liblz4-dll.vcxproj", "{9800039D-4AAA-43A4-BB78-FEF6F4836927}"
6
6
  EndProject
@@ -20,6 +20,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-
20
20
  EndProjectSection
21
21
  EndProject
22
22
  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lz4", "lz4\lz4.vcxproj", "{60A3115E-B988-41EE-8815-F4D4F253D866}"
23
+ ProjectSection(ProjectDependencies) = postProject
24
+ {9092C5CC-3E71-41B3-BF68-4A7BDD8A5476} = {9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}
25
+ EndProjectSection
23
26
  EndProject
24
27
  Global
25
28
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -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
- cmake_minimum_required(VERSION 2.8.12)
10
+
11
+ cmake_minimum_required(VERSION 3.5)
14
12
 
15
13
  set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
16
14
 
17
15
  # Parse version information
18
- file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$")
19
- string(REGEX REPLACE "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MAJOR "${LZ4_VERSION_MAJOR}")
20
- file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MINOR REGEX "^#define LZ4_VERSION_MINOR +([0-9]+) +.*$")
21
- string(REGEX REPLACE "^#define LZ4_VERSION_MINOR +([0-9]+) +.*$" "\\1" LZ4_VERSION_MINOR "${LZ4_VERSION_MINOR}")
22
- file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_RELEASE REGEX "^#define LZ4_VERSION_RELEASE +([0-9]+) +.*$")
23
- 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
+
24
26
  set(LZ4_VERSION_STRING "${LZ4_VERSION_MAJOR}.${LZ4_VERSION_MINOR}.${LZ4_VERSION_RELEASE}")
25
27
  mark_as_advanced(LZ4_VERSION_STRING LZ4_VERSION_MAJOR LZ4_VERSION_MINOR LZ4_VERSION_RELEASE)
26
28
 
27
- if("${CMAKE_VERSION}" VERSION_LESS "3.0")
28
- project(LZ4 C)
29
- else()
30
- cmake_policy (SET CMP0048 NEW)
31
- project(LZ4
32
- VERSION ${LZ4_VERSION_STRING}
33
- LANGUAGES C)
34
- endif()
29
+ message(STATUS "Creating build script for LZ4 version: ${LZ4_VERSION_STRING}")
30
+
31
+ project(LZ4 VERSION ${LZ4_VERSION_STRING} LANGUAGES C)
32
+
35
33
 
36
34
  option(LZ4_BUILD_CLI "Build lz4 program" ON)
37
- option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c program with legacy argument support" ON)
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()
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,6 +87,7 @@ 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})
@@ -130,11 +118,23 @@ if(BUILD_STATIC_LIBS)
130
118
  POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB})
131
119
  list(APPEND LZ4_LIBRARIES_BUILT lz4_static)
132
120
  endif()
121
+ # Add unified target.
122
+ add_library(lz4 INTERFACE)
123
+ list(APPEND LZ4_LIBRARIES_BUILT lz4)
124
+ if(BUILD_SHARED_LIBS)
125
+ target_link_libraries(lz4 INTERFACE lz4_shared)
126
+ else()
127
+ target_link_libraries(lz4 INTERFACE lz4_static)
128
+ endif()
133
129
 
130
+ # xxhash namespace
131
+ if(BUILD_SHARED_LIBS)
132
+ target_compile_definitions(lz4_shared PRIVATE
133
+ XXH_NAMESPACE=LZ4_)
134
+ endif()
134
135
  if(BUILD_STATIC_LIBS)
135
- set(LZ4_LINK_LIBRARY lz4_static)
136
- else()
137
- list(APPEND LZ4_CLI_SOURCES ${LZ4_SOURCES})
136
+ target_compile_definitions(lz4_static PRIVATE
137
+ XXH_NAMESPACE=LZ4_)
138
138
  endif()
139
139
 
140
140
  # lz4
@@ -142,55 +142,44 @@ if (LZ4_BUILD_CLI)
142
142
  set(LZ4_PROGRAMS_BUILT lz4cli)
143
143
  add_executable(lz4cli ${LZ4_CLI_SOURCES})
144
144
  set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4)
145
- if (BUILD_STATIC_LIBS)
146
- target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY})
147
- endif()
148
- endif()
149
-
150
- # lz4c
151
- if (LZ4_BUILD_LEGACY_LZ4C)
152
- list(APPEND LZ4_PROGRAMS_BUILT lz4c)
153
- add_executable(lz4c ${LZ4_CLI_SOURCES})
154
- set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS")
155
- if (BUILD_STATIC_LIBS)
156
- target_link_libraries(lz4c ${LZ4_LINK_LIBRARY})
157
- endif()
158
145
  endif()
159
146
 
160
147
  # Extra warning flags
161
- include (CheckCCompilerFlag)
162
- foreach (flag
163
- # GCC-style
164
- -Wall
165
- -Wextra
166
- -Wundef
167
- -Wcast-qual
168
- -Wcast-align
169
- -Wshadow
170
- -Wswitch-enum
171
- -Wdeclaration-after-statement
172
- -Wstrict-prototypes
173
- -Wpointer-arith
174
-
175
- # MSVC-style
176
- /W4)
177
- # Because https://gcc.gnu.org/wiki/FAQ#wnowarning
178
- string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
179
- string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" test_name "CFLAG_${flag_to_test}")
180
-
181
- check_c_compiler_flag("${ADD_COMPILER_FLAGS_PREPEND} ${flag_to_test}" ${test_name})
182
-
183
- if(${test_name})
184
- set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
185
- 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)
165
+
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}")
169
+
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()
186
180
 
187
- unset(test_name)
188
- unset(flag_to_test)
189
- endforeach (flag)
190
181
 
191
182
  if(NOT LZ4_BUNDLED_MODE)
192
- include(GNUInstallDirs)
193
-
194
183
  install(TARGETS ${LZ4_PROGRAMS_BUILT}
195
184
  BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
196
185
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
@@ -201,8 +190,9 @@ if(NOT LZ4_BUNDLED_MODE)
201
190
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
202
191
  install(FILES
203
192
  "${LZ4_LIB_SOURCE_DIR}/lz4.h"
204
- "${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
205
193
  "${LZ4_LIB_SOURCE_DIR}/lz4hc.h"
194
+ "${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
195
+ "${LZ4_LIB_SOURCE_DIR}/lz4file.h"
206
196
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
207
197
  install(FILES "${LZ4_PROG_SOURCE_DIR}/lz4.1"
208
198
  DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
@@ -233,16 +223,21 @@ if(NOT LZ4_BUNDLED_MODE)
233
223
  ${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake
234
224
  DESTINATION ${LZ4_PKG_INSTALLDIR})
235
225
 
236
- # install lz4cat and unlz4 symlinks on *nix
226
+ # Install lz4cat and unlz4 symlinks on Unix systems
237
227
  if(UNIX AND LZ4_BUILD_CLI)
238
- install(CODE "
239
- foreach(f lz4cat unlz4)
240
- set(dest \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/\${f}\")
241
- message(STATUS \"Symlinking: \${dest} -> lz4\")
242
- execute_process(
243
- COMMAND \"${CMAKE_COMMAND}\" -E create_symlink lz4 \"\${dest}\")
244
- endforeach()
245
- ")
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()
246
241
 
247
242
  # create manpage aliases
248
243
  foreach(f lz4cat unlz4)
@@ -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