11# !make
22SHELL: =/bin/bash
33
4- # ################################################
5- # A set of basic execution recipes (all PHONY).
6- # Call `make` on the command line for documentation.
7- # ################################################
4+ # ###############################################
5+ # A set of execution recipes (all PHONY).
6+ # In essence, a programmatic entrypoint into the app.
7+ # Run `make` for help.
8+ # ###############################################
89
910# pp - pretty print function
1011yellow := $(shell tput setaf 3)
@@ -18,33 +19,39 @@ help: Makefile
1819 @echo " Choose a command to run:"
1920 @sed -n ' s/^##//p' $< | column -t -s ' :' | sed -e ' s/^/ /'
2021
21- # # withenv: 😭 run `make` with envars from `.env`. like so `make withenv RECIPE=init`
22+ # # withenv: 😭 execute `make` with environment variables defined in `.env`. like so > `make withenv RECIPE=init`
2223.PHONY : withenv
2324withenv :
2425 test -e .env || cp .env.example .env
2526 bash -c ' set -o allexport; source .env; set +o allexport; make "$$RECIPE"'
2627
27- # # init: 🏌️ initialize the project, fetch dependencies
28+ # # init: 🏌️ initialize the project
2829.PHONY : init
2930init :
31+ $(call pp,initializing project)
32+ git config core.hooksPath hooks
3033 rm -rf build && mkdir build
3134 python3 -m venv .venv
3235 source .venv/bin/activate && \
3336 pip install gcovr conan && \
3437 conan install . --lockfile=conan.lock --build=missing -s build_type=Debug && \
3538 conan install . --lockfile=conan.lock --build=missing -s build_type=Release
39+ cmake --preset=release
3640 cmake --preset=debug
41+ $(MAKE ) restore-cpus
3742
38- # # lock-conan: 📦 run after adding (but before installing) conan dependencies
39- .PHONY : lock-conan
40- lock-conan :
41- conan lock create . --profile:host=default -s build_type=Debug --lockfile-out=conan.lock
42- conan lock create . --profile:host=default -s build_type=Release --lockfile=conan.lock --lockfile-out=conan.lock
43+ # # lock: 📦 update Conan dependency lock file. (NB run after adding conan dependencies to conanfile.txt, but before installing)
44+ .PHONY : lock
45+ lock :
46+ $(call pp,updating conan lock file to match contents of conanfile.txt)
47+ source .venv/bin/activate && \
48+ conan lock create . --profile:host=default -s build_type=Debug --lockfile-out=conan.lock && \
49+ conan lock create . --profile:host=default -s build_type=Release --lockfile=conan.lock --lockfile-out=conan.lock
4350
4451# # build-debug: 🔨 compile (debug)
4552.PHONY : build-debug
4653build-debug :
47- $(call pp,assuming `make init` has been called)
54+ $(call pp,NB assuming `make init` has been called)
4855 cmake --preset=debug
4956 cmake --build --preset=debug
5057
6875# # bench: ⏱️ build and run benchmarks
6976.PHONY : bench
7077bench :
71- $(call pp,assuming `make build-release` has been called)
7278 cmake --build --preset release
7379 build/Release/benchmarks/benchmarks \
7480 --benchmark_out=bench_results.json \
@@ -79,19 +85,29 @@ bench:
7985.PHONY : tidy
8086tidy :
8187 find src/ tests/ benchmarks/ \( -name ' *.cpp' -o -name ' *.hpp' -o -name ' *.c' -o -name ' *.h' \) -exec clang-format -i {} +
88+ hooks/check_shell.sh
8289 hooks/check_clang_tidy.sh
8390
84- # # run-debug: 🏃♂️ run the app (debug) (don't forget `withenv`)
91+ # # run-debug: 🏃♂️ run the app (debug) (don't forget `withenv`)
8592.PHONY : run-debug
8693run-debug :
8794 ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1:fast_unwind_on_malloc=0 \
8895 build/Debug/tradercpp
8996
90- # # run-release: 🏎️ run the app (prod)
97+ # # run-release: 🏎️ run the app (prod)
9198.PHONY : run-release
9299run-release :
93- $(call pp,starting app. dont forget to run `scripts/cpu_shield_start.sh` and `scripts/irqs_move.sh`)
94- build/Release/tradercpp
100+ $(call pp,moving IRQs)
101+ set -o allexport; source .env; set +o allexport; sudo -E scripts/pin_irqs.sh
102+ $(call pp,moving CPUs and starting app)
103+ set -o allexport; source .env; set +o allexport; sudo -E scripts/pin_cpus.sh build/Release/tradercpp
104+
105+ # # restore-cpus: 🖥️ hand back pinned CPUs and IRQs to the operating system. (NB app must not be running)
106+ .PHONY : restore-cpus
107+ restore-cpus :
108+ $(call pp,handing CPU management back to the kernel (NB: app must not be running) )
109+ $(call pp,NB: for re-assigning IRQs reboot the machine)
110+ set -o allexport; source .env; set +o allexport; sudo -E scripts/unpin_cpus.sh
95111
96112# CONTAINERISATION RECIPES ----------------------------------------------------
97113
@@ -101,7 +117,7 @@ build-container:
101117 IMAGE_VERSION=
102118 @if [ -z " $( IMAGE_VERSION) " ]; then \
103119 echo " Error: IMAGE_VERSION is not set" ; \
104- echo " (you can set it on the command line like so: \` make build-container IMAGE_VERSION=1.7 \` )" ; \
120+ echo " (you can set it on the command line like so: \` make build-container IMAGE_VERSION=1.8 \` )" ; \
105121 exit 1; \
106122 fi
107123 docker build -f Dockerfile_build -t milss/tradercppbuild:latest -t milss/tradercppbuild:v$(IMAGE_VERSION ) .
0 commit comments