Skip to content

Commit 0ad20d0

Browse files
authored
Merge pull request #4 from nashif/topic/missing_build
add missing kconfig/cmake files
2 parents 5b86fa5 + 5402e54 commit 0ad20d0

3 files changed

Lines changed: 150 additions & 2 deletions

File tree

zephyr/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (c) 2020 Linumiz
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if(CONFIG_LZ4)
5+
set(LZ4_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
6+
7+
zephyr_library()
8+
9+
zephyr_include_directories(${LZ4_DIR}/lib)
10+
11+
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4_HEAPMODE_STACK
12+
LZ4_HEAPMODE=0
13+
)
14+
15+
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
16+
LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION
17+
)
18+
19+
zephyr_library_compile_definitions(
20+
LZ4_MEMORY_USAGE=${CONFIG_LZ4_MEMORY_USAGE}
21+
)
22+
23+
zephyr_library_sources(
24+
${LZ4_DIR}/lib/lz4.c
25+
)
26+
27+
zephyr_library_sources_ifdef(CONFIG_LZ4_HIGH_COMPRESSION_VARIANT
28+
${LZ4_DIR}/lib/lz4hc.c
29+
)
30+
31+
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4HC_HEAPMODE_STACK
32+
LZ4HC_HEAPMODE=0
33+
)
34+
35+
zephyr_library_sources_ifdef(CONFIG_LZ4_XX_HASH
36+
${LZ4_DIR}/lib/xxhash.c
37+
)
38+
39+
zephyr_library_sources_ifdef(CONFIG_LZ4_FRAME_SUPPORT
40+
${LZ4_DIR}/lib/lz4frame.c
41+
)
42+
43+
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4F_HEAPMODE_HEAP
44+
LZ4F_HEAPMODE=1
45+
)
46+
endif()

zephyr/Kconfig

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Copyright (c) 2020 Linumiz
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config ZEPHYR_LZ4_MODULE
5+
bool
6+
7+
menuconfig LZ4
8+
bool "Lz4 data compression and decompression"
9+
help
10+
This option enables lz4 compression & decompression library
11+
support.
12+
if LZ4
13+
14+
config LZ4_MEMORY_USAGE
15+
int "Lz4 memory usage"
16+
range 10 20
17+
default 14
18+
help
19+
Increasing memory usage improves compression ratio, but usually at the
20+
cost of speed, due to cache locality. Memory usage 2^value (10 -> 1KB,
21+
12 -> 4KB, 20 -> 1MB).
22+
23+
config LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
24+
bool "Disable dynamic memory allocation"
25+
help
26+
Disable lz4 functions that use dynamic memory allocation functions.
27+
28+
choice LZ4_HEAPMODE
29+
prompt "How stateless compression functions allocate memory for their hash table"
30+
default LZ4_HEAPMODE_HEAP
31+
32+
config LZ4_HEAPMODE_STACK
33+
bool "in memory stack"
34+
help
35+
Allocate memory from stack (fastest).
36+
37+
config LZ4_HEAPMODE_HEAP
38+
bool "in memory heap"
39+
depends on !LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
40+
help
41+
Allocate memory from heap (requires malloc()).
42+
endchoice
43+
44+
config LZ4_HIGH_COMPRESSION_VARIANT
45+
bool "Lz4 high compression variant"
46+
help
47+
For more compression ratio at the cost of compression speed,
48+
the High Compression variant called lz4hc is available. This variant
49+
also compresses data using the lz4 block format.
50+
51+
if LZ4_HIGH_COMPRESSION_VARIANT
52+
choice LZ4HC_HEAPMODE
53+
prompt "How stateless HC compression functions allocate memory for their workspace"
54+
default LZ4HC_HEAPMODE_HEAP
55+
56+
config LZ4HC_HEAPMODE_STACK
57+
bool "in memory stack"
58+
help
59+
Allocate memory from stack (fastest).
60+
61+
config LZ4HC_HEAPMODE_HEAP
62+
bool "in memory heap"
63+
depends on !LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
64+
help
65+
Allocate memory from heap (requires malloc()).
66+
endchoice
67+
endif
68+
69+
config LZ4_XX_HASH
70+
bool "xxHash hashing algorithm"
71+
help
72+
Build xxHash library included in lz4 sources.
73+
74+
config LZ4_FRAME_SUPPORT
75+
bool "LZ4 frame support"
76+
select LZ4_XX_HASH
77+
select LZ4_HIGH_COMPRESSION_VARIANT
78+
help
79+
In order to produce compressed data compatible with lz4 command line
80+
utility, it's necessary to use the official interoperable frame format.
81+
This format is generated and decoded automatically by the lz4frame library.
82+
Its public API is described in lib/lz4frame.h.
83+
84+
if LZ4_FRAME_SUPPORT
85+
choice LZ4F_HEAPMODE
86+
prompt "Control how LZ4F_compressFrame() allocates the Compression State"
87+
default LZ4F_HEAPMODE_STACK
88+
89+
config LZ4F_HEAPMODE_STACK
90+
bool "in memory stack"
91+
help
92+
Allocate memory from stack (fastest).
93+
94+
config LZ4F_HEAPMODE_HEAP
95+
bool "in memory heap"
96+
depends on !LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
97+
help
98+
Allocate memory from heap (requires malloc()).
99+
endchoice
100+
endif
101+
102+
endif

zephyr/module.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: lz4
22
build:
3-
cmake-ext: True
4-
kconfig-ext: True
3+
cmake: zephyr/
4+
kconfig: zephyr/Kconfig

0 commit comments

Comments
 (0)