diff --git a/.gitignore b/.gitignore index 3639c96..c313b0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # ---> Zig -.zig-cache/ +zig-cache/ zig-out/ build/ build-*/ diff --git a/build.zig b/build.zig deleted file mode 100644 index 8bf641a..0000000 --- a/build.zig +++ /dev/null @@ -1,75 +0,0 @@ -const std = @import("std"); - -pub fn build(b: *std.Build) !void { - const allocator = b.allocator; - - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - - const run_all = b.step("run", "Run all days"); - const test_all = b.step("test", "Test all days"); - const check = b.step("check", "run checks"); - - const utils_mod = b.createModule(.{ .root_source_file = b.path("src/utils/mod.zig") }); - - var dirIt = (try std.fs.cwd().openDir( - "./src/days", - .{ .iterate = true }, - )).iterate(); - - while (try dirIt.next()) |entry| { - if (entry.kind == .directory) {} - // each day entry will have a main.zig - const source_file = try std.fs.path.join(allocator, &.{ "src", "days", entry.name, "main.zig" }); - defer allocator.free(source_file); - //make sure the main.zig exists - _ = std.fs.cwd().openFile(source_file, .{}) catch continue; - - const exe = b.addExecutable(.{ - .name = entry.name, - .root_source_file = b.path(source_file), - .target = target, - .optimize = optimize, - }); - exe.root_module.addImport("utils", utils_mod); - - b.installArtifact(exe); - const install_cmd = b.addInstallArtifact(exe, .{}); - const install_step = b.step( - b.fmt("install_{s}", .{entry.name}), - b.fmt("install {s}", .{entry.name}), - ); - install_step.dependOn(&install_cmd.step); - b.installArtifact(exe); - - const run_cmd = b.addRunArtifact(exe); - const run_step = b.step( - b.fmt("run_{s}", .{entry.name}), - b.fmt("run {s}", .{entry.name}), - ); - run_step.dependOn(&run_cmd.step); - run_all.dependOn(&run_cmd.step); - - const exe_test = b.addTest(.{ - .root_source_file = b.path(source_file), - .target = target, - .optimize = optimize, - }); - const test_cmd = b.addRunArtifact(exe_test); - const test_step = b.step( - b.fmt("test_{s}", .{entry.name}), - b.fmt("test {s}", .{entry.name}), - ); - test_step.dependOn(&test_cmd.step); - test_all.dependOn(&test_cmd.step); - - const exe_check = b.addExecutable(.{ - .name = entry.name, - .root_source_file = b.path(source_file), - .target = target, - .optimize = optimize, - }); - exe_check.root_module.addImport("utils", utils_mod); - check.dependOn(&exe_check.step); - } -} diff --git a/build.zig.zon b/build.zig.zon deleted file mode 100644 index 7f01cca..0000000 --- a/build.zig.zon +++ /dev/null @@ -1,46 +0,0 @@ -.{ - // This is the default name used by packages depending on this one. For - // example, when a user runs `zig fetch --save `, this field is used - // as the key in the `dependencies` table. Although the user can choose a - // different name, most users will stick with this provided value. - // - // It is redundant to include "zig" in this name because it is already - // within the Zig package namespace. - .name = .aoc2024, - - // This is a [Semantic Version](https://semver.org/). - // In a future version of Zig it will be used for package deduplication. - .version = "0.0.1", - - // Together with name, this represents a globally unique package - // identifier. This field is generated by the Zig toolchain when the - // package is first created, and then *never changes*. This allows - // unambiguous detection of one package being an updated version of - // another. - // - // When forking a Zig project, this id should be regenerated (delete the - // field and run `zig build`) if the upstream project is still maintained. - // Otherwise, the fork is *hostile*, attempting to take control over the - // original project's identity. Thus it is recommended to leave the comment - // on the following line intact, so that it shows up in code reviews that - // modify the field. - .fingerprint = 0x25105d4386327470, // Changing this has security and trust implications. - - // Tracks the earliest Zig version that the package considers to be a - // supported use case. - .minimum_zig_version = "0.14.0", - - // Specifies the set of files and directories that are included in this package. - // Only files and directories listed here are included in the `hash` that - // is computed for this package. Only files listed here will remain on disk - // when using the zig package manager. As a rule of thumb, one should list - // files required for compilation plus any license(s). - // Paths are relative to the build root. Use the empty string (`""`) to refer to - // the build root itself. - // A directory listed here means that all files within, recursively, are included. - .paths = .{ - "build.zig", - "build.zig.zon", - "src", - }, -} diff --git a/src/days/template/input.txt b/src/days/template/input.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/days/template/lib.zig b/src/days/template/lib.zig deleted file mode 100644 index 95a0b68..0000000 --- a/src/days/template/lib.zig +++ /dev/null @@ -1 +0,0 @@ -const std = @import("std"); diff --git a/src/days/template/main.zig b/src/days/template/main.zig deleted file mode 100644 index 8c0f96f..0000000 --- a/src/days/template/main.zig +++ /dev/null @@ -1,10 +0,0 @@ -const std = @import("std"); -const part1 = @import("part1.zig"); -const part2 = @import("part2.zig"); -const input = @embedFile("input.txt"); - -pub fn main() !void { - const stdout = std.io.getStdErr().writer(); - try stdout.print("Part1: {d}\n", .{part1.solve(input)}); - try stdout.print("Part2: {d}\n", .{part2.solve(input)}); -} diff --git a/src/days/template/part1.zig b/src/days/template/part1.zig deleted file mode 100644 index 2ded691..0000000 --- a/src/days/template/part1.zig +++ /dev/null @@ -1,14 +0,0 @@ -const lib = @import("lib.zig"); -const std = @import("std"); -const utils = @import("utils"); - -pub fn solve(comptime input: []const u8) i32 { - return input.len; -} - -test "part1 sample" { - const input = - \\0 - ; - try std.testing.expectEqual(solve(input), 1); -} diff --git a/src/days/template/part2.zig b/src/days/template/part2.zig deleted file mode 100644 index 30680d9..0000000 --- a/src/days/template/part2.zig +++ /dev/null @@ -1,14 +0,0 @@ -const lib = @import("lib.zig"); -const std = @import("std"); -const utils = @import("utils"); - -pub fn solve(comptime input: []const u8) i32 { - return input.len; -} - -test "part2 sample" { - const input = - \\0 - ; - try std.testing.expectEqual(solve(input), 1); -} diff --git a/src/utils/mod.zig b/src/utils/mod.zig deleted file mode 100644 index 95a0b68..0000000 --- a/src/utils/mod.zig +++ /dev/null @@ -1 +0,0 @@ -const std = @import("std");