1+ # ReScript Relay PPX Makefile
2+
3+ .PHONY : help deps build clean rebuild test dev-setup build-release check env
4+
5+ # Default target - just build the binary like before
6+ all : build
7+
8+ # Show help
9+ help :
10+ @echo " ReScript Relay PPX Build Commands:"
11+ @echo " "
12+ @echo " Main Commands:"
13+ @echo " build - Build the PPX executable (default)"
14+ @echo " rebuild - Clean and build from scratch"
15+ @echo " clean - Clean build artifacts"
16+ @echo " "
17+ @echo " Setup:"
18+ @echo " dev-setup - Set up development environment (OCaml 4.14 + dependencies)"
19+ @echo " deps - Install project dependencies only"
20+ @echo " "
21+ @echo " Release:"
22+ @echo " build-release - Build with release profile"
23+ @echo " "
24+ @echo " Utilities:"
25+ @echo " check - Check if binary builds and works"
26+ @echo " env - Show current OCaml environment"
27+ @echo " test - Run tests (if any)"
28+ @echo " "
29+
30+ # Development setup - ensures we have the right OCaml version and dependencies
31+ dev-setup :
32+ @echo " Setting up development environment..."
33+ @if ! opam switch list | grep -q " 4.14" ; then \
34+ echo " Installing OCaml 4.14.0..." ; \
35+ opam switch create 4.14.0 4.14.0; \
36+ fi
37+ @echo " Switching to OCaml 4.14.0..."
38+ @opam switch 4.14.0
39+ @eval $$(opam env )
40+ @echo " Installing dependencies..."
41+ @opam install . --deps-only --yes
42+ @echo " Development environment ready!"
43+
44+ # Install dependencies only
45+ deps :
46+ @echo " Installing project dependencies..."
47+ @opam install . --deps-only --yes
48+
49+ # Build the project - produces binary at _build/default/bin/RescriptRelayPpxApp.exe
50+ build :
51+ @echo " Building PPX..."
52+ @opam exec -- dune build bin/RescriptRelayPpxApp.exe
53+ @echo " ✓ PPX binary built at: _build/default/bin/RescriptRelayPpxApp.exe"
54+
55+ # Build release version
56+ build-release :
57+ @echo " Building PPX in release mode..."
58+ @opam exec -- dune build --profile release bin/RescriptRelayPpxApp.exe
59+ @echo " ✓ Release binary built at: _build/default/bin/RescriptRelayPpxApp.exe"
60+
61+ # Clean build artifacts
62+ clean :
63+ @echo " Cleaning build artifacts..."
64+ @opam exec -- dune clean
65+ @echo " Clean complete!"
66+
67+ # Clean and rebuild
68+ rebuild : clean build
69+
70+ # Run tests (placeholder for when tests are added)
71+ test :
72+ @echo " Running tests..."
73+ @if [ -d " __tests__" ]; then \
74+ echo " No test runner configured yet" ; \
75+ else \
76+ echo " No tests found" ; \
77+ fi
78+
79+ # Check if the binary builds and works
80+ check :
81+ @echo " Checking PPX build..."
82+ @opam exec -- dune build bin/RescriptRelayPpxApp.exe
83+ @echo " ✓ Build successful"
84+ @if [ -f " _build/default/bin/RescriptRelayPpxApp.exe" ]; then \
85+ echo " ✓ Binary available at: _build/default/bin/RescriptRelayPpxApp.exe" ; \
86+ _build/default/bin/RescriptRelayPpxApp.exe --help | head -1; \
87+ else \
88+ echo " ✗ Binary not found" ; \
89+ exit 1; \
90+ fi
91+
92+ # Show current OCaml environment
93+ env :
94+ @echo " Current OCaml environment:"
95+ @echo " OCaml version: $$ (ocaml --version)"
96+ @echo " Opam switch: $$ (opam switch show)"
97+ @echo " Dune version: $$ (opam exec -- dune --version)"
0 commit comments