Skip to content

Commit 7facd33

Browse files
committed
Initial commit
0 parents  commit 7facd33

File tree

6 files changed

+190
-0
lines changed

6 files changed

+190
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
zig-version: [master]
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
include:
20+
- zig-version: "0.14.0"
21+
os: ubuntu-latest
22+
runs-on: ${{ matrix.os }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Zig
28+
uses: mlugg/setup-zig@v1
29+
with:
30+
version: ${{ matrix.zig-version }}
31+
32+
- name: Check Formatting
33+
run: zig fmt --ast-check --check .
34+
35+
- name: Build
36+
run: zig build --summary all

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (Expat)
2+
3+
Copyright (c) contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

LICENSE-BZIP2

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--------------------------------------------------------------------------
2+
3+
This program, "bzip2", the associated library "libbzip2", and all
4+
documentation, are copyright (C) 1996-2010 Julian R Seward. All
5+
rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions
9+
are met:
10+
11+
1. Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
14+
2. The origin of this software must not be misrepresented; you must
15+
not claim that you wrote the original software. If you use this
16+
software in a product, an acknowledgment in the product
17+
documentation would be appreciated but is not required.
18+
19+
3. Altered source versions must be plainly marked as such, and must
20+
not be misrepresented as being the original software.
21+
22+
4. The name of the author may not be used to endorse or promote
23+
products derived from this software without specific prior written
24+
permission.
25+
26+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
27+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
30+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
38+
Julian Seward, [email protected]
39+
bzip2/libbzip2 version 1.1.0 of 6 September 2010
40+
41+
--------------------------------------------------------------------------

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[![CI](https://github.com/allyourcodebase/bzip2/actions/workflows/ci.yaml/badge.svg)](https://github.com/allyourcodebase/zstd/actions)
2+
3+
# bzip
4+
5+
This is [bzip](ttps://github.com/libarchive/bzip2), packaged for [Zig](https://ziglang.org/).
6+
7+
## Installation
8+
9+
First, update your `build.zig.zon`:
10+
11+
```
12+
# Initialize a `zig build` project if you haven't already
13+
zig init
14+
zig fetch --save git+https://github.com/allyourcodebase/bzip.git#1.0.8
15+
```
16+
17+
You can then import `zstd` in your `build.zig` with:
18+
19+
```zig
20+
const bzip_dependency = b.dependency("bzip", .{
21+
.target = target,
22+
.optimize = optimize,
23+
});
24+
your_exe.linkLibrary(bzip_dependency.artifact("bz"));
25+
```
26+

build.zig

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
const optimize = b.standardOptimizeOption(.{});
6+
7+
const upstream = b.dependency("upstream", .{});
8+
9+
const bz2_mod = b.createModule(.{
10+
.target = target,
11+
.optimize = optimize,
12+
});
13+
bz2_mod.link_libc = true;
14+
15+
bz2_mod.addCSourceFiles(.{
16+
.root = upstream.path("."),
17+
.files = &.{
18+
"blocksort.c",
19+
"huffman.c",
20+
"crctable.c",
21+
"randtable.c",
22+
"compress.c",
23+
"decompress.c",
24+
"bzlib.c",
25+
},
26+
});
27+
28+
const bz = b.addLibrary(.{
29+
.linkage = .static,
30+
.name = "bz",
31+
.root_module = bz2_mod,
32+
});
33+
bz.installHeader(upstream.path("bzlib.h"), "bzlib.h");
34+
35+
b.installArtifact(bz);
36+
37+
const bzip2_mod = b.createModule(.{
38+
.target = target,
39+
.optimize = optimize,
40+
});
41+
bzip2_mod.link_libc = true;
42+
bzip2_mod.addCSourceFile(.{ .file = upstream.path("bzip2.c") });
43+
bzip2_mod.linkLibrary(bz);
44+
45+
const bzip2_exe = b.addExecutable(.{
46+
.name = "bzip2",
47+
.root_module = bzip2_mod,
48+
});
49+
b.installArtifact(bzip2_exe);
50+
}

build.zig.zon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.{
2+
.name = .bzip2_zig,
3+
.version = "1.0.8",
4+
.fingerprint = 0xca0009a2c7703b81,
5+
.minimum_zig_version = "0.14.1",
6+
.dependencies = .{
7+
.upstream = .{
8+
.url = "git+https://github.com/libarchive/bzip2#bzip2-1.0.8",
9+
.hash = "N-V-__8AANChDwAITDmkzIqB-9m_iaOXSquhghM2-AqDFcX8",
10+
},
11+
},
12+
.paths = .{
13+
"build.zig",
14+
"build.zig.zon",
15+
},
16+
}

0 commit comments

Comments
 (0)