-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add xz decoder #14434
Add xz decoder #14434
Conversation
LZMA is useful independently from xz, is it not? |
Kinda. The original LZMA (aka LZMA1) is also used by lzip (and probably other things) while LZMA2 was developed solely for xz. Or at least, that's my understanding. From the lzma-rs code, it seems there's some overlap in decoding LZMA1 and LZMA2, but the LZMA format is poorly documented so tbh that doesn't sound fun to me to investigate lol. Should I delete |
I am perfectly content with xz-specific lzma code, at the very least for the time being. P.S. can you please add 4 more lines to your diff? (just kidding) 😜 |
Nice work. I added a commit to your branch, making some executive decisions to better fit this implementation into the standard library API (as well as a breaking change to gzip to go with it). I hope you will find them to your liking. Additionally, I added another commit to the branch, hooking up the new xz implementation into the package manager, enabling fetching of .tar.xz files. So, this PR closes #14300 in addition to #2851. |
* add xz to std.compress * prefer importing std.zig by file name, to reduce reliance on the standard library being a special case. * extract some types from inside generic functions. These types are the same regardless of the generic parameters. * expose some more types in the std.compress.xz namespace. * rename xz.stream to xz.decompress * rename check.Kind to Check * use std.leb for LEB instead of a redundant implementation
This includes a breaking change: std.compress.gzip.GzipStream renamed to std.compress.gzip.Decompress This follows the same naming convention as std.compress.xz so that the stream type can be passed as a comptime parameter.
Looks good! No idea why CI is failing though since the tests are passing on both my macOS and Windows machines |
With your patch that passed the CI checks, it was missing the line in compress.zig to expose xz. So it wasn't actually being tested by the CI at all. Now that the CI is actually running the new code, it found this:
Note the target: It failed on the first big-endian target that is checked by the CI. You can test this target locally on Linux, if you install QEMU:
Follow the advice printed at the end. Example:
or add it to your original invocation:
|
Head branch was pushed to by a user without write access
Initial implementation for #2851
Currently only supports files compressed with a single xz stream and no compression filters other than LZMA2 (which seems to be the most common use case)
File format: https://tukaani.org/xz/xz-file-format.txt (markdown)
LZMA2 code ported from https://github.com/gendx/lzma-rs
Test files from https://github.com/xz-mirror/xz/tree/master/tests/files