Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8002e745e0 | |||
| b5742bc282 | |||
| 51305a1a80 | |||
| 1dc85c62fc |
@@ -13,13 +13,13 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
- uses: mlugg/setup-zig@v2
|
- uses: mlugg/setup-zig@v2
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: sudo apt update && sudo apt install -y liblzma-dev liblzo2-dev
|
run: sudo apt update && sudo apt install -y zlib1g-dev libzstd-dev liblzma-dev liblz4-dev liblzo2-dev
|
||||||
- name: Build normal version
|
- name: Build normal version
|
||||||
run: zig build --release=fast -Duse_zig_decomp=true -Dversion=${{ github.ref_name }}
|
run: zig build --release=fast -Dversion=${{ github.ref_name }}
|
||||||
- name: Move zig build out
|
- name: Move normal build out
|
||||||
run: mv zig-out/bin/unsquashfs ./unsquashfs-x86_64-zig-libs
|
run: mv zig-out/bin/unsquashfs ./unsquashfs-x86_64-zig-libs
|
||||||
- name: Rebuild with C libraries
|
- name: Rebuild with C libraries
|
||||||
run: zig build --release=fast -Dversion="${{ github.ref_name }}"
|
run: zig build --release=fast -Duse_c_libs=true -Dversion="${{ github.ref_name }}"
|
||||||
- name: Move C build out
|
- name: Move C build out
|
||||||
run: mv zig-out/bin/unsquashfs ./unsquashfs-x86_64-c-libs
|
run: mv zig-out/bin/unsquashfs ./unsquashfs-x86_64-c-libs
|
||||||
- name: Release
|
- name: Release
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "extern/zstd"]
|
||||||
|
path = extern/zstd
|
||||||
|
url = https://github.com/facebook/zstd
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const Compile = std.Build.Step.Compile;
|
||||||
|
const ResolvedTarget = std.Build.ResolvedTarget;
|
||||||
|
const OptimizeMode = std.builtin.OptimizeMode;
|
||||||
|
const Module = std.Build.Module;
|
||||||
|
|
||||||
pub fn build(b: *std.Build) !void {
|
pub fn build(b: *std.Build) !void {
|
||||||
const use_zig_decomp = b.option(bool, "use_zig_decomp", "Use zig standard library for decompression.") orelse false;
|
const use_zig_decomp = b.option(bool, "use_zig_decomp", "Use Zig standard library for decompression instead of C libraries.") orelse false;
|
||||||
const allow_lzo = b.option(bool, "allow_lzo", "Compile with lzo support") orelse false;
|
const allow_lzo = b.option(bool, "allow_lzo", "Compile with lzo support") orelse false;
|
||||||
const debug = b.option(bool, "debug", "Enable options to make debugging easier.") orelse false;
|
const debug = b.option(bool, "debug", "Enable options to make debugging easier.");
|
||||||
const version_string_option = b.option([]const u8, "version", "Version of the library/binary");
|
const version_string_option = b.option([]const u8, "version", "Version of the library/binary");
|
||||||
|
|
||||||
const zig_squashfs_options = b.addOptions();
|
const zig_squashfs_options = b.addOptions();
|
||||||
@@ -22,19 +26,19 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.strip = if (debug == true) false else null,
|
.strip = if (debug == true) false else null,
|
||||||
});
|
});
|
||||||
mod.addOptions("config", zig_squashfs_options);
|
mod.addOptions("config", zig_squashfs_options);
|
||||||
|
|
||||||
if (!use_zig_decomp) {
|
if (!use_zig_decomp) {
|
||||||
var zlib_ng = b.dependency("zlib_ng", .{});
|
var zlib = b.dependency("zlib_ng", .{});
|
||||||
mod.linkLibrary(zlib_ng.artifact("zng"));
|
mod.linkLibrary(zlib.artifact("zng"));
|
||||||
|
|
||||||
mod.linkSystemLibrary("lzma", .{ .preferred_link_mode = .static });
|
mod.linkSystemLibrary("lzma", .{ .preferred_link_mode = .static });
|
||||||
if (allow_lzo == true)
|
if (allow_lzo == true)
|
||||||
mod.linkSystemLibrary("minilzo", .{ .preferred_link_mode = .static });
|
mod.linkSystemLibrary("minilzo", .{ .preferred_link_mode = .static });
|
||||||
|
mod.linkSystemLibrary("lz4", .{ .preferred_link_mode = .static });
|
||||||
|
|
||||||
var lz4 = b.dependency("lz4", .{});
|
const zstd_lib = buildZstdLibrary(b, target, optimize, debug);
|
||||||
mod.linkLibrary(lz4.artifact("lz4"));
|
mod.linkLibrary(zstd_lib);
|
||||||
|
mod.addIncludePath(b.path("extern/zstd/lib/"));
|
||||||
var zstd = b.dependency("zstd", .{});
|
|
||||||
mod.linkLibrary(zstd.artifact("zstd"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var version = version_string_option orelse "0.0.0-testing";
|
var version = version_string_option orelse "0.0.0-testing";
|
||||||
@@ -99,3 +103,61 @@ pub fn build(b: *std.Build) !void {
|
|||||||
check.dependOn(&lib_check.step);
|
check.dependOn(&lib_check.step);
|
||||||
check.dependOn(&exe_check.step);
|
check.dependOn(&exe_check.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn buildZstdLibrary(b: *std.Build, target: ResolvedTarget, optimize: OptimizeMode, debug: ?bool) *Compile {
|
||||||
|
var zstd_lib = b.addLibrary(.{
|
||||||
|
.name = "zstd",
|
||||||
|
.linkage = .static,
|
||||||
|
.root_module = b.createModule(.{
|
||||||
|
.target = target,
|
||||||
|
.optimize = if (debug == true) .Debug else optimize,
|
||||||
|
.link_libc = true,
|
||||||
|
}),
|
||||||
|
.use_llvm = debug,
|
||||||
|
});
|
||||||
|
zstd_lib.root_module.addCSourceFiles(.{
|
||||||
|
.root = b.path("extern/zstd/lib/"),
|
||||||
|
.files = &.{
|
||||||
|
"common/debug.c",
|
||||||
|
"common/entropy_common.c",
|
||||||
|
"common/error_private.c",
|
||||||
|
"common/fse_decompress.c",
|
||||||
|
"common/pool.c",
|
||||||
|
"common/threading.c",
|
||||||
|
"common/xxhash.c",
|
||||||
|
"common/zstd_common.c",
|
||||||
|
"compress/fse_compress.c",
|
||||||
|
"compress/hist.c",
|
||||||
|
"compress/huf_compress.c",
|
||||||
|
"compress/zstd_compress.c",
|
||||||
|
"compress/zstd_compress_literals.c",
|
||||||
|
"compress/zstd_compress_sequences.c",
|
||||||
|
"compress/zstd_compress_superblock.c",
|
||||||
|
"compress/zstd_double_fast.c",
|
||||||
|
"compress/zstd_fast.c",
|
||||||
|
"compress/zstd_lazy.c",
|
||||||
|
"compress/zstd_ldm.c",
|
||||||
|
"compress/zstdmt_compress.c",
|
||||||
|
"compress/zstd_opt.c",
|
||||||
|
"compress/zstd_preSplit.c",
|
||||||
|
"decompress/huf_decompress.c",
|
||||||
|
"decompress/zstd_ddict.c",
|
||||||
|
"decompress/zstd_decompress_block.c",
|
||||||
|
"decompress/zstd_decompress.c",
|
||||||
|
"dictBuilder/cover.c",
|
||||||
|
"dictBuilder/divsufsort.c",
|
||||||
|
"dictBuilder/fastcover.c",
|
||||||
|
"dictBuilder/zdict.c",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
zstd_lib.root_module.addCSourceFiles(.{
|
||||||
|
.root = b.path("extern/zstd/lib/decompress"),
|
||||||
|
.files = &.{"huf_decompress_amd64.S"},
|
||||||
|
});
|
||||||
|
zstd_lib.installHeadersDirectory(b.path("extern/zstd/lib/"), &.{}, .{});
|
||||||
|
zstd_lib.installHeadersDirectory(b.path("extern/zstd/lib/common/"), &.{}, .{});
|
||||||
|
zstd_lib.installHeadersDirectory(b.path("extern/zstd/lib/compress/"), &.{}, .{});
|
||||||
|
zstd_lib.installHeadersDirectory(b.path("extern/zstd/lib/dictBuilder/"), &.{}, .{});
|
||||||
|
zstd_lib.installHeadersDirectory(b.path("extern/zstd/lib/"), &.{}, .{});
|
||||||
|
return zstd_lib;
|
||||||
|
}
|
||||||
|
|||||||
+3
-10
@@ -5,16 +5,9 @@
|
|||||||
.minimum_zig_version = "0.15.2",
|
.minimum_zig_version = "0.15.2",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.zlib_ng = .{
|
.zlib_ng = .{
|
||||||
.url = "git+https://github.com/CalebQ42/zig-zlib-ng#5f2f02dfb28acca2517dacbbd09e9b987f57b133",
|
// .url = "https://github.com/CalebQ42/zig-zlib-ng/archive/refs/tags/2.3.3.tar.gz",
|
||||||
.hash = "zlib_ng-2.3.3-pre1-2HYS4ClFAABW8KlHMyBHtlNKE3V7kCS8wqfxawG7xeaa",
|
// .hash = "zlib_ng-2.3.3-2HYS4Bw_AADjgv7tkrqjjz2fVz5kRTvha8wN9LEcjYNp",
|
||||||
},
|
.path = "../zig-zlib-ng",
|
||||||
.zstd = .{
|
|
||||||
.url = "git+https://github.com/allyourcodebase/zstd.git?ref=1.5.7-1#e1a501be57f42c541e8a5597e4b59a074dfd09a3",
|
|
||||||
.hash = "zstd-1.5.7-1-KEItkAMwAAD6OKY3m0OOmXG7aL-aLUfrDqbP5J5oYapU",
|
|
||||||
},
|
|
||||||
.lz4 = .{
|
|
||||||
.url = "git+https://github.com/allyourcodebase/lz4.git?ref=1.10.0-6#41f52ab227caf9d48cf88c89a4d2946caa12b102",
|
|
||||||
.hash = "lz4-1.10.0-6-ewyzw-4NAAAWDpY4xpiqr4LQhZQAC0x_rGnW2iPh6jk2",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|||||||
+1
Submodule extern/zstd added at f8745da6ff
+1
-1
@@ -18,7 +18,7 @@ const OffsetFile = @import("util/offset_file.zig");
|
|||||||
const XattrTable = @import("xattr.zig");
|
const XattrTable = @import("xattr.zig");
|
||||||
|
|
||||||
const config = if (builtin.is_test) .{
|
const config = if (builtin.is_test) .{
|
||||||
.use_zig_decomp = !builtin.link_libc,
|
.use_zig_decomp = builtin.link_libc != true,
|
||||||
.allow_lzo = false,
|
.allow_lzo = false,
|
||||||
} else @import("config");
|
} else @import("config");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ const Reader = std.Io.Reader;
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
const config = if (builtin.is_test) .{
|
const config = if (builtin.is_test) .{
|
||||||
.use_zig_decomp = !builtin.link_libc,
|
.use_zig_decomp = builtin.link_libc != true,
|
||||||
.allow_lzo = false, // Change once LZO compilation is fixed
|
.allow_lzo = false, // Change once LZO compilation is fixed
|
||||||
} else @import("config");
|
} else @import("config");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user