-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (63 loc) · 1.69 KB
/
Makefile
File metadata and controls
79 lines (63 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.PHONY: run run-controller build build-controller build-wrapper build-plugins clean fix
# Configuration
WASM_RUSTFLAGS = -Z wasi-exec-model=reactor
WASM_TARGET = wasm32-wasip2
# Directories
RUN_DIR = run
OLD_RUN_DIR = run.old
PLUGIN_DIR = $(RUN_DIR)/plugins/wasm
# Arguments
CONTROLLER_ARGS = "--debug"
CLI_ARGS = "--debug"
# OS detection
ifeq ($(OS),Windows_NT)
RM = cmd /C del /S /Q
MKDIR = mkdir
CP = xcopy /E /I /Y
SEP = &
SETENV = set
else
RM = rm -rf
MKDIR = mkdir -p
CP = cp -r
SEP = ;
SETENV = export
endif
# Targets
## Clean target
clean:
$(CP) $(RUN_DIR) $(OLD_RUN_DIR)
$(RM) $(RUN_DIR)
cargo clean
## Fix target
fix:
cargo clippy --fix --allow-dirty --allow-staged --all-features
cargo fmt
## Build target
build: build-controller build-cli build-wrapper build-plugins
## Run target
run: run-controller
## Run controller
run-controller:
$(MKDIR) $(RUN_DIR) $(SEP) cd $(RUN_DIR) $(SEP) cargo run -p controller --all-features -- $(CONTROLLER_ARGS)
## Run cli
run-cli:
$(MKDIR) $(RUN_DIR) $(SEP) cd $(RUN_DIR) $(SEP) cargo run -p cli --all-features -- $(CLI_ARGS)
## Build controller target
build-controller:
cargo build -p controller --all-features --release
## Build cli target
build-cli:
cargo build -p cli --all-features --release
## Build wrapper target
build-wrapper:
cargo build -p wrapper --all-features --release
## Build plugins target
build-plugins:
$(SETENV) RUSTFLAGS="$(WASM_RUSTFLAGS)"
cargo build -p pelican --target $(WASM_TARGET) --release
cargo build -p local --target $(WASM_TARGET) --release
cargo build -p cloudflare --target $(WASM_TARGET) --release
# Create plugin directory if it doesn't exist
$(PLUGIN_DIR):
$(MKDIR) $(PLUGIN_DIR)