justfile 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. # SPDX-FileCopyrightText: 2024 Christina Sørensen
  2. # SPDX-License-Identifier: EUPL-1.2
  3. all: build test
  4. all-release: build-release test-release
  5. genDemo:
  6. fish_prompt="> " fish_history="eza_history" vhs < docs/tapes/demo.tape
  7. nsxiv -a docs/images/demo.gif
  8. #----------#
  9. # building #
  10. #----------#
  11. # compile the exa binary
  12. @build:
  13. cargo build
  14. # compile the exa binary (in release mode)
  15. @build-release:
  16. cargo build --release --verbose
  17. # produce an HTML chart of compilation timings
  18. @build-time:
  19. cargo +nightly clean
  20. cargo +nightly build -Z timings
  21. # check that the exa binary can compile
  22. @check:
  23. cargo check
  24. #---------------#
  25. # running tests #
  26. #---------------#
  27. # run unit tests
  28. @test:
  29. cargo test --workspace -- --quiet
  30. # run unit tests (in release mode)
  31. @test-release:
  32. cargo test --workspace --release --verbose
  33. #-----------------------#
  34. # code quality and misc #
  35. #-----------------------#
  36. # lint the code
  37. @clippy:
  38. touch src/main.rs
  39. cargo clippy
  40. # update dependency versions, and checks for outdated ones
  41. @update-deps:
  42. cargo update
  43. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  44. cargo outdated
  45. # list unused dependencies
  46. @unused-deps:
  47. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  48. cargo +nightly udeps
  49. # check that every combination of feature flags is successful
  50. @check-features:
  51. command -v cargo-hack >/dev/null || (echo "cargo-hack not installed" && exit 1)
  52. cargo hack check --feature-powerset
  53. # print versions of the necessary build tools
  54. @versions:
  55. rustc --version
  56. cargo --version
  57. #---------------#
  58. # documentation #
  59. #---------------#
  60. # build the man pages
  61. @man:
  62. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  63. version=$(awk 'BEGIN { FS = "\"" } ; /^version/ { print $2 ; exit }' Cargo.toml); \
  64. for page in eza.1 eza_colors.5 eza_colors-explanation.5; do \
  65. sed "s/\$version/v${version}/g" "man/${page}.md" | pandoc --standalone -f markdown -t man > "${CARGO_TARGET_DIR:-target}/man/${page}"; \
  66. done;
  67. # build and preview the main man page (eza.1)
  68. @man-1-preview: man
  69. man "${CARGO_TARGET_DIR:-target}/man/eza.1"
  70. # build and preview the colour configuration man page (eza_colors.5)
  71. @man-5-preview: man
  72. man "${CARGO_TARGET_DIR:-target}/man/eza_colors.5"
  73. # build and preview the colour configuration man page (eza_colors.5)
  74. @man-5-explanations-preview: man
  75. man "${CARGO_TARGET_DIR:-target}/man/eza_colors-explanation.5"
  76. #---------------#
  77. # release #
  78. #---------------#
  79. new_version := "$(convco version --bump)"
  80. # If you're not cafkafk and she isn't dead, don't run this!
  81. #
  82. # usage: release major, release minor, release patch
  83. release:
  84. cargo bump "{{new_version}}"
  85. git cliff -c .config/cliff.toml -t "{{new_version}}" > CHANGELOG.md
  86. cargo check
  87. nix build -L ./#clippy
  88. git checkout -b "cafk-release-v{{new_version}}"
  89. git commit -asm "chore: eza v{{new_version}} changelogs, version bump"
  90. git push
  91. @echo "waiting 10 seconds for github to catch up..."
  92. sleep 10
  93. gh pr create --draft --title "chore: release v{{new_version}}" --body "This PR was auto-generated by our lovely just file" --reviewer cafkafk
  94. @echo "Now go review that and come back and run gh-release"
  95. @gh-release:
  96. git tag -d "v{{new_version}}" || echo "tag not found, creating";
  97. git tag --sign -a "v{{new_version}}" -m "auto generated by the justfile for eza v$(convco version)"
  98. just cross
  99. just mangen
  100. just completions
  101. mkdir -p ./target/"release-notes-$(convco version)"
  102. git cliff -c .config/cliff.toml -t "v$(convco version)" --current > ./target/"release-notes-$(convco version)/RELEASE.md"
  103. just checksum >> ./target/"release-notes-$(convco version)/RELEASE.md"
  104. git push origin "v{{new_version}}"
  105. gh release create "v$(convco version)" --target "$(git rev-parse HEAD)" --title "eza v$(convco version)" -d -F ./target/"release-notes-$(convco version)/RELEASE.md" ./target/"bin-$(convco version)"/* ./target/"man-$(convco version).tar.gz" ./target/"completions-$(convco version).tar.gz"
  106. #----------------#
  107. # binaries #
  108. #----------------#
  109. tar BINARY TARGET:
  110. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  111. zip BINARY TARGET:
  112. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  113. tar_static BINARY TARGET:
  114. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  115. zip_static BINARY TARGET:
  116. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.zip ./target/{{TARGET}}/release/{{BINARY}}
  117. binary BINARY TARGET:
  118. rustup target add {{TARGET}}
  119. cross build --release --target {{TARGET}}
  120. just tar {{BINARY}} {{TARGET}}
  121. just zip {{BINARY}} {{TARGET}}
  122. binary_static BINARY TARGET:
  123. rustup target add {{TARGET}}
  124. RUSTFLAGS='-C target-feature=+crt-static' cross build --release --target {{TARGET}}
  125. just tar_static {{BINARY}} {{TARGET}}
  126. just zip_static {{BINARY}} {{TARGET}}
  127. binary_no_libgit BINARY TARGET:
  128. rustup target add {{TARGET}}
  129. cross build --no-default-features --release --target {{TARGET}}
  130. just tar {{BINARY}} {{TARGET}}
  131. just zip {{BINARY}} {{TARGET}}
  132. binary_static_no_libgit BINARY TARGET:
  133. rustup target add {{TARGET}}
  134. RUSTFLAGS='-C target-feature=+crt-static' cross build --no-default-features --release --target {{TARGET}}
  135. just tar_static {{BINARY}} {{TARGET}}
  136. just zip_static {{BINARY}} {{TARGET}}
  137. checksum:
  138. @echo "# Checksums"
  139. @echo "## sha256sum"
  140. @echo '```'
  141. @sha256sum ./target/"bin-$(convco version)"/*
  142. @echo '```'
  143. @echo "## md5sum"
  144. @echo '```'
  145. @md5sum ./target/"bin-$(convco version)"/*
  146. @echo '```'
  147. @echo "## blake3sum"
  148. @echo '```'
  149. @b3sum ./target/"bin-$(convco version)"/*
  150. @echo '```'
  151. alias c := cross
  152. # Generate release binaries for EZA
  153. #
  154. # usage: cross
  155. @cross:
  156. # Setup Output Directory
  157. mkdir -p ./target/"bin-$(convco version)"
  158. # Install Toolchains/Targets
  159. rustup toolchain install stable
  160. ## Linux
  161. ### x86
  162. just binary eza x86_64-unknown-linux-gnu
  163. # just binary_static eza x86_64-unknown-linux-gnu
  164. just binary eza x86_64-unknown-linux-musl
  165. # just binary_static eza x86_64-unknown-linux-musl
  166. ### aarch
  167. just binary_no_libgit eza aarch64-unknown-linux-gnu
  168. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  169. ### arm
  170. just binary_no_libgit eza arm-unknown-linux-gnueabihf
  171. # just binary_static eza arm-unknown-linux-gnueabihf
  172. ## MacOS
  173. # TODO: just binary eza x86_64-apple-darwin
  174. ## Windows
  175. ### x86
  176. just binary eza.exe x86_64-pc-windows-gnu
  177. # just binary_static eza.exe x86_64-pc-windows-gnu
  178. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  179. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  180. # Generate Checksums
  181. # TODO: moved to gh-release just checksum
  182. @mangen:
  183. # Setup Output Directory
  184. mkdir -p ./target/"man-$(convco version)"
  185. pandoc --standalone -f markdown -t man man/eza.1.md > ./target/"man-$(convco version)"/eza.1
  186. pandoc --standalone -f markdown -t man man/eza_colors.5.md > ./target/"man-$(convco version)"/eza_colors.5
  187. pandoc --standalone -f markdown -t man man/eza_colors-explanation.5.md > ./target/"man-$(convco version)"/eza_colors-explanation.5
  188. tar czvf ./target/"man-$(convco version)".tar.gz ./target/"man-$(convco version)"
  189. @completions:
  190. # Setup Output Directory
  191. mkdir -p ./target/"completions-$(convco version)"
  192. cp completions/*/* ./target/"completions-$(convco version)"/
  193. tar czvf ./target/"completions-$(convco version)".tar.gz ./target/"completions-$(convco version)"
  194. #---------------------#
  195. # Integration testing #
  196. #---------------------#
  197. alias gen := gen_test_dir
  198. test_dir := "tests/test_dir"
  199. gen_test_dir:
  200. bash devtools/dir-generator.sh {{ test_dir }}
  201. # Runs integration tests in nix sandbox
  202. #
  203. # Required nix, likely won't work on windows.
  204. @itest:
  205. nix build -L ./#trycmd-local
  206. # Runs integration tests in nix sandbox, and dumps outputs.
  207. #
  208. # WARNING: this can cause loss of work
  209. @idump:
  210. rm ./tests/gen/*_nix.stderr -f || echo
  211. rm ./tests/gen/*_nix.stdout -f || echo
  212. rm ./tests/gen/*_unix.stderr -f || echo
  213. rm ./tests/gen/*_unix.stdout -f || echo
  214. rm ./tests/ptests/ptest_*.stderr -f || echo
  215. rm ./tests/ptests/ptest_*.stdout -f || echo
  216. nix build -L ./#trydump
  217. find result/dump -type f \( -name "*.stdout" -o -name "*.stderr" \) -exec sh -c 'base=$(basename {}); if [ -e "tests/gen/${base%.*}.toml" ]; then cp {} tests/gen/; elif [ -e "tests/cmd/${base%.*}.toml" ]; then cp {} tests/cmd/; elif [ -e "tests/ptests/${base%.*}.toml" ]; then cp {} tests/ptests/; fi' \;
  218. @itest-gen:
  219. nix build -L ./#trycmd
  220. # Fully re-generates the integration tests using powertest
  221. @regen:
  222. which powertest >&- 2>&- || (echo -e "Powertest not installed. Please Clone the repo and run:\n\tcargo install --path . --locked" && exit 1)
  223. echo "WARNING: this will delete all tests in tests/ptest"
  224. sleep 5
  225. echo "Deleting tests/ptests"
  226. rm -rf tests/ptests
  227. echo "Generating tests/ptests"
  228. powertest
  229. nix build -L ./#trydump
  230. find result/dump -type f \( -name "*.stdout" -o -name "*.stderr" \) -exec sh -c 'base=$(basename {}); if [ -e "tests/ptests/${base%.*}.toml" ]; then cp {} tests/ptests/; fi' \;