|
| 1 | +bin := "statusline" |
| 2 | +target_bin := "target" / "debug" / bin |
| 3 | +release_bin := "target" / "release" / bin |
| 4 | + |
| 5 | +default: build |
| 6 | + |
| 7 | +gate: fmt lint test |
| 8 | + cargo build --workspace -q |
| 9 | + |
| 10 | +check: |
| 11 | + cargo check --workspace --all-targets |
| 12 | + |
| 13 | +test: |
| 14 | + cargo test --workspace |
| 15 | + |
| 16 | +lint: |
| 17 | + cargo clippy --workspace --all-targets -- -D warnings |
| 18 | + cargo clippy -p statusline --all-targets --features codesigned -- -D warnings |
| 19 | + |
| 20 | +fmt: |
| 21 | + cargo fmt --all |
| 22 | + taplo fmt |
| 23 | + |
| 24 | +compile: |
| 25 | + cargo build --workspace |
| 26 | + |
| 27 | +build: |
| 28 | + cargo build --workspace --release |
| 29 | + |
| 30 | +build-signed developer_name team_id: |
| 31 | + cargo build --workspace --release --features codesigned |
| 32 | + codesign --force --options runtime --sign "Developer ID Application: {{developer_name}} ({{team_id}})" {{release_bin}} |
| 33 | + codesign --verify --verbose {{release_bin}} |
| 34 | + |
| 35 | +install: build |
| 36 | + cp {{release_bin}} "${CARGO_HOME:-$HOME/.cargo}/bin/" |
| 37 | + |
| 38 | +install-signed developer_name team_id: (build-signed developer_name team_id) |
| 39 | + cp {{release_bin}} "${CARGO_HOME:-$HOME/.cargo}/bin/" |
| 40 | + |
| 41 | +dev *ARGS: |
| 42 | + cargo build --quiet |
| 43 | + {{target_bin}} {{ARGS}} |
| 44 | + |
| 45 | +cert-request developer_name: |
| 46 | + openssl req -new -newkey rsa:2048 -nodes \ |
| 47 | + -keyout devid.key -out devid.csr \ |
| 48 | + -subj "/CN={{developer_name}}" |
| 49 | + @echo "" |
| 50 | + @echo "Upload devid.csr at:" |
| 51 | + @echo " https://developer.apple.com/account/resources/certificates/add" |
| 52 | + @echo "Select 'Developer ID Application', then download the .cer file." |
| 53 | + @echo "" |
| 54 | + @echo "Then run: just cert-import <path-to-downloaded.cer>" |
| 55 | + |
| 56 | +cert-import cer: |
| 57 | + openssl x509 -inform DER -in "{{cer}}" -out devid.crt |
| 58 | + openssl pkcs12 -export -out devid.p12 -inkey devid.key -in devid.crt -legacy |
| 59 | + security import devid.p12 -k ~/Library/Keychains/login.keychain-db |
| 60 | + @echo "" |
| 61 | + @echo "Certificate imported. Your signing identity:" |
| 62 | + @security find-identity -v -p codesigning | grep "Developer ID Application" |
| 63 | + @echo "" |
| 64 | + @IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | sed 's/.*"\(.*\)".*/\1/'); \ |
| 65 | + NAME=$(echo "$IDENTITY" | sed 's/Developer ID Application: \(.*\) (.*/\1/'); \ |
| 66 | + TEAM=$(echo "$IDENTITY" | sed 's/.*(\(.*\))/\1/'); \ |
| 67 | + echo "Test with:"; \ |
| 68 | + echo " just install-signed \"$NAME\" \"$TEAM\""; \ |
| 69 | + echo ""; \ |
| 70 | + echo "Clean up: just cert-clean" |
| 71 | + |
| 72 | +cert-clean: |
| 73 | + rm -f devid.key devid.csr devid.crt devid.p12 |
0 commit comments