LZ4 Native Extension

I’ve just released a native extension version of lua-lz4 over on GitHub:

I only have access to a Mac at the moment, so I’d appreciate it if someone on Linux and/or Windows could make sure it works there too.

Installation

You can use defold-lz4 in your own project by adding it as a Defold library dependency. Open your game.project file and in the dependencies field add:

Or point to the ZIP file of a specific release, e.g. https://github.com/JustAPotota/defold-lz4/archive/v1.0.zip.

Usage

Refer to lua-lz4 for documentation. Quick example:

function init(self)
    local s = "LZ4 is a very fast compression and decompression algorithm."
    print("Original: " .. s)

    local compressed = lz4.block_compress(s)
    print("Compressed: " .. compressed)

    local decompressed = lz4.block_decompress_safe(compressed, #s)
    print("Decompressed: " .. decompressed)
end
14 Likes

Release v1.1


  • Added .gitignore
  • Added build status badge to README.md
  • Fixed undeclared identifier on non-Darwin platforms

Add it to your project via https://github.com/JustAPotota/defold-lz4/archive/v1.1.zip

3 Likes

We use this extension, and in the past few days our Github automated testing builds that run on linux have started breaking with the errors below. We didn’t switch Defold version, and we stayed on v1.1 of defold-lz4.
Has there been a change in the extender that could’ve caused this? The change occurred some time between 20th-23rd November.

/defold-lz4/src/lz4.c Line 248: In file included from upload/defold-lz4/src/lz4hc.c:65: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 248 | static unsigned LZ4_NbCommonBytes (register size_t val)

com.defold.extender.ExtenderException: java.io.IOException: clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

2 Likes

Defold updated to Clang 17 which broke the old version of LZ4 that the extension used. I’ve updated everything on the main branch to try and fix it. Let me know if that works for you now and I’ll make a new release.

5 Likes

Thanks, that fixed it.

2 Likes