-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
164 lines (127 loc) · 4.92 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
project_name = styled-ppx
OPAM_EXEC = opam exec --
DUNE = $(OPAM_EXEC) dune
opam_file = $(project_name).opam
.PHONY: help
help: ## Print this help message
@echo "";
@echo "List of available make commands";
@echo "";
@grep -E '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}';
@echo $(TEST_TARGETS) | tr -s " " "\012" | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m Run %s test \33[1;97m(add \"-watch\" or \"-promote\")\033[0m\n", $$1, $$1}';
@echo "";
.PHONY: build
build: ## Build the project, including non installable libraries and executables
$(DUNE) build --promote-install-files --root .
.PHONY: build-prod
build-prod: ## Build for production (--profile=prod)
$(DUNE) build --profile=prod
.PHONY: clean
clean: ## Clean artifacts
$(DUNE) clean
.PHONY: deps
deps: $(opam_file) ## Alias to update the opam file and install the needed deps
.PHONY: format-check
format-check: ## Checks if format is correct
$(DUNE) build @fmt
.PHONY: format
fmt format: ## Formats code
$(DUNE) build @fmt --auto-promote
.PHONY: setup-githooks
setup-githooks: ## Setup githooks
@git config core.hooksPath .githooks
.PHONY: create-switch
create-switch: ## Create opam switch
opam switch create . 5.2.0 --deps-only --with-test --no-install
.PHONY: install
install: ## Install project dependencies
opam install . --deps-only --with-test -y
npm install
.PHONY: init
init: setup-githooks create-switch install ## Create a local dev enviroment
.PHONY: subst
subst: ## Run dune substitute
$(DUNE) subst
.PHONY: dev
dev: ## Run the project in dev mode
$(DUNE) build --promote-install-files --root . --watch
.PHONY: release-static
release-static:
$(DUNE) build --root . --ignore-promoted-rules --profile release-static --only-packages styled-ppx
# Testing commands
TEST_TARGETS := test-parser test-css-property-parser test-ppx-native test-ppx-snapshot-reason test-ppx-snapshot-rescript test-css-support test-css-spec-types test-runtime test-murmur2 test-css-spec-parser test-string-interpolation
# Create targets with the format "test-{{target_name}}-{{ "watch" | "promote" }}"
define create-test
.PHONY: $(1)
$(1): ## Run $(1) tests
$$(DUNE) build @$(1)
endef
define create-test-watch
.PHONY: $(1)-watch
$(1)-watch: ## Run $(1) tests
$$(DUNE) build @$(1) --watch
endef
define create-test-promote
.PHONY: $(1)-promote
$(1)-promote: ## Run $(1) tests
$$(DUNE) build @$(1) --auto-promote
endef
$(foreach target,$(TEST_TARGETS), $(eval $(call create-test,$(target))))
$(foreach target,$(TEST_TARGETS), $(eval $(call create-test-watch,$(target))))
$(foreach target,$(TEST_TARGETS), $(eval $(call create-test-promote,$(target))))
.PHONY: test-e2e-rescript-v9
test-e2e-rescript-v9: ## Run End-to-end tests for JSX3
npm --prefix 'e2e/rescript-v9-JSX3' install
npm --prefix 'e2e/rescript-v9-JSX3' run build
npm --prefix 'e2e/rescript-v9-JSX3' run test
.PHONY: test-e2e-rescript-v9-watch
test-e2e-rescript-v9-watch: ## Run End-to-end tests for JSX3
npm --prefix 'e2e/rescript-v9-JSX3' run test-watch
.PHONY: test-e2e-rescript-v9-promote
test-e2e-rescript-v9-promote: ## Run End-to-end tests for JSX3
npm --prefix 'e2e/rescript-v9-JSX3' run test-promote
.PHONY: test-e2e-rescript-v10
test-e2e-rescript-v10: ## Run End-to-end tests for JSX4
npm --prefix 'e2e/rescript-v10-JSX4' install
npm --prefix 'e2e/rescript-v10-JSX4' run build
npm --prefix 'e2e/rescript-v10-JSX4' run test
.PHONY: test-e2e-rescript-v10-watch
test-e2e-rescript-v10-watch: ## Run End-to-end tests for JSX4
npm --prefix 'e2e/rescript-v10-JSX4' run test-watch
.PHONY: test-e2e-rescript-v10-promote
test-e2e-rescript-v10-promote: ## Run End-to-end tests for JSX4
npm --prefix 'e2e/rescript-v10-JSX4' run test-promote
.PHONY: test
test: build
@for target in $(TEST_TARGETS); do \
if [ "$(CI)" = "true" ]; then \
ALCOTEST_VERBOSE=true make $${target}; \
else \
ALCOTEST_VERBOSE=false make $${target}; \
fi \
done
.PHONY: test-e2e
test-e2e: build test-e2e-rescript-v9 test-e2e-rescript-v10 ## Run E2E tests
# Demo
.PHONY: demo-e2e-rescript-v10
demo-e2e-rescript-v10: build ## Run the ReScript v10 demo with JSX4
npm --prefix 'e2e/rescript-v10-JSX4' install
npm --prefix 'e2e/rescript-v10-JSX4' run start
.PHONY: demo-e2e-melange-debug
demo-e2e-melange-debug: ## Run the melange server demo
$(DUNE) exec e2e-melange-debug
.PHONY: demo-e2e-melange-debug-watch
demo-e2e-melange-debug-watch: ## Run (and watch) the melange server demo
$(DUNE) exec e2e-melange-debug --watch
# Debug commands
.PHONY: ast
ast: ## Print the command to debug the ast
@echo "Run the following command to debug the AST"
@echo " $(DUNE) exec ast-renderer"
.PHONY: lexer
lexer: ## Print the command to debug the lexer
@echo "Run the following command to debug the AST"
@echo " $(DUNE) exec lexer-renderer"
.PHONY: interpreter
interpreter: ## Run menhir as interpret
$(OPAM_EXEC) menhir --interpret --interpret-show-cst packages/parser/lib/Parser.mly