Justfile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 -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. 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)"/*
  101. #----------------#
  102. # binaries #
  103. #----------------#
  104. tar BINARY TARGET:
  105. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  106. zip BINARY TARGET:
  107. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}.zip ./target/{{TARGET}}/release/{{BINARY}}
  108. tar_static BINARY TARGET:
  109. tar czvf ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.tar.gz -C ./target/{{TARGET}}/release/ ./{{BINARY}}
  110. zip_static BINARY TARGET:
  111. zip -j ./target/"bin-$(convco version)"/{{BINARY}}_{{TARGET}}_static.zip ./target/{{TARGET}}/release/{{BINARY}}
  112. binary BINARY TARGET:
  113. rustup target add {{TARGET}}
  114. cross build --release --target {{TARGET}}
  115. just tar {{BINARY}} {{TARGET}}
  116. just zip {{BINARY}} {{TARGET}}
  117. binary_static BINARY TARGET:
  118. rustup target add {{TARGET}}
  119. RUSTFLAGS='-C target-feature=+crt-static' cross build --release --target {{TARGET}}
  120. just tar_static {{BINARY}} {{TARGET}}
  121. just zip_static {{BINARY}} {{TARGET}}
  122. checksum:
  123. @echo "# Checksums"
  124. @echo "## sha256sum"
  125. @echo '```'
  126. @sha256sum ./target/"bin-$(convco version)"/*
  127. @echo '```'
  128. @echo "## md5sum"
  129. @echo '```'
  130. @md5sum ./target/"bin-$(convco version)"/*
  131. @echo '```'
  132. alias c := cross
  133. # Generate release binaries for EZA
  134. #
  135. # usage: cross
  136. @cross:
  137. # Setup Output Directory
  138. mkdir -p ./target/"bin-$(convco version)"
  139. # Install Toolchains/Targets
  140. rustup toolchain install stable
  141. ## Linux
  142. ### x86
  143. just binary eza x86_64-unknown-linux-gnu
  144. # just binary_static eza x86_64-unknown-linux-gnu
  145. just binary eza x86_64-unknown-linux-musl
  146. # just binary_static eza x86_64-unknown-linux-musl
  147. ### aarch
  148. just binary eza aarch64-unknown-linux-gnu
  149. # BUG: just binary_static eza aarch64-unknown-linux-gnu
  150. ### arm
  151. just binary eza arm-unknown-linux-gnueabihf
  152. # just binary_static eza arm-unknown-linux-gnueabihf
  153. ## MacOS
  154. # TODO: just binary eza x86_64-apple-darwin
  155. ## Windows
  156. ### x86
  157. just binary eza.exe x86_64-pc-windows-gnu
  158. # just binary_static eza.exe x86_64-pc-windows-gnu
  159. # TODO: just binary eza.exe x86_64-pc-windows-gnullvm
  160. # TODO: just binary eza.exe x86_64-pc-windows-msvc
  161. # Generate Checksums
  162. # TODO: moved to gh-release just checksum
  163. #---------------------#
  164. # Integration testing #
  165. #---------------------#
  166. alias gen := gen_test_dir
  167. test_dir := "tests/test_dir"
  168. gen_test_dir:
  169. bash devtools/dir-generator.sh {{ test_dir }}
  170. # Runs integration tests in nix sandbox
  171. #
  172. # Required nix, likely won't work on windows.
  173. @itest:
  174. nix build -L ./#trycmd-local
  175. # Runs integration tests in nix sandbox, and dumps outputs.
  176. #
  177. # WARNING: this can cause loss of work
  178. @idump:
  179. rm ./tests/gen/*_nix.stderr -f || echo
  180. rm ./tests/gen/*_nix.stdout -f || echo
  181. rm ./tests/gen/*_unix.stderr -f || echo
  182. rm ./tests/gen/*_unix.stdout -f || echo
  183. rm ./tests/ptests/ptest_*.stderr -f || echo
  184. rm ./tests/ptests/ptest_*.stdout -f || echo
  185. nix build -L ./#trydump
  186. cp ./result/dump/*nix.* ./tests/cmd/
  187. cp ./result/dump/*.std* ./tests/gen/
  188. cp ./result/dump/ptest_*.* ./tests/ptests/
  189. @itest-gen:
  190. nix build -L ./#trycmd