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-cache
zig-out /zig-cache
/zig-out

View file

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

View file

@ -1,46 +1,15 @@
{ {
"nodes": { "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": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1710146030,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"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",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -66,41 +35,24 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707546158, "lastModified": 1718541509,
"narHash": "sha256-nYYJTpzfPMDxI8mzhQsYjIUX+grorqjKEU9Np6Xwy/0=", "narHash": "sha256-TmC5TxW5WPAfmovDzi1hLe1i4qqND79s9SH9UOKcSvo=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d934204a0f8d9198e1e4515dd6fec76a139c87f0", "rev": "ba06293cdba1c94af9710024abf3b94cf8d76349",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-unstable", "ref": "nixos-unstable-small",
"type": "indirect" "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": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"make-shell": "make-shell", "make-shell": "make-shell",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"zig": "zig"
} }
}, },
"systems": { "systems": {
@ -117,26 +69,6 @@
"repo": "default", "repo": "default",
"type": "github" "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", "root": "root",

View file

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

View file

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