Skip to content

Commit dc76ea4

Browse files
committed
Polish makefile and dune watch
1 parent 1b11ebb commit dc76ea4

File tree

7 files changed

+48
-44
lines changed

7 files changed

+48
-44
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ _esy/
99
static/
1010

1111
.merlin
12+
13+
.processes/last_built_at.txt

.processes/.gitkeep

Whitespace-only changes.

Makefile

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,46 @@ install: ## Install dependencies from esy.json and package.json
1212
@$(ESY) install
1313
@npm install
1414

15-
.PHONY: client-bundle
16-
client-bundle: ## Bundle the JS code
15+
.PHONY: webpack
16+
webpack: ## Bundle the JS code
1717
@$(WEBPACK) --env development
1818

19-
.PHONY: client-bundle-watch
20-
client-bundle-watch: ## Watch and bundle the JS code
21-
@$(WEBPACK) --watch --env development
22-
23-
.PHONY: client-bundle
24-
client-bundle-prod: ## Bundle the JS code for production
19+
.PHONY: webpack-prod
20+
webpack-prod: ## Bundle the JS code for production
2521
@$(WEBPACK) --env production
2622

27-
.PHONY: client-build
28-
client-build: ## Build Reason code
23+
.PHONY: webpack-watch
24+
webpack-watch: ## Watch and bundle the JS code
25+
@$(WEBPACK) --watch --env development
26+
27+
.PHONY: build-client
28+
build-client: ## Build Reason code
2929
@$(DUNE) build @client
3030

31-
.PHONY: client-build-watch
32-
client-build-watch: ## Watch reason code
31+
.PHONY: build-client-watch
32+
build-client-watch: ## Watch reason code
3333
@$(DUNE) build -w @client
3434

35-
.PHONY: server-build
36-
server-build: ## Build the project, including non installable libraries and executables
37-
@$(DUNE) build @@default
38-
39-
.PHONY: server-build-prod
40-
server-build-prod: ## Build for production (--profile=prod)
41-
@$(DUNE) build --profile=prod @@default
35+
.PHONY: build-server-prod
36+
build-server-prod: ## Build for production (--profile=prod)
37+
@$(DUNE) build --profile=prod @server
4238

43-
.PHONY: server-start
44-
server-start: ## Start the server
45-
@$(DUNE) exec --root . --no-buffer server/server.exe
39+
.PHONY: build-server
40+
build-server: ## Build the project, including non installable libraries and executables
41+
@$(DUNE) build @server
4642

47-
.PHONY: server-dev
48-
server-dev: ## Build in watch mode
49-
@$(DUNE) build -w @@default
43+
.PHONY: start-server
44+
start-server: ## Start the server
45+
@$(DUNE) exec server/server.exe
5046

51-
.PHONY: server-dev
52-
watch: ## Build in watch
53-
@$(DUNE) build -w @@default
47+
.PHONY: run
48+
run: ## Start the server in dev mode
49+
@watchexec --no-ignore -w .processes/last_built_at.txt -r -c \
50+
"clear; _build/default/server/server.exe"
5451

55-
.PHONY: dev
56-
dev: ## Start the server in dev mode
57-
@watchexec \
58-
-w client -w server -w shared -w vendor \
59-
--exts re,rei,res,resi,ml,mli -r -c \
60-
"$(MAKE) client-build; $(MAKE) server-build; $(MAKE) client-bundle; $(MAKE) server-start"
52+
.PHONY: watch
53+
watch: ## Build in watch mode
54+
@$(DUNE) build -w @client @server
6155

6256
.PHONY: clean
6357
clean: ## Clean artifacts

benchmark/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Command to run `wrk -t8 -c400 -d30s http://localhost:xxxx`
2323

2424
```sh
2525
Thread Stats Avg Stdev Max +/- Stdev
26-
Latency 109.35us 42.15us 1.68ms 75.40%
27-
Req/Sec 9.10k 2.11k 12.52k 51.08%
28-
2179657 requests in 30.10s, 5.96GB read
29-
30-
Requests/sec: 72414.39
31-
Transfer/sec: 202.62MB
26+
Latency 40.82ms 10.45ms 188.76ms 85.29%
27+
Req/Sec 1.22k 267.70 1.51k 70.58%
28+
291638 requests in 30.08s, 270.62MB read
29+
Socket errors: connect 0, read 964, write 0, timeout 0
30+
Requests/sec: 9695.68
31+
Transfer/sec: 9.00MB
3232
```
3333

3434
### node-express-js

dune

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
(subdir static)
2-
3-
(subdir vendor)
1+
(dirs static vendor shared server client)

server/dune

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@
88
server-reason-react.css)
99
(preprocess
1010
(pps server-reason-react.ppx)))
11+
12+
(rule
13+
(alias server)
14+
(deps ./server.exe)
15+
(action
16+
; we want dune to write the file but not attach any fsevents listeners to it,
17+
; so that watchexec can read from it without issues.
18+
; this means no (target), no (with-stdout-to), just a bash command with stdout
19+
; redirect inside a string
20+
(bash "date > %{project_root}/../../.processes/last_built_at.txt")))

shared/js/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
(modes melange)
44
(libraries melange reason_react bs_css bs_css_emotion bs_webapi)
55
(preprocess
6-
(pps reactjs-jsx-ppx)))
6+
(pps melange.ppx reactjs-jsx-ppx)))
77

88
(copy_files# "../*.re")

0 commit comments

Comments
 (0)