forked from melange-re/melange-opam-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 2.17 KB
/
Makefile
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
project_name = melange-opam-template
DUNE = opam exec -- dune
.DEFAULT_GOAL := help
.PHONY: help
help: ## Print this help message
@echo "List of available make commands";
@echo "";
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}';
@echo "";
.PHONY: generate-opam
generate-opam: ## Generate opam file from dune-project
$(DUNE) build $(project_name).opam
.PHONY: create-switch
create-switch: generate-opam ## Create opam switch
opam switch create . 5.1.0 -y --deps-only
.PHONY: init
init: create-switch install ## Configure everything to develop this repository in local
.PHONY: install
install: generate-opam ## Install development dependencies
npm install # install JavaScript packages that the project might depend on, like `react` or `react-dom`
opam update # make sure that opam has the latest information about published libraries in the opam repository https://opam.ocaml.org/packages/
opam install -y . --deps-only --with-test # install the Melange and OCaml dependencies
opam exec opam-check-npm-deps # check that the versions of the JavaScript packages installed match the requirements defined by Melange libraries
.PHONY: build
build: ## Build the project
$(DUNE) build @react @node # @react and @node are dune aliases: https://dune.readthedocs.io/en/stable/overview.html#term-alias
# Another way to build the project would be just calling `dune build`, which will build the `@@default` alias: https://dune.readthedocs.io/en/stable/reference/aliases.html#default
.PHONY: build_verbose
build_verbose: ## Build the project
$(DUNE) build --verbose @react @node
.PHONY: serve
serve: ## Serve the application with a local HTTP server
npm run serve
.PHONY: bundle
bundle: ## Bundle the JavaScript application
npm run bundle
.PHONY: clean
clean: ## Clean build artifacts and other generated files
$(DUNE) clean
.PHONY: format
format: ## Format the codebase with ocamlformat
$(DUNE) build @fmt --auto-promote
.PHONY: format-check
format-check: ## Checks if format is correct
$(DUNE) build @fmt
.PHONY: watch
watch: ## Watch for the filesystem and rebuild on every change
$(DUNE) build --watch @react @node