|
| 1 | +# Define installation arguments with optional prefix |
1 | 2 | INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)
|
| 3 | +# Define examples with their descriptions |
| 4 | +EXAMPLE_DESCRIPTIONS := \ |
| 5 | + "example-building-ast:Demonstrates how to build AST" \ |
| 6 | + "example-destructuring-ast:Demonstrates how to destructure an AST" \ |
2 | 7 |
|
3 |
| -# Default rule |
4 |
| -default: |
| 8 | +.PHONY: help |
| 9 | +help: ## Print this help message |
| 10 | + @echo ""; |
| 11 | + @echo "List of available make commands"; |
| 12 | + @echo ""; |
| 13 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'; |
| 14 | + @echo ""; |
| 15 | + @echo "Available examples:"; |
| 16 | + @echo ""; |
| 17 | + @for desc in $(EXAMPLE_DESCRIPTIONS); do \ |
| 18 | + target=$$(echo $$desc | cut -d: -f1); \ |
| 19 | + description=$$(echo $$desc | cut -d: -f2); \ |
| 20 | + printf " \033[36m%-30s\033[0m %s\n" "$$target" "$$description"; \ |
| 21 | + done |
| 22 | + @echo ""; |
| 23 | + |
| 24 | +.PHONY: default |
| 25 | +default: ## Build the project with auto-promote |
5 | 26 | dune build --auto-promote @install
|
6 | 27 |
|
7 |
| -install: |
| 28 | +.PHONY: install |
| 29 | +install: ## Install the project |
8 | 30 | dune install $(INSTALL_ARGS)
|
9 | 31 |
|
10 |
| -uninstall: |
| 32 | +.PHONY: uninstall |
| 33 | +uninstall: ## Uninstall the project |
11 | 34 | dune uninstall $(INSTALL_ARGS)
|
12 | 35 |
|
13 |
| -reinstall: uninstall reinstall |
| 36 | +.PHONY: reinstall |
| 37 | +reinstall: ## Reinstall the project |
| 38 | + uninstall reinstall |
14 | 39 |
|
15 |
| -test: |
| 40 | +.PHONY: test |
| 41 | +test: ## Run tests |
16 | 42 | dune runtest
|
17 | 43 |
|
18 |
| -doc: |
| 44 | +.PHONY: doc |
| 45 | +doc: ## Build documentation |
19 | 46 | dune build @doc
|
20 | 47 |
|
21 |
| -clean: |
| 48 | +.PHONY: doc-dev |
| 49 | +doc-dev: ## Build and watch documentation |
| 50 | + dune build @doc --watch & dune_pid=$$!; \ |
| 51 | + trap 'kill $$dune_pid' EXIT; \ |
| 52 | + sleep 2 && open _build/default/_doc/_html/index.html & \ |
| 53 | + wait $$dune_pid |
| 54 | + |
| 55 | +.PHONY: clean |
| 56 | +clean: ## Clean the build artifacts |
22 | 57 | dune clean
|
23 | 58 |
|
24 |
| -all-supported-ocaml-versions: |
| 59 | +.PHONY: all-supported-ocaml-versions |
| 60 | +all-supported-ocaml-versions: ## Build for all supported OCaml versions |
25 | 61 | dune build @install --workspace dune-workspace.dev --root .
|
26 | 62 |
|
27 |
| -opam-release: |
| 63 | +.PHONY: opam-release |
| 64 | +opam-release: ## Release the project using opam |
28 | 65 | dune-release distrib --skip-build --skip-lint --skip-tests
|
29 | 66 | dune-release publish distrib --verbose
|
30 | 67 | dune-release opam pkg
|
31 | 68 | dune-release opam submit
|
32 | 69 |
|
33 |
| -bench: |
| 70 | +.PHONY: bench |
| 71 | +bench: ## Run benchmarks |
34 | 72 | dune build bench --profile release
|
35 | 73 | dune exec bench/bench.exe
|
36 | 74 |
|
37 |
| -.PHONY: default install uninstall reinstall clean test doc bench |
38 |
| -.PHONY: all-supported-ocaml-versions opam-release |
39 |
| - |
40 |
| -.PHONY: $(TARGET) |
41 |
| -example-%: |
| 75 | +.PHONY: example-<target> |
| 76 | +example-%: ## Run example with specified target, e.g. make example-global-transformation |
42 | 77 | DUNE_CONFIG__GLOBAL_LOCK=disabled opam exec -- dune exec $*-example
|
0 commit comments