update to zig 0.11.0-dev.2157+f56f3c582

This commit is contained in:
Emil Lerch 2023-03-19 10:54:51 -07:00
parent aed0280d69
commit b8e4accccf
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
4 changed files with 36 additions and 24 deletions

View File

@ -14,9 +14,10 @@ pub fn build(b: *std.build.Builder) void {
// for restricting supported target set are available. // for restricting supported target set are available.
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select // Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
const mode = b.standardReleaseOptions(); // set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
// Dependency based on the package manager MVP: // Dependency based on the package manager MVP:
// https://github.com/ziglang/zig/pull/14265 // https://github.com/ziglang/zig/pull/14265
@ -24,13 +25,20 @@ pub fn build(b: *std.build.Builder) void {
const im_dep = b.dependency("ImageMagick", .{}); const im_dep = b.dependency("ImageMagick", .{});
const z_dep = b.dependency("libz", .{}); const z_dep = b.dependency("libz", .{});
const i2cdriver = b.addStaticLibrary("i2cdriver", null); const i2cdriver = b.addStaticLibrary(.{
.name = "i2cdriver",
.target = target,
.optimize = optimize,
});
i2cdriver.addCSourceFile("lib/i2cdriver/i2cdriver.c", &[_][]const u8{ "-Wall", "-Wpointer-sign", "-Werror" }); i2cdriver.addCSourceFile("lib/i2cdriver/i2cdriver.c", &[_][]const u8{ "-Wall", "-Wpointer-sign", "-Werror" });
i2cdriver.linkLibC(); i2cdriver.linkLibC();
const exe = b.addExecutable("i2c", "src/main.zig"); const exe = b.addExecutable(.{
exe.setTarget(target); .name = "i2c",
exe.setBuildMode(mode); .root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
exe.linkLibrary(im_dep.artifact("MagickWand")); exe.linkLibrary(im_dep.artifact("MagickWand"));
exe.linkLibrary(z_dep.artifact("z")); exe.linkLibrary(z_dep.artifact("z"));
exe.linkLibrary(i2cdriver); exe.linkLibrary(i2cdriver);
@ -46,9 +54,11 @@ pub fn build(b: *std.build.Builder) void {
const run_step = b.step("run", "Run the app"); const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step); run_step.dependOn(&run_cmd.step);
const exe_tests = b.addTest("src/main.zig"); const exe_tests = b.addTest(.{
exe_tests.setTarget(target); .root_source_file = .{ .path = "src/main.zig" },
exe_tests.setBuildMode(mode); .target = target,
.optimize = optimize,
});
const test_step = b.step("test", "Run unit tests"); const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&exe_tests.step); test_step.dependOn(&exe_tests.step);

View File

@ -1,13 +0,0 @@
[package]
name=i2c
version=0.0.1
[dependency]
name=ImageMagick
url=https://github.com/elerch/ImageMagick/archive/31ce8a2ada73c78f389554d059943beb01288157.tar.gz
hash=c277d15642d73d4c5365cc64c1322569029302d91786471b84a0fc42c5f35d6f
[dependency]
name=libz
url=https://github.com/andrewrk/libz/archive/0c407ce05693fef54b909fee9d0c17ad28f7190b.tar.gz
hash=a09f23166f264f4ec7a82b81e9e7ce62bf36a13f86e12afb1fce1211d90f0d88

15
build.zig.zon Normal file
View File

@ -0,0 +1,15 @@
.{
.name = "i2c",
.version = "0.0.1",
.dependencies = .{
.ImageMagick = .{
.url = "https://github.com/elerch/ImageMagick/archive/0c78c43ba348fe2d764593b074b4f53d087a3a26.tar.gz",
.hash = "12208162dcc0b1f2e5fb6376136fe5266b2b493a38ca8f30eff94b735f7da6ada462",
},
.libz = .{
.url="https://github.com/andrewrk/libz/archive/9e71b746b83d2b5bf5eb247663eb65a52cf0f68f.tar.gz",
.hash = "12204ea3490e5bdf379f56aa11784d906aed6d4c553c724fa5427169915f2cf4a651",
},
},
}

View File

@ -129,7 +129,7 @@ fn sendPixelsThroughI2CDriver(pixels: []const u8, file: [*:0]const u8, device_id
fn packPixelsToDeviceFormat(pixels: []const u8, packed_pixels: []u8) void { fn packPixelsToDeviceFormat(pixels: []const u8, packed_pixels: []u8) void {
// Each u8 in pixels is a single bit. We need to pack these bits // Each u8 in pixels is a single bit. We need to pack these bits
for (packed_pixels) |*b, i| { for (packed_pixels, 0..) |*b, i| {
const column = i % WIDTH; const column = i % WIDTH;
const page = i / WIDTH; const page = i / WIDTH;