diff --git a/.config/hakari.toml b/.config/hakari.toml new file mode 100644 index 0000000..e7d47f1 --- /dev/null +++ b/.config/hakari.toml @@ -0,0 +1,27 @@ +# This file contains settings for `cargo hakari`. +# See https://docs.rs/cargo-hakari/latest/cargo_hakari/config for a full list of options. + +hakari-package = "advent-hack" + +# Format version for hakari's output. Version 4 requires cargo-hakari 0.9.22 or above. +dep-format-version = "4" + +# Setting workspace.resolver = "2" or higher in the root Cargo.toml is HIGHLY recommended. +# Hakari works much better with the v2 resolver. (The v2 and v3 resolvers are identical from +# hakari's perspective, so you're welcome to set either.) +# +# For more about the new feature resolver, see: +# https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver +resolver = "2" + +# Add triples corresponding to platforms commonly used by developers here. +# https://doc.rust-lang.org/rustc/platform-support.html +platforms = [ + "x86_64-unknown-linux-gnu", + # "x86_64-apple-darwin", + # "aarch64-apple-darwin", + # "x86_64-pc-windows-msvc", +] + +# Write out exact versions rather than a semver range. (Defaults to false.) +# exact-versions = true diff --git a/Cargo.lock b/Cargo.lock index 57c7f83..115827a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,16 +6,22 @@ version = 4 name = "advent" version = "0.1.0" dependencies = [ + "advent-hack", "advent_core", "macros", "y_2024", "y_2025", ] +[[package]] +name = "advent-hack" +version = "0.1.0" + [[package]] name = "advent_core" version = "0.1.0" dependencies = [ + "advent-hack", "indicatif", "regex", ] @@ -106,9 +112,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -116,14 +122,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.177" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "macros" version = "0.1.0" dependencies = [ + "advent-hack", "advent_core", ] @@ -250,12 +257,15 @@ checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" [[package]] name = "utils" version = "0.1.0" +dependencies = [ + "advent-hack", +] [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -266,9 +276,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -276,9 +286,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", @@ -289,9 +299,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] @@ -325,6 +335,7 @@ dependencies = [ name = "y_2024" version = "0.1.0" dependencies = [ + "advent-hack", "advent_core", "macros", "rayon", @@ -336,6 +347,7 @@ dependencies = [ name = "y_2025" version = "0.1.0" dependencies = [ + "advent-hack", "advent_core", "macros", "rayon", diff --git a/Cargo.toml b/Cargo.toml index 489214e..f7796c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [workspace] - -members = ["advent_core", "macros", "utils", "years/*"] +resolver = "3" +members = ["advent-hack", "advent_core", "macros", "utils", "years/*"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,6 +14,7 @@ y_2025 = { path = "years/2025" } y_2024 = { path = "years/2024" } advent_core = { path = "advent_core" } macros = { path = "macros" } +advent-hack = { version = "0.1", path = "advent-hack" } [[bin]] name = "advent" diff --git a/advent-hack/.gitattributes b/advent-hack/.gitattributes new file mode 100644 index 0000000..3e9dba4 --- /dev/null +++ b/advent-hack/.gitattributes @@ -0,0 +1,4 @@ +# Avoid putting conflict markers in the generated Cargo.toml file, since their presence breaks +# Cargo. +# Also do not check out the file as CRLF on Windows, as that's what hakari needs. +Cargo.toml merge=binary -crlf diff --git a/advent-hack/Cargo.toml b/advent-hack/Cargo.toml new file mode 100644 index 0000000..ead0ab5 --- /dev/null +++ b/advent-hack/Cargo.toml @@ -0,0 +1,17 @@ +# This file is generated by `cargo hakari`. +# To regenerate, run: +# cargo hakari generate + +[package] +name = "advent-hack" +version = "0.1.0" +edition = "2021" +description = "workspace-hack package, managed by hakari" +# You can choose to publish this crate: see https://docs.rs/cargo-hakari/latest/cargo_hakari/publishing. +publish = false + +# The parts of the file between the BEGIN HAKARI SECTION and END HAKARI SECTION comments +# are managed by hakari. + +### BEGIN HAKARI SECTION +### END HAKARI SECTION diff --git a/advent-hack/build.rs b/advent-hack/build.rs new file mode 100644 index 0000000..92518ef --- /dev/null +++ b/advent-hack/build.rs @@ -0,0 +1,2 @@ +// A build script is required for cargo to consider build dependencies. +fn main() {} diff --git a/advent-hack/src/lib.rs b/advent-hack/src/lib.rs new file mode 100644 index 0000000..22489f6 --- /dev/null +++ b/advent-hack/src/lib.rs @@ -0,0 +1 @@ +// This is a stub lib.rs. diff --git a/advent_core/Cargo.toml b/advent_core/Cargo.toml index c41248b..600b526 100644 --- a/advent_core/Cargo.toml +++ b/advent_core/Cargo.toml @@ -8,3 +8,4 @@ edition = "2024" [dependencies] indicatif = "0.18.3" regex = "1.12.2" +advent-hack = { version = "0.1", path = "../advent-hack" } diff --git a/flake.nix b/flake.nix index 345107f..22c4612 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,8 @@ src = lib.fileset.toSource { root = rawSrc; fileset = lib.fileset.unions [ + ./.config/hakari.toml + ./advent-hack ./advent_core ./src ./macros @@ -97,7 +99,13 @@ default = pkgs: (mkCrane pkgs).buildCrate "advent"; }; checks = pkgs: let - inherit (mkCrane pkgs) commonArgs craneLib cargoArtifacts; + inherit + (mkCrane pkgs) + src + commonArgs + craneLib + cargoArtifacts + ; in forAllCrates (name: { name = "clippy-${name}"; @@ -120,10 +128,30 @@ cargoNextestPartitionsExtraArgs = "--no-tests=pass -p ${name}"; } ); - }); + }) + // { + advent-hakari = craneLib.mkCargoDerivation { + inherit src; + pname = "advent-hakari"; + cargoArtifacts = null; + doInstallCargoArtifacts = false; + + buildPhaseCargoCommand = '' + cargo hakari generate --diff # workspace-hack Cargo.toml is up-to-date + cargo hakari manage-deps --dry-run # all workspace crates depend on workspace-hack + cargo hakari verify + ''; + + nativeBuildInputs = [ + pkgs.cargo-hakari + ]; + }; + }; devShell = pkgs: (mkCrane pkgs).craneLib.devShell { checks = self.checks.${pkgs.system}; + + packages = with pkgs; [cargo-hakari]; }; }; } diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 4883d5a..b2644c7 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -10,3 +10,4 @@ proc-macro = true [dependencies] advent_core = { path = "../advent_core" } +advent-hack = { version = "0.1", path = "../advent-hack" } diff --git a/utils/Cargo.toml b/utils/Cargo.toml index bd645df..be84d13 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -2,3 +2,6 @@ name = "utils" version = "0.1.0" edition = "2021" + +[dependencies] +advent-hack = { version = "0.1", path = "../advent-hack" } diff --git a/years/2024/Cargo.toml b/years/2024/Cargo.toml index bac3e2e..fb3e405 100644 --- a/years/2024/Cargo.toml +++ b/years/2024/Cargo.toml @@ -10,3 +10,4 @@ macros = { path = "../../macros" } rayon = "1.11.0" regex = "1.12.2" utils = { path = "../../utils" } +advent-hack = { version = "0.1", path = "../../advent-hack" } diff --git a/years/2025/Cargo.toml b/years/2025/Cargo.toml index e025283..31d4f59 100644 --- a/years/2025/Cargo.toml +++ b/years/2025/Cargo.toml @@ -9,3 +9,4 @@ advent_core = { path = "../../advent_core" } macros = { path = "../../macros" } rayon = "1.11.0" utils = { path = "../../utils" } +advent-hack = { version = "0.1", path = "../../advent-hack" }