Skip to content

Commit 915e0e3

Browse files
committed
simplify justfile
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 41c1958 commit 915e0e3

1 file changed

Lines changed: 22 additions & 41 deletions

File tree

justfile

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,40 @@
1+
TARGET_DIR := justfile_directory() + "/target"
2+
BIN_DIR := TARGET_DIR + "/bin"
3+
4+
default: run
15

26
install-wkg:
3-
#!/bin/bash
4-
set -euox pipefail
5-
if ! [[ -f {{ justfile_directory() }}/target/bin/wkg ]]; then
6-
cargo install wkg \
7-
--root {{ justfile_directory() }}/target
8-
fi
7+
! test -f {{ BIN_DIR }}/wkg || \
8+
cargo install wkg \
9+
--root {{ TARGET_DIR }}
910

1011
get-component: install-wkg
11-
#!/bin/bash
12-
set -euox pipefail
13-
if ! [[ -f sample_wasi_http_rust.wasm ]]; then
14-
{{ justfile_directory() }}/target/bin/wkg oci pull \
15-
ghcr.io/bytecodealliance/sample-wasi-http-rust/sample-wasi-http-rust:latest \
16-
-o sample_wasi_http_rust.wasm
17-
fi
12+
! test -f sample_wasi_http_rust.wasm || \
13+
{{ BIN_DIR }}/wkg oci pull \
14+
ghcr.io/bytecodealliance/sample-wasi-http-rust/sample-wasi-http-rust:latest \
15+
-o sample_wasi_http_rust.wasm
1816

1917
install-hyperlight-wasm-aot:
20-
#!/bin/bash
21-
set -euox pipefail
22-
if ! [[ -f {{ justfile_directory() }}/target/bin/hyperlight-wasm-aot ]]; then
23-
cargo install hyperlight-wasm-aot \
24-
--git https://github.com/jprendes/hyperlight-wasm.git \
25-
--rev 134d8fc355ef842ace918777a758349342241c9d \
26-
--root {{ justfile_directory() }}/target
27-
fi
18+
! test -f {{ BIN_DIR }}/hyperlight-wasm-aot || \
19+
cargo install hyperlight-wasm-aot \
20+
--git https://github.com/jprendes/hyperlight-wasm.git \
21+
--rev 134d8fc355ef842ace918777a758349342241c9d \
22+
--root {{ TARGET_DIR }}
2823

2924
aot-component: get-component install-hyperlight-wasm-aot
30-
#!/bin/bash
31-
set -euox pipefail
32-
{{ justfile_directory() }}/target/bin/hyperlight-wasm-aot compile --component sample_wasi_http_rust.wasm sample_wasi_http_rust.bin
25+
{{ BIN_DIR }}/hyperlight-wasm-aot compile --component sample_wasi_http_rust.wasm sample_wasi_http_rust.bin
3326

3427
install-wasm-tools:
35-
#!/bin/bash
36-
set -euox pipefail
37-
if ! [[ -f {{ justfile_directory() }}/target/bin/wasm-tools ]]; then
38-
cargo install wasm-tools \
39-
--root {{ justfile_directory() }}/target
40-
fi
28+
! test -f {{ BIN_DIR }}/wasm-tools || \
29+
cargo install wasm-tools \
30+
--root {{ TARGET_DIR }}
4131

4232
make-wit-world: install-wasm-tools
43-
#!/bin/bash
44-
set -euox pipefail
45-
if ! [[ -f hyperlight-world.wasm ]]; then
46-
{{ justfile_directory() }}/target/bin/wasm-tools component wit hyperlight.wit -w -o hyperlight-world.wasm
47-
fi
33+
! test -f hyperlight-world.wasm || \
34+
{{ BIN_DIR }}/wasm-tools component wit hyperlight.wit -w -o hyperlight-world.wasm
4835

4936
build: make-wit-world
50-
#!/bin/bash
51-
set -euox pipefail
52-
export WIT_WORLD={{ justfile_directory() }}/hyperlight-world.wasm
5337
cargo build
5438

5539
run: build aot-component
56-
#!/bin/bash
57-
set -euox pipefail
58-
export WIT_WORLD={{ justfile_directory() }}/hyperlight-world.wasm
5940
cargo run -- sample_wasi_http_rust.bin

0 commit comments

Comments
 (0)