Justfile 6.9 KB

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