aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 181190701e9fe888f21d3add37c061bdc34893f7 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
CODEGEN_TOOL_PROFILE := release
PAC_PROFILE := release
TIMINGS ?= --timings

-include chiptool/target/$(CODEGEN_TOOL_PROFILE)/chiptool.d
-include svd2rust/target/$(CODEGEN_TOOL_PROFILE)/svd2rust.d
-include form/target/$(CODEGEN_TOOL_PROFILE)/form.d
-include svdtools/target/$(CODEGEN_TOOL_PROFILE)/svdtools.d

CHIPTOOL = chiptool/target/$(CODEGEN_TOOL_PROFILE)/chiptool
SVD2RUST = svd2rust/target/$(CODEGEN_TOOL_PROFILE)/svd2rust
FORM     = form/target/$(CODEGEN_TOOL_PROFILE)/form
SVDTOOLS = svdtools/target/$(CODEGEN_TOOL_PROFILE)/svdtools

$(CHIPTOOL):
	cargo build --manifest-path=chiptool/Cargo.toml --profile=$(CODEGEN_TOOL_PROFILE)

$(SVD2RUST):
	cargo build --manifest-path=svd2rust/Cargo.toml --profile=$(CODEGEN_TOOL_PROFILE)

$(FORM):
	cargo build --manifest-path=form/Cargo.toml --profile $(CODEGEN_TOOL_PROFILE)

$(SVDTOOLS):
	cargo build --manifest-path=svdtools/Cargo.toml --profile $(CODEGEN_TOOL_PROFILE)

.PHONY: codegen_tools
codegen_tools: $(CHIPTOOL) $(RALTOOL) $(SVD2RUST) $(FORM) $(SVDTOOLS)

.PHONY: test_codegen_tools
test_codegen_tools: codegen_tools
	$(CHIPTOOL) --help
	$(SVD2RUST) --help
	$(FORM) --help
	$(SVDTOOLS) --help

.PHONY: imxrt-ral.shootout
imxrt-ral.shootout:
	@cargo update --manifest-path=imxrt-ral/Cargo.toml

	@cargo clean --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE)
	cargo build --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --package=imxrt-ral --features=imxrt1011,rt $(TIMINGS)

	@cargo clean --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE)
	cargo build --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --package=imxrt-ral --features=imxrt1062,rt $(TIMINGS)

	@cargo clean --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE)
	cargo build --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --package=imxrt-ral --features=imxrt1176_cm7,rt $(TIMINGS)

	@cargo clean --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE)
	cargo build --manifest-path=imxrt-ral/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv8m.main-none-eabihf --package=imxrt-ral --features=imxrt1189_cm33,rt $(TIMINGS)

imxrt-svd2rust:
	@mkdir -p $@

imxrt-ral/svd/%.svd.patched: $(SVDTOOLS)
	SVDTOOLS=../$(SVDTOOLS) $(MAKE) -C imxrt-ral svd/$*.svd.patched

imxrt-svd2rust/%: imxrt-ral/svd/%.svd.patched imxrt-svd2rust $(SVD2RUST) $(FORM)
	@mkdir -p $@
	@cp Cargo.toml.svd2rust $@/Cargo.toml
	@$(SVD2RUST) -i $< --output-dir $@
	@$(FORM) --input $@/lib.rs --outdir $@/src/
	@rm -f @/lib.rs
	@cargo fmt --manifest-path=$@/Cargo.toml

.PHONY: imxrt-svd2rust.shootout
imxrt-svd2rust.shootout: imxrt-svd2rust/imxrt1011 imxrt-svd2rust/imxrt1062
	@cargo update --manifest-path=imxrt-svd2rust/imxrt1011/Cargo.toml
	@cargo clean --manifest-path=imxrt-svd2rust/imxrt1011/Cargo.toml
	cargo build --manifest-path=imxrt-svd2rust/imxrt1011/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --features=rt $(TIMINGS)

	@cargo update --manifest-path=imxrt-svd2rust/imxrt1062/Cargo.toml
	@cargo clean --manifest-path=imxrt-svd2rust/imxrt1062/Cargo.toml
	cargo build --manifest-path=imxrt-svd2rust/imxrt1062/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --features=rt $(TIMINGS)

imxrt-chiptool:
	@mkdir -p $@

imxrt-chiptool/%: imxrt-ral/svd/%.svd.patched imxrt-chiptool $(CHIPTOOL) $(FORM)
	@mkdir -p $@
	@cp Cargo.toml.chiptool $@/Cargo.toml
	@cd $@ && ../../$(CHIPTOOL) generate --svd ../../$< --transform ../../transform.yaml && ../../$(FORM) --input lib.rs --outdir src/ && rm lib.rs
	@cargo fmt --manifest-path=$@/Cargo.toml

.PHONY: imxrt-chiptool.shootout
imxrt-chiptool.shootout: imxrt-chiptool/imxrt1011 imxrt-chiptool/imxrt1062 imxrt-chiptool/imxrt1176_cm7 imxrt-chiptool/imxrt1189_cm33
	@cargo update --manifest-path=imxrt-chiptool/imxrt1011/Cargo.toml
	@cargo clean --manifest-path=imxrt-chiptool/imxrt1011/Cargo.toml
	cargo build --manifest-path=imxrt-chiptool/imxrt1011/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --features=rt $(TIMINGS)

	@cargo update --manifest-path=imxrt-chiptool/imxrt1062/Cargo.toml
	@cargo clean --manifest-path=imxrt-chiptool/imxrt1062/Cargo.toml
	cargo build --manifest-path=imxrt-chiptool/imxrt1062/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --features=rt $(TIMINGS)

	@cargo update --manifest-path=imxrt-chiptool/imxrt1176_cm7/Cargo.toml
	@cargo clean --manifest-path=imxrt-chiptool/imxrt1176_cm7/Cargo.toml
	cargo build --manifest-path=imxrt-chiptool/imxrt1176_cm7/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv7em-none-eabihf --features=rt $(TIMINGS)

	@cargo update --manifest-path=imxrt-chiptool/imxrt1189_cm33/Cargo.toml
	@cargo clean --manifest-path=imxrt-chiptool/imxrt1189_cm33/Cargo.toml
	cargo build --manifest-path=imxrt-chiptool/imxrt1189_cm33/Cargo.toml --profile=$(PAC_PROFILE) --target=thumbv8m.main-none-eabihf --features=rt $(TIMINGS)