| 1 | # todo-ocaml: TodoMVC for the CARLOS bakeoff. See README.md. |
| 2 | SHELL := /bin/bash |
| 3 | VERSION ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo dev) |
| 4 | MESSAGE ?= Deploy todo-ocaml |
| 5 | CSS := static/base.css static/index.css |
| 6 | DUNE := dune build --root . --profile release |
| 7 | |
| 8 | .PHONY: build build-arm64 test clean clean-deps bump unbump deploy |
| 9 | |
| 10 | # The shared TodoMVC styles are served byte for byte, compiled in. |
| 11 | static/%.css: ../../shared/%.css |
| 12 | cp $< $@ |
| 13 | |
| 14 | build: $(CSS) |
| 15 | mkdir -p _build |
| 16 | APP_VERSION=$(VERSION) tools/x86.sh $(DUNE) --build-dir $(CURDIR)/_build/x86 ./bin/main.exe |
| 17 | mkdir -p dist && install -m 755 _build/x86/default/bin/main.exe dist/app |
| 18 | |
| 19 | build-arm64: $(CSS) |
| 20 | mkdir -p _build |
| 21 | APP_VERSION=$(VERSION) LINK_FLAGS='-ccopt -static' \ |
| 22 | tools/arm64.sh $(DUNE) --build-dir $(CURDIR)/_build/arm64 ./bin/main.exe |
| 23 | mkdir -p dist && install -m 755 _build/arm64/default/bin/main.exe dist/app-linux-arm64 |
| 24 | echo $(VERSION) > dist/app-linux-arm64.version |
| 25 | |
| 26 | test: $(CSS) |
| 27 | mkdir -p _build |
| 28 | tools/x86.sh dune test --root . --build-dir $(CURDIR)/_build/x86 --force |
| 29 | |
| 30 | clean: |
| 31 | rm -rf dist _build $(CSS) |
| 32 | |
| 33 | # Deletes both opam switches and both SQLite builds (every compiled |
| 34 | # library) but keeps the opam repositories, opam's download cache and the |
| 35 | # SQLite tarball in .cache/src, so the next build compiles every library |
| 36 | # from its already-downloaded source. |
| 37 | clean-deps: clean |
| 38 | rm -rf .cache/opam-arm64/default .cache/opam-x86/default .cache/sqlite-arm64 .cache/sqlite-x86 |
| 39 | |
| 40 | bump: |
| 41 | sed -i 's/^let build_marker = "todomvc"$$/let build_marker = "todomvc-bumped"/' src/app.ml |
| 42 | |
| 43 | unbump: |
| 44 | sed -i 's/^let build_marker = "todomvc-bumped"$$/let build_marker = "todomvc"/' src/app.ml |
| 45 | |
| 46 | # Ships the version the binary was built with, which it reports at /api/version. |
| 47 | deploy: |
| 48 | carlos deploy --account bfj --app todo-ocaml --target linux-arm64 --no-prompt \ |
| 49 | --version "$$(cat dist/app-linux-arm64.version)" --message "$(MESSAGE)" dist/app-linux-arm64 |
| 50 | |