-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
45 lines (32 loc) · 1.07 KB
/
makefile
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
SHELL := /usr/bin/env bash
SVDTOOLS ?= svdtools
SVD2RUST ?= svd2rust
FORM ?= form
DEVICES := mcxn947
YAMLS := $(foreach device, $(DEVICES), svd/$(device).yaml)
PATCHED_SVDS := $(foreach device, $(DEVICES), svd/$(device).svd.patched)
CARGO_LIBS := $(foreach device, $(DEVICES), pacs/$(device)/src/lib.rs)
CARGO_TOMLS := $(foreach device, $(DEVICES), pacs/$(device)/Cargo.toml)
.NOTINTERMEDIATE: $(CARGO_LIBS)
.PHONY: install_tools patch crates clean-patch clean-crates clean
install_tools:
svd/%.svd.patched: svd/%.yaml svd/%.svd
$(SVDTOOLS) patch $<
patch: $(PATCHED_SVDS)
pacs/%/src/lib.rs: svd/%.svd.patched
rm -rf pacs/$*
mkdir -p pacs/$*
svd2rust -c svd2rust.toml -i $< -o pacs/$*
form -i pacs/$*/lib.rs -o pacs/$*/src
rm pacs/$*/lib.rs
pacs/%/Cargo.toml: Cargo.toml.template pacs/%/src/lib.rs
sed 's/@NAME@/$*/g' Cargo.toml.template > $@
cargo fmt --manifest-path $@
pacs/%/src/lib.rs:
crates: $(CARGO_TOMLS)
clean-patch:
rm -rf svd/*.svd.patched
clean-crates:
rm -rf pacs
clean: clean-patch clean-crates