From d2b8135cdbae30cf7d55acaeae02687d93c807af Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 8 Sep 2024 16:29:48 -0600 Subject: [PATCH] Use full LTO, update dependencies & CI --- .github/workflows/build.yaml | 76 +++++++--- Cargo.lock | 270 +++++++++++++++++++---------------- Cargo.toml | 2 +- nod/Cargo.toml | 10 +- nod/src/disc/mod.rs | 19 +++ nod/src/fst.rs | 10 ++ nod/src/io/mod.rs | 2 + nod/src/lib.rs | 17 ++- nod/src/streams.rs | 2 + nodtool/Cargo.toml | 56 ++++---- 10 files changed, 292 insertions(+), 172 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9e1f511..17de80c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,10 +1,15 @@ name: Build -on: [ push, pull_request ] +on: + pull_request: + push: + paths-ignore: + - '*.md' + - 'LICENSE*' + workflow_dispatch: env: BUILD_PROFILE: release-lto - CARGO_BIN_NAME: nodtool CARGO_TARGET_DIR: target jobs: @@ -79,7 +84,9 @@ jobs: run: cargo test --release build: - name: Build + name: Build nodtool + env: + CARGO_BIN_NAME: nodtool strategy: matrix: include: @@ -88,11 +95,11 @@ jobs: name: linux-x86_64 build: zigbuild features: asm -# - platform: ubuntu-latest -# target: i686-unknown-linux-musl -# name: linux-i686 -# build: zigbuild -# features: asm + - platform: ubuntu-latest + target: i686-unknown-linux-musl + name: linux-i686 + build: zigbuild + features: asm - platform: ubuntu-latest target: aarch64-unknown-linux-musl name: linux-aarch64 @@ -103,6 +110,11 @@ jobs: name: linux-armv7l build: zigbuild features: default + - platform: windows-latest + target: i686-pc-windows-msvc + name: windows-x86 + build: build + features: default - platform: windows-latest target: x86_64-pc-windows-msvc name: windows-x86_64 @@ -135,20 +147,20 @@ jobs: sudo apt-get -y install ${{ matrix.packages }} - name: Install cargo-zigbuild if: matrix.build == 'zigbuild' - run: pip install ziglang==0.11.0 cargo-zigbuild==0.18.3 + run: pip install ziglang==0.13.0 cargo-zigbuild==0.19.1 - name: Setup Rust toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Cargo build - run: cargo ${{ matrix.build }} --profile ${{ env.BUILD_PROFILE }} --target ${{ matrix.target }} --bin ${{ env.CARGO_BIN_NAME }} --features ${{ matrix.features }} + run: > + cargo ${{ matrix.build }} --profile ${{ env.BUILD_PROFILE }} --target ${{ matrix.target }} + --bin ${{ env.CARGO_BIN_NAME }} --features ${{ matrix.features }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: ${{ matrix.name }} + name: ${{ env.CARGO_BIN_NAME }}-${{ matrix.name }} path: | - ${{ env.CARGO_TARGET_DIR }}/${{ env.BUILD_PROFILE }}/${{ env.CARGO_BIN_NAME }} - ${{ env.CARGO_TARGET_DIR }}/${{ env.BUILD_PROFILE }}/${{ env.CARGO_BIN_NAME }}.exe ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/${{ env.CARGO_BIN_NAME }} ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/${{ env.CARGO_BIN_NAME }}.exe if-no-files-found: error @@ -159,6 +171,22 @@ jobs: runs-on: ubuntu-latest needs: [ build ] steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check git tag against Cargo version + shell: bash + run: | + set -eou pipefail + tag='${{github.ref}}' + tag="${tag#refs/tags/}" + for file in */Cargo.toml; do + version=$(grep '^version' $file | head -1 | awk -F' = ' '{print $2}' | tr -d '"') + version="v$version" + if [ "$tag" != "$version" ]; then + echo "::error::Git tag doesn't match the Cargo version! ($tag != $version)" + exit 1 + fi + done - name: Download artifacts uses: actions/download-artifact@v4 with: @@ -166,12 +194,26 @@ jobs: - name: Rename artifacts working-directory: artifacts run: | + set -euo pipefail mkdir ../out - for i in */*/$BUILD_PROFILE/$CARGO_BIN_NAME*; do - mv "$i" "../out/$(sed -E "s/([^/]+)\/[^/]+\/$BUILD_PROFILE\/($CARGO_BIN_NAME)/\2-\1/" <<< "$i")" + for dir in */; do + for file in "$dir"*; do + base=$(basename "$file") + name="${base%.*}" + ext="${base##*.}" + if [ "$ext" = "$base" ]; then + ext="" + else + ext=".$ext" + fi + arch="${dir%/}" # remove trailing slash + arch="${arch##"$name-"}" # remove bin name + dst="../out/${name}-${arch}${ext}" + mv "$file" "$dst" + done done ls -R ../out - name: Release - uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981 + uses: softprops/action-gh-release@v2 with: files: out/* diff --git a/Cargo.lock b/Cargo.lock index 913069e..07e3ba9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aes" version = "0.8.4" @@ -21,9 +27,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -57,9 +63,9 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -117,11 +123,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.86" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ + "jobserver", "libc", + "shlex", ] [[package]] @@ -155,9 +163,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -192,9 +200,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crypto-common" @@ -218,15 +226,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "either" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enable-ansi-support" @@ -245,9 +253,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -305,9 +313,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -320,39 +328,48 @@ checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "jobserver" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "liblzma" -version = "0.2.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599133771f99c14ca089a8db3a4565f482ea6eeb66991b262bffc2b72acff69c" +checksum = "a7c45fc6fcf5b527d3cf89c1dee8c327943984b0dc8bfcf6e100473b00969e63" dependencies = [ "liblzma-sys", ] [[package]] name = "liblzma-sys" -version = "0.2.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be9aaba5f9c8f8f615d41570909338b6284fbb1813dc057ecc68563d98a65097" +checksum = "885d379719f1be90c51852451dc658009c1aab2eb867cae8d5eb7f83bfaaca96" dependencies = [ "cc", "libc", @@ -361,9 +378,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "matchers" @@ -387,31 +404,31 @@ dependencies = [ [[package]] name = "md5-asm" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61d33bc4cdfe5c60340e282bbbee0a6e2bc57f0b9279bb3489c5004d12492e5c" +checksum = "d19b8ee7fc7d812058d3b708c7f719efd0713d53854648e4223c6fcae709e2df" dependencies = [ "cc", ] [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "nod" -version = "1.2.0" +version = "1.2.1" dependencies = [ "adler", "aes", @@ -434,7 +451,7 @@ dependencies = [ [[package]] name = "nodtool" -version = "1.2.0" +version = "1.2.1" dependencies = [ "argp", "base16ct", @@ -490,9 +507,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pkg-config" @@ -502,15 +519,15 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -529,9 +546,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" dependencies = [ "memchr", "serde", @@ -539,18 +556,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "rayon" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -568,14 +585,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.5", - "regex-syntax 0.8.2", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -589,13 +606,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.4", ] [[package]] @@ -606,28 +623,28 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.77", ] [[package]] @@ -644,9 +661,9 @@ dependencies = [ [[package]] name = "sha1-asm" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba6947745e7f86be3b8af00b7355857085dbdf8901393c89514510eb61f4e21" +checksum = "286acebaf8b67c1130aedffad26f594eff0c1292389158135327d2e23aed582b" dependencies = [ "cc", ] @@ -660,6 +677,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "size" version = "0.4.1" @@ -668,15 +691,15 @@ checksum = "9fed904c7fb2856d868b92464fc8fa597fce366edea1a9cbfaa8cb5fe080bd6d" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "supports-color" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" +checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" dependencies = [ "is_ci", ] @@ -694,9 +717,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.50" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -705,22 +728,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.77", ] [[package]] @@ -752,7 +775,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.77", ] [[package]] @@ -817,9 +840,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "valuable" @@ -829,9 +852,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "winapi" @@ -881,17 +904,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -902,9 +926,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -914,9 +938,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -926,9 +950,15 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -938,9 +968,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -950,9 +980,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -962,9 +992,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -974,21 +1004,21 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "xxhash-rust" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" +checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive", @@ -996,38 +1026,38 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.77", ] [[package]] name = "zstd" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.1.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.11+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 1c1d8e4..b69c4ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,5 @@ resolver = "2" [profile.release-lto] inherits = "release" -lto = "thin" +lto = "fat" strip = "debuginfo" diff --git a/nod/Cargo.toml b/nod/Cargo.toml index fb5cd6e..54248fc 100644 --- a/nod/Cargo.toml +++ b/nod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nod" -version = "1.2.0" +version = "1.2.1" edition = "2021" rust-version = "1.73.0" authors = ["Luke Street "] @@ -31,11 +31,11 @@ cbc = "0.1" digest = "0.10" dyn-clone = "1.0" encoding_rs = "0.8" -itertools = "0.12" -liblzma = { version = "0.2", features = ["static"], optional = true } +itertools = "0.13" +liblzma = { version = "0.3", features = ["static"], optional = true } log = "0.4" -miniz_oxide = { version = "0.7", optional = true } -rayon = "1.8" +miniz_oxide = { version = "0.8", optional = true } +rayon = "1.10" sha1 = "0.10" thiserror = "1.0" zerocopy = { version = "0.7", features = ["alloc", "derive"] } diff --git a/nod/src/disc/mod.rs b/nod/src/disc/mod.rs index dc85872..341da18 100644 --- a/nod/src/disc/mod.rs +++ b/nod/src/disc/mod.rs @@ -64,9 +64,11 @@ static_assert!(size_of::() == 0x400); impl DiscHeader { /// Game ID as a string. + #[inline] pub fn game_id_str(&self) -> &str { from_utf8(&self.game_id).unwrap_or("[invalid]") } /// Game title as a string. + #[inline] pub fn game_title_str(&self) -> &str { CStr::from_bytes_until_nul(&self.game_title) .ok() @@ -75,9 +77,11 @@ impl DiscHeader { } /// Whether this is a GameCube disc. + #[inline] pub fn is_gamecube(&self) -> bool { self.gcn_magic.get() == 0xC2339F3D } /// Whether this is a Wii disc. + #[inline] pub fn is_wii(&self) -> bool { self.wii_magic.get() == 0x5D1C9EA3 } } @@ -117,6 +121,7 @@ static_assert!(size_of::() == 0x40); impl PartitionHeader { /// Offset within the partition to the main DOL. + #[inline] pub fn dol_offset(&self, is_wii: bool) -> u64 { if is_wii { self.dol_offset.get() as u64 * 4 @@ -126,6 +131,7 @@ impl PartitionHeader { } /// Offset within the partition to the file system table (FST). + #[inline] pub fn fst_offset(&self, is_wii: bool) -> u64 { if is_wii { self.fst_offset.get() as u64 * 4 @@ -135,6 +141,7 @@ impl PartitionHeader { } /// Size of the file system table (FST). + #[inline] pub fn fst_size(&self, is_wii: bool) -> u64 { if is_wii { self.fst_size.get() as u64 * 4 @@ -144,6 +151,7 @@ impl PartitionHeader { } /// Maximum size of the file system table (FST) across multi-disc games. + #[inline] pub fn fst_max_size(&self, is_wii: bool) -> u64 { if is_wii { self.fst_max_size.get() as u64 * 4 @@ -171,6 +179,7 @@ pub struct ApploaderHeader { impl ApploaderHeader { /// Apploader build date as a string. + #[inline] pub fn date_str(&self) -> Option<&str> { CStr::from_bytes_until_nul(&self.date).ok().and_then(|c| c.to_str().ok()) } @@ -222,6 +231,7 @@ pub enum PartitionKind { } impl Display for PartitionKind { + #[inline] fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { Self::Data => write!(f, "Data"), @@ -237,6 +247,7 @@ impl Display for PartitionKind { impl PartitionKind { /// Returns the directory name for the partition kind. + #[inline] pub fn dir_name(&self) -> Cow { match self { Self::Data => Cow::Borrowed("DATA"), @@ -251,6 +262,7 @@ impl PartitionKind { } impl From for PartitionKind { + #[inline] fn from(v: u32) -> Self { match v { 0 => Self::Data, @@ -334,32 +346,39 @@ pub struct PartitionMeta { impl PartitionMeta { /// A view into the disc header. + #[inline] pub fn header(&self) -> &DiscHeader { DiscHeader::ref_from(&self.raw_boot[..size_of::()]).unwrap() } /// A view into the partition header. + #[inline] pub fn partition_header(&self) -> &PartitionHeader { PartitionHeader::ref_from(&self.raw_boot[size_of::()..]).unwrap() } /// A view into the apploader header. + #[inline] pub fn apploader_header(&self) -> &ApploaderHeader { ApploaderHeader::ref_from_prefix(&self.raw_apploader).unwrap() } /// A view into the file system table (FST). + #[inline] pub fn fst(&self) -> Result { Fst::new(&self.raw_fst) } /// A view into the DOL header. + #[inline] pub fn dol_header(&self) -> &DolHeader { DolHeader::ref_from_prefix(&self.raw_dol).unwrap() } /// A view into the ticket. (Wii only) + #[inline] pub fn ticket(&self) -> Option<&Ticket> { self.raw_ticket.as_ref().and_then(|v| Ticket::ref_from(v)) } /// A view into the TMD. (Wii only) + #[inline] pub fn tmd_header(&self) -> Option<&TmdHeader> { self.raw_tmd.as_ref().and_then(|v| TmdHeader::ref_from_prefix(v)) } diff --git a/nod/src/fst.rs b/nod/src/fst.rs index 421d6b6..243dc50 100644 --- a/nod/src/fst.rs +++ b/nod/src/fst.rs @@ -33,6 +33,7 @@ static_assert!(size_of::() == 12); impl Node { /// File system node kind. + #[inline] pub fn kind(&self) -> NodeKind { match self.kind { 0 => NodeKind::File, @@ -42,12 +43,15 @@ impl Node { } /// Whether the node is a file. + #[inline] pub fn is_file(&self) -> bool { self.kind == 0 } /// Whether the node is a directory. + #[inline] pub fn is_dir(&self) -> bool { self.kind == 1 } /// Offset in the string table to the filename. + #[inline] pub fn name_offset(&self) -> u32 { u32::from_be_bytes([0, self.name_offset[0], self.name_offset[1], self.name_offset[2]]) } @@ -55,6 +59,7 @@ impl Node { /// For files, this is the partition offset of the file data. (Wii: >> 2) /// /// For directories, this is the parent node index in the FST. + #[inline] pub fn offset(&self, is_wii: bool) -> u64 { if is_wii && self.kind == 0 { self.offset.get() as u64 * 4 @@ -68,6 +73,7 @@ impl Node { /// For directories, this is the child end index in the FST. /// /// Number of child files and directories recursively is `length - offset`. + #[inline] pub fn length(&self) -> u64 { self.length.get() as u64 } } @@ -81,6 +87,7 @@ pub struct Fst<'a> { impl<'a> Fst<'a> { /// Create a new FST view from a buffer. + #[allow(clippy::missing_inline_in_public_items)] pub fn new(buf: &'a [u8]) -> Result { let Some(root_node) = Node::ref_from_prefix(buf) else { return Err("FST root node not found"); @@ -96,9 +103,11 @@ impl<'a> Fst<'a> { } /// Iterate over the nodes in the FST. + #[inline] pub fn iter(&self) -> FstIter { FstIter { fst: self, idx: 1 } } /// Get the name of a node. + #[allow(clippy::missing_inline_in_public_items)] pub fn get_name(&self, node: &Node) -> Result, String> { let name_buf = self.string_table.get(node.name_offset() as usize..).ok_or_else(|| { format!( @@ -118,6 +127,7 @@ impl<'a> Fst<'a> { } /// Finds a particular file or directory by path. + #[allow(clippy::missing_inline_in_public_items)] pub fn find(&self, path: &str) -> Option<(usize, &Node)> { let mut split = path.trim_matches('/').split('/'); let mut current = split.next()?; diff --git a/nod/src/io/mod.rs b/nod/src/io/mod.rs index 5c1f7aa..a846d89 100644 --- a/nod/src/io/mod.rs +++ b/nod/src/io/mod.rs @@ -46,6 +46,7 @@ pub enum Format { } impl fmt::Display for Format { + #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Format::Iso => write!(f, "ISO"), @@ -81,6 +82,7 @@ pub enum Compression { } impl fmt::Display for Compression { + #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Compression::None => write!(f, "None"), diff --git a/nod/src/lib.rs b/nod/src/lib.rs index b045511..49b230f 100644 --- a/nod/src/lib.rs +++ b/nod/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(missing_docs)] +#![warn(missing_docs, clippy::missing_inline_in_public_items)] //! Library for traversing & reading Nintendo Optical Disc (GameCube and Wii) images. //! //! Originally based on the C++ library [nod](https://github.com/AxioDL/nod), @@ -92,10 +92,12 @@ pub enum Error { } impl From<&str> for Error { + #[inline] fn from(s: &str) -> Error { Error::Other(s.to_string()) } } impl From for Error { + #[inline] fn from(s: String) -> Error { Error::Other(s) } } @@ -109,6 +111,7 @@ pub trait ErrorContext { } impl ErrorContext for std::io::Error { + #[inline] fn context(self, context: impl Into) -> Error { Error::Io(context.into(), self) } } @@ -125,10 +128,12 @@ pub trait ResultContext { impl ResultContext for Result where E: ErrorContext { + #[inline] fn context(self, context: impl Into) -> Result { self.map_err(|e| e.context(context)) } + #[inline] fn with_context(self, f: F) -> Result where F: FnOnce() -> String { self.map_err(|e| e.context(f())) @@ -155,11 +160,13 @@ pub struct Disc { impl Disc { /// Opens a disc image from a file path. + #[inline] pub fn new>(path: P) -> Result { Disc::new_with_options(path, &OpenOptions::default()) } /// Opens a disc image from a file path with custom options. + #[inline] pub fn new_with_options>(path: P, options: &OpenOptions) -> Result { let io = io::block::open(path.as_ref())?; let reader = disc::reader::DiscReader::new(io, options)?; @@ -167,22 +174,27 @@ impl Disc { } /// The disc's primary header. + #[inline] pub fn header(&self) -> &DiscHeader { self.reader.header() } /// Returns extra metadata included in the disc file format, if any. + #[inline] pub fn meta(&self) -> DiscMeta { self.reader.meta() } /// The disc's size in bytes, or an estimate if not stored by the format. + #[inline] pub fn disc_size(&self) -> u64 { self.reader.disc_size() } /// A list of Wii partitions on the disc. /// /// **GameCube**: This will return an empty slice. + #[inline] pub fn partitions(&self) -> &[PartitionInfo] { self.reader.partitions() } /// Opens a decrypted partition read stream for the specified partition index. /// /// **GameCube**: `index` must always be 0. + #[inline] pub fn open_partition(&self, index: usize) -> Result> { self.reader.open_partition(index, &self.options) } @@ -191,15 +203,18 @@ impl Disc { /// the specified kind. /// /// **GameCube**: `kind` must always be [`PartitionKind::Data`]. + #[inline] pub fn open_partition_kind(&self, kind: PartitionKind) -> Result> { self.reader.open_partition_kind(kind, &self.options) } } impl Read for Disc { + #[inline] fn read(&mut self, buf: &mut [u8]) -> std::io::Result { self.reader.read(buf) } } impl Seek for Disc { + #[inline] fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result { self.reader.seek(pos) } } diff --git a/nod/src/streams.rs b/nod/src/streams.rs index 9b6b9a1..ca22ff5 100644 --- a/nod/src/streams.rs +++ b/nod/src/streams.rs @@ -10,6 +10,7 @@ pub trait ReadStream: Read + Seek { /// Creates a windowed read sub-stream with offset and size. /// /// Seeks underlying stream immediately. + #[inline] fn new_window(&mut self, offset: u64, size: u64) -> io::Result { self.seek(SeekFrom::Start(offset))?; Ok(SharedWindowedReadStream { base: self.as_dyn(), begin: offset, end: offset + size }) @@ -22,6 +23,7 @@ pub trait ReadStream: Read + Seek { impl ReadStream for T where T: Read + Seek { + #[inline] fn as_dyn(&mut self) -> &mut dyn ReadStream { self } } diff --git a/nodtool/Cargo.toml b/nodtool/Cargo.toml index 1a0080c..c0bba73 100644 --- a/nodtool/Cargo.toml +++ b/nodtool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nodtool" -version = "1.2.0" +version = "1.2.1" edition = "2021" rust-version = "1.73.0" authors = ["Luke Street "] @@ -20,32 +20,32 @@ asm = ["md-5/asm", "nod/asm", "sha1/asm"] nightly = ["crc32fast/nightly"] [dependencies] -argp = "0.3.0" -base16ct = "0.2.0" -crc32fast = "1.4.2" -digest = "0.10.7" -enable-ansi-support = "0.2.1" -hex = { version = "0.4.3", features = ["serde"] } -indicatif = "0.17.8" -itertools = "0.12.1" -log = "0.4.20" -md-5 = "0.10.6" -nod = { version = "1.2.0", path = "../nod" } -quick-xml = { version = "0.31.0", features = ["serialize"] } -serde = { version = "1.0.197", features = ["derive"] } -sha1 = "0.10.6" -size = "0.4.1" -supports-color = "3.0.0" -tracing = "0.1.40" -tracing-attributes = "0.1.27" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } -xxhash-rust = { version = "0.8.10", features = ["xxh64"] } -zerocopy = { version = "0.7.32", features = ["alloc", "derive"] } -zstd = "0.13.1" +argp = "0.3" +base16ct = "0.2" +crc32fast = "1.4" +digest = "0.10" +enable-ansi-support = "0.2" +hex = { version = "0.4", features = ["serde"] } +indicatif = "0.17" +itertools = "0.13" +log = "0.4" +md-5 = "0.10" +nod = { version = "1.2", path = "../nod" } +quick-xml = { version = "0.36", features = ["serialize"] } +serde = { version = "1.0", features = ["derive"] } +sha1 = "0.10" +size = "0.4" +supports-color = "3.0" +tracing = "0.1" +tracing-attributes = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +xxhash-rust = { version = "0.8", features = ["xxh64"] } +zerocopy = { version = "0.7", features = ["alloc", "derive"] } +zstd = "0.13" [build-dependencies] -hex = { version = "0.4.3", features = ["serde"] } -quick-xml = { version = "0.31.0", features = ["serialize"] } -serde = { version = "1.0.197", features = ["derive"] } -zerocopy = { version = "0.7.32", features = ["alloc", "derive"] } -zstd = "0.13.1" +hex = { version = "0.4", features = ["serde"] } +quick-xml = { version = "0.36", features = ["serialize"] } +serde = { version = "1.0", features = ["derive"] } +zerocopy = { version = "0.7", features = ["alloc", "derive"] } +zstd = "0.13"