update for zig 0.13.0

This commit is contained in:
Jeffrey C. Ollie 2024-06-16 12:28:14 -05:00
parent cf5f48d976
commit 262b9a6c5d
Signed by: jeff
GPG key ID: 6F86035A6D97044E
5 changed files with 24 additions and 91 deletions

5
.gitignore vendored
View file

@ -1,2 +1,3 @@
zig-cache
zig-out
/.zig-cache
/zig-cache
/zig-out

View file

@ -6,11 +6,11 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("hidapi", .{
.root_source_file = .{ .path = "src/hidapi.zig" },
.root_source_file = b.path("src/hidapi.zig"),
});
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/hidapi.zig" },
.root_source_file = b.path("src/hidapi.zig"),
.target = target,
.optimize = optimize,
});

View file

@ -1,46 +1,15 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
@ -66,41 +35,24 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1707546158,
"narHash": "sha256-nYYJTpzfPMDxI8mzhQsYjIUX+grorqjKEU9Np6Xwy/0=",
"lastModified": 1718541509,
"narHash": "sha256-TmC5TxW5WPAfmovDzi1hLe1i4qqND79s9SH9UOKcSvo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d934204a0f8d9198e1e4515dd6fec76a139c87f0",
"rev": "ba06293cdba1c94af9710024abf3b94cf8d76349",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"ref": "nixos-unstable-small",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1702350026,
"narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9463103069725474698139ab10f17a9d125da859",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"make-shell": "make-shell",
"nixpkgs": "nixpkgs",
"zig": "zig"
"nixpkgs": "nixpkgs"
}
},
"systems": {
@ -117,26 +69,6 @@
"repo": "default",
"type": "github"
}
},
"zig": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1707611073,
"narHash": "sha256-sMsxVKXP5TLcaVMNlRZ7KlDsYGwDdJAMtY0DKmb+7fQ=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "aa4edff6f53e64443ca77e8d9ffe866f29e5b3d4",
"type": "github"
},
"original": {
"owner": "mitchellh",
"repo": "zig-overlay",
"type": "github"
}
}
},
"root": "root",

View file

@ -1,9 +1,9 @@
{
description = "zig-usbnhid";
description = "zig-hidapi";
inputs = {
nixpkgs = {
url = "nixpkgs/nixos-unstable";
url = "nixpkgs/nixos-unstable-small";
};
flake-utils = {
url = "github:numtide/flake-utils";
@ -11,9 +11,9 @@
make-shell = {
url = "github:ursi/nix-make-shell";
};
zig = {
url = "github:mitchellh/zig-overlay";
};
# zig = {
# url = "github:mitchellh/zig-overlay";
# };
# zls = {
# url = "github:zigtools/zls";
# inputs.nixpkgs.follows = "nixpkgs";
@ -23,7 +23,6 @@
};
outputs = {
self,
nixpkgs,
flake-utils,
...
@ -35,9 +34,9 @@
# }
# )
];
systems = builtins.attrNames inputs.zig.packages;
# systems = builtins.attrNames inputs.zig.packages;
in
flake-utils.lib.eachSystem systems (
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit overlays system;
@ -46,7 +45,8 @@
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.hidapi
inputs.zig.packages.${system}.master
pkgs.zig_0_13
# inputs.zig.packages.${system}.master
# inputs.zls.packages.${system}.zls
];
buildInputs = [

View file

@ -298,7 +298,7 @@ pub const Device = struct {
var buffer: [128]hidapi.wchar_t = undefined;
const result = hidapi.hid_get_manufacturer_string(self.device, &buffer, buffer.len);
if (result < 0) return error.HIDApiError;
return try from_wchar_alloc(alloc, &buffer);
return (try from_wchar_alloc(alloc, &buffer)) orelse return error.HIDApiError;
}
/// Get The Product String from a HID device.
@ -306,7 +306,7 @@ pub const Device = struct {
var buffer: [128]hidapi.wchar_t = undefined;
const result = hidapi.hid_get_product_string(self.device, &buffer, buffer.len);
if (result < 0) return error.HIDApiError;
return try from_wchar_alloc(alloc, &buffer);
return (try from_wchar_alloc(alloc, &buffer)) orelse return error.HIDApiError;
}
/// Get The Serial Number String from a HID device.