-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.dev
65 lines (52 loc) · 1.94 KB
/
Makefile.dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# This Makefile is only for help - a wrapper around 'cargo build' to shorten the commands.
#
# Usage:
# $ [DEFMT_LOG=trace|debug|info|...] [FEATURES=esp-hal-next|esp-hal-0_22|...] make -f Makefile.dev {m3|...}
# # builds and runs a certain sample
#
DEFMT_LOG?=debug
FEATURES?=
LOG_ENV:=DEFMT_LOG=esp_hal=info,$(DEFMT_LOG)
DEFMT_HOST_FMT:='{t:dimmed} [{L:bold}] {s}'
REMAKE:=$(MAKE) -f $(MAKEFILE_LIST)
# Read the 'TARGET' from './cargo/config.toml'
#
TARGET:=$(shell cat ../.cargo/config.toml | grep -e '^target\s*=\s"' | cut -d '"' -f2)
# riscv32imac-unknown-none-elf
ALL_FEATURES:=ambient_per_spad,nb_spads_enabled,signal_per_spad,range_sigma_mm,distance_mm,reflectance_percent
# Detect 'cargo' build cache
#
# NOTE: This is not very easy. Cargo only exposes the path (which can be defined in THREE different ways!) within
# its own build system (as 'OUT_DIR' env.var.); there is no CLI way to ask for it.. Which is fine.
#
# We have 'build.rs' write the path to '.OUT_DIR', from where we can pick it up, for running.
#
# YES: The author knows one can use Cargo runners. But this feels more free.
#
# [1]: Cargo Book > Build cache
# https://doc.rust-lang.org/stable/cargo/guide/build-cache.html
#
_OUT_DIR:=.OUT_DIR
# Note! Defined with '=' so that it gets re-evaluated on-site!
_OUT_EXAMPLE=$(shell cat ${_OUT_DIR} | sed -E 's^/build/.+$$^/examples/^')$(EXAMPLE)
all:
@false
# Examples
#|m3:
#| EXAMPLE=m3 \
#| FEATURES=targets_per_zone_2,distance_mm,reflectance_percent \
#| $(REMAKE) --no-print-directory _build _run
m3:
EXAMPLE=m3 \
FEATURES=$(FEATURES),targets_per_zone_2,$(ALL_FEATURES) \
$(REMAKE) --no-print-directory _build _run
#---
_build:
$(LOG_ENV) cargo build --release --features=$(FEATURES),defmt,fugit --example $(EXAMPLE)
@test -f ${_OUT_DIR} || (echo >&2 "Did not generate ${_OUT_DIR}"; false)
_run:
probe-rs run --log-format $(DEFMT_HOST_FMT) $(_OUT_EXAMPLE)
echo:
@echo $(notdir $(_OUT_EXAMPLE))
.PHONY: all m3 _build _run echo