Justfile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. @echo "## blake3sum"
  134. @echo '```'
  135. @b3sum ./target/"bin-$(convco version)"/*
  136. @echo '```'
  137. alias c := cross
  138. # Generate release binaries for EZA
  139. #
  140. # usage: cross
  141. @cross:
  142. # Setup Output Directory
  143. mkdir -p ./target/"bin-$(convco version)"
  144. # Install Toolchains/Targets
  145. rustup toolchain install stable
  146. ## Linux
  147. ### x86
  148. just binary eza x86_64-unknown-linux-gnu
  149. # just binary_static eza x86_64-unknown-linux-gnu
  150. just binary eza x86_64-unknown-linux-musl
  151. # just binary_static eza x86_64-unknown-linux-musl
  152. ### aarch
  153. just binary eza aarch64-unknown-linux-gnu
  154. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  155. ### arm
  156. just binary eza arm-unknown-linux-gnueabihf
  157. # just binary_static eza arm-unknown-linux-gnueabihf
  158. ## MacOS
  159. # TODO: just binary eza x86_64-apple-darwin
  160. ## Windows
  161. ### x86
  162. just binary eza.exe x86_64-pc-windows-gnu
  163. # just binary_static eza.exe x86_64-pc-windows-gnu
  164. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  165. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  166. # Generate Checksums
  167. # TODO: moved to gh-release just checksum
  168. #---------------------#
  169. # Integration testing #
  170. #---------------------#
  171. alias gen := gen_test_dir
  172. test_dir := "tests/test_dir"
  173. gen_test_dir:
  174. bash devtools/dir-generator.sh {{ test_dir }}
  175. # Runs integration tests in nix sandbox
  176. #
  177. # Required nix, likely won't work on windows.
  178. @itest:
  179. nix build -L ./#trycmd-local
  180. # Runs integration tests in nix sandbox, and dumps outputs.
  181. #
  182. # WARNING: this can cause loss of work
  183. @idump:
  184. rm ./tests/gen/*_nix.stderr -f || echo
  185. rm ./tests/gen/*_nix.stdout -f || echo
  186. rm ./tests/gen/*_unix.stderr -f || echo
  187. rm ./tests/gen/*_unix.stdout -f || echo
  188. rm ./tests/ptests/ptest_*.stderr -f || echo
  189. rm ./tests/ptests/ptest_*.stdout -f || echo
  190. nix build -L ./#trydump
  191. 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' \;
  192. @itest-gen:
  193. nix build -L ./#trycmd