From 9a16dd53927ef2012478b6494bafb4475e44f4c9 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Wed, 19 Jun 2024 18:19:15 +0100 Subject: [PATCH] Update to Zig master --- build.zig | 8 +- flake.lock | 183 +++++++++++++++++++++++++++++++++++--- flake.nix | 15 +++- src/integration_tests.zig | 6 +- 4 files changed, 191 insertions(+), 21 deletions(-) diff --git a/build.zig b/build.zig index d85fbe8..e669e12 100644 --- a/build.zig +++ b/build.zig @@ -6,16 +6,16 @@ pub fn build(b: *std.Build) !void { const lib = b.addStaticLibrary(.{ .name = "tomlz", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); b.installArtifact(lib); - _ = b.addModule("tomlz", .{ .root_source_file = .{ .path = "src/main.zig" } }); + _ = b.addModule("tomlz", .{ .root_source_file = b.path("src/main.zig") }); const main_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); @@ -27,7 +27,7 @@ pub fn build(b: *std.Build) !void { const fuzz_exe = b.addExecutable(.{ .name = "fuzz", - .root_source_file = .{ .path = "src/fuzz.zig" }, + .root_source_file = b.path("src/fuzz.zig"), .target = target, }); fuzz_exe.linkLibC(); diff --git a/flake.lock b/flake.lock index 285ac1c..8e620c8 100644 --- a/flake.lock +++ b/flake.lock @@ -32,16 +32,32 @@ "type": "github" } }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -68,13 +84,82 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "zls", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "langref": { + "flake": false, + "locked": { + "narHash": "sha256-O6p2tiKD8ZMhSX+DeA/o5hhAvcPkU2J9lFys/r11peY=", + "type": "file", + "url": "https://raw.githubusercontent.com/ziglang/zig/0fb2015fd3422fc1df364995f9782dfe7255eccd/doc/langref.html.in" + }, + "original": { + "type": "file", + "url": "https://raw.githubusercontent.com/ziglang/zig/0fb2015fd3422fc1df364995f9782dfe7255eccd/doc/langref.html.in" + } + }, "nixpkgs": { "locked": { - "lastModified": 1717681334, - "narHash": "sha256-HlvsMH8BNgdmQCwbBDmWp5/DfkEQYhXZHagJQCgbJU0=", + "lastModified": 1718606988, + "narHash": "sha256-pmjP5ePc1jz+Okona3HxD7AYT0wbrCwm9bXAlj08nDM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "31f40991012489e858517ec20102f033e4653afb", + "rev": "38d3352a65ac9d621b0cd3074d3bef27199ff78f", "type": "github" }, "original": { @@ -89,7 +174,8 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "zig": "zig" + "zig": "zig", + "zls": "zls" } }, "systems": { @@ -122,6 +208,36 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "zig": { "inputs": { "flake-compat": "flake-compat_2", @@ -131,11 +247,11 @@ ] }, "locked": { - "lastModified": 1717719897, - "narHash": "sha256-sUWikeclHJxm4tCURmSF8uWly9FSpWmcfV2EvIhEH7Q=", + "lastModified": 1718798994, + "narHash": "sha256-aEZaj+rFFuLXIE9ohjYFo65t7xKbQ0asrhETNtDGF/0=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "fd30d088a9171c3b865fb9f051460209523203aa", + "rev": "e1a9faa2f863ff1134685b4c0cfdf792ee24d762", "type": "github" }, "original": { @@ -143,6 +259,53 @@ "repo": "zig-overlay", "type": "github" } + }, + "zig-overlay": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "zls", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718539737, + "narHash": "sha256-hvQ900gSqzGnJWMRQwv65TixciIbC44iX0Nh5ENRwCU=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "6eb42ce6f85d247b1aecf854c45d80902821d0ad", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } + }, + "zls": { + "inputs": { + "flake-utils": "flake-utils_3", + "gitignore": "gitignore", + "langref": "langref", + "nixpkgs": [ + "nixpkgs" + ], + "zig-overlay": "zig-overlay" + }, + "locked": { + "lastModified": 1718724404, + "narHash": "sha256-BnXu0u0H74cyVOEneESQoCqMCf9zgSrkSx2QVuYztVY=", + "owner": "zigtools", + "repo": "zls", + "rev": "cfea2d55798418cccdf27b1b1bde0f70bff1b8f2", + "type": "github" + }, + "original": { + "owner": "zigtools", + "repo": "zls", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index dde7dae..98df943 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; + zls = { + url = "github:zigtools/zls"; + inputs.nixpkgs.follows = "nixpkgs"; + }; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; @@ -14,12 +18,15 @@ }; }; - outputs = {self, nixpkgs, flake-utils, flake-compat, zig}: + outputs = {self, nixpkgs, flake-utils, zls, flake-compat, zig}: let overlays = [ (final: prev: { zigpkgs = zig.packages.${prev.system}; }) + (final: prev: { + zlspkgs = zls.packages.${prev.system}; + }) ]; systems = builtins.attrNames zig.packages; in @@ -27,11 +34,11 @@ let pkgs = import nixpkgs { inherit overlays system; }; in - rec { + { devShell = pkgs.mkShell { buildInputs = (with pkgs; [ - zigpkgs."0.12.0" - zls + zigpkgs.master-2024-06-18 + zlspkgs.default bashInteractive gdb lldb diff --git a/src/integration_tests.zig b/src/integration_tests.zig index 7d3f8e6..d39bbcb 100644 --- a/src/integration_tests.zig +++ b/src/integration_tests.zig @@ -228,7 +228,7 @@ fn testValid(dir: *const std.fs.Dir, path: []const u8, basename: []const u8) !bo // standard tests test "invalid" { - var dir = try std.fs.cwd().makeOpenPath("tests/invalid", .{}); + var dir = try std.fs.cwd().makeOpenPath("tests/invalid", .{.iterate = true}); defer dir.close(); var fail = false; @@ -245,7 +245,7 @@ test "invalid" { } test "valid" { - var dir = try std.fs.cwd().makeOpenPath("tests/valid", .{}); + var dir = try std.fs.cwd().makeOpenPath("tests/valid", .{.iterate = true}); defer dir.close(); var fail = false; @@ -265,7 +265,7 @@ test "valid" { // fuzz error case tests test "fuzz" { - var dir = try std.fs.cwd().makeOpenPath("tests/fuzzing", .{}); + var dir = try std.fs.cwd().makeOpenPath("tests/fuzzing", .{.iterate = true}); defer dir.close(); var walker = try dir.walk(testing.allocator);