forked from davesnx/styled-ppx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (120 loc) · 4.63 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
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(or \"%s_watch\" to watch them)\033[0m\n", $$1, $$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.1.1 --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_reason_css_parser test_native_typecheck test_ppx_snapshot_reason test_ppx_snapshot_rescript test_css_support test_css_spec_types test_emotion 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
# Apply the create_watch_target rule for each test target
$(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
# 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
# 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/css_parser.mly