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,41 @@ 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+ # TODO: replace ☝️ with `set -a; . .env; set +a;`
29+
30+ # # init: 🏌️ initialize the project
2831.PHONY : init
2932init :
33+ $(call pp,initializing project)
34+ git config core.hooksPath hooks
3035 rm -rf build && mkdir build
3136 python3 -m venv .venv
3237 source .venv/bin/activate && \
3338 pip install gcovr conan && \
3439 conan install . --lockfile=conan.lock --build=missing -s build_type=Debug && \
3540 conan install . --lockfile=conan.lock --build=missing -s build_type=Release
41+ cmake --preset=release
3642 cmake --preset=debug
43+ $(MAKE ) restore-cpus
3744
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
45+ # # lock: 📦 update Conan dependency lock file. (NB run after adding conan dependencies to conanfile.txt, but before installing)
46+ .PHONY : lock
47+ lock :
48+ $(call pp,updating conan lock file to match contents of conanfile.txt)
49+ source .venv/bin/activate && \
50+ conan lock create . --profile:host=default -s build_type=Debug --lockfile-out=conan.lock && \
51+ conan lock create . --profile:host=default -s build_type=Release --lockfile=conan.lock --lockfile-out=conan.lock
4352
4453# # build-debug: 🔨 compile (debug)
4554.PHONY : build-debug
4655build-debug :
47- $(call pp,assuming `make init` has been called)
56+ $(call pp,NB assuming `make init` has been called)
4857 cmake --preset=debug
4958 cmake --build --preset=debug
5059
6877# # bench: ⏱️ build and run benchmarks
6978.PHONY : bench
7079bench :
71- $(call pp,assuming `make build-release` has been called)
7280 cmake --build --preset release
7381 build/Release/benchmarks/benchmarks \
7482 --benchmark_out=bench_results.json \
@@ -80,18 +88,26 @@ bench:
8088tidy :
8189 find src/ tests/ benchmarks/ \( -name ' *.cpp' -o -name ' *.hpp' -o -name ' *.c' -o -name ' *.h' \) -exec clang-format -i {} +
8290 hooks/check_clang_tidy.sh
91+ hooks/check_shell.sh
8392
84- # # run-debug: 🏃♂️ run the app (debug) (don't forget `withenv`)
93+ # # run-debug: 🏃♂️ run the app (debug) (don't forget `withenv`)
8594.PHONY : run-debug
8695run-debug :
8796 ASAN_OPTIONS=detect_leaks=1:leak_check_at_exit=1:fast_unwind_on_malloc=0 \
8897 build/Debug/tradercpp
8998
90- # # run-release: 🏎️ run the app (prod)
99+ # # run-release: 🏎️ run the app (prod)
91100.PHONY : run-release
92101run-release :
93- $(call pp,starting app. dont forget to run `scripts/cpu_shield_start.sh` and `scripts/irqs_move.sh`)
94- build/Release/tradercpp
102+ # set -a; . .env; set +a; sudo -E scripts/pin_irqs.sh
103+ set -a; . .env; set +a; 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 and IRQ management back to the kernel. NB: app must not be running`)
109+ set -a; . .env; set +a; sudo -E scripts/unpin_cpus.sh
110+ set -a; . .env; set +a; sudo -E scripts/unpin_irqs.sh
95111
96112# CONTAINERISATION RECIPES ----------------------------------------------------
97113
0 commit comments