forked from oreboot/oreboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (104 loc) · 4.28 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
help:
@echo 'Make options:'
@echo 'firsttime -- for the first time you run make'
@echo 'update -- to update the install'
@echo 'format -- to format all files'
@echo 'checkformat -- to format all files with checking enabled'
@echo ' # Build a single board'
@echo ' make VENDOR/BOARD'
@echo ' # This is equivalent to'
@echo ' cd src/mainboard/VENDOR/BOARD && make'
@echo ' # Build all mainboards'
@echo ' make mainboards'
@echo ' # Build everything in parallel'
@echo ' make -j mainboards'
@echo ' # Build debug mode'
@echo ' MODE=debug make mainboards'
# Turn them all off. We'll turn them back on to try to get to working tests.
MAINBOARDS := $(wildcard src/mainboard/*/*/Makefile)
TOOLCHAIN_VER := $(shell grep channel rust-toolchain.toml | grep -e '".*"' -o)
BINUTILS_VER := 0.3.2
STACK_SIZES_VER := 0.4.0
CARGOINST := rustup run --install nightly cargo install
.PHONY: mainboards $(MAINBOARDS)
mainboard: $(MAINBOARDS)
$(MAINBOARDS):
cd $(dir $@) && make cibuild
firsttime:
$(CARGOINST) $(if $(BINUTILS_VER),--version $(BINUTILS_VER),) cargo-binutils
$(CARGOINST) $(if $(STACK_SIZES_VER),--version $(STACK_SIZES_VER),) stack-sizes
rustup target add riscv64imac-unknown-none-elf
rustup target add riscv64gc-unknown-none-elf
nexttime:
rustup toolchain install $(TOOLCHAIN_VER)
rustup component add llvm-tools-preview rust-src --toolchain $(TOOLCHAIN_VER)
$(CARGOINST) --force $(if $(BINUTILS_VER),--version $(BINUTILS_VER),) cargo-binutils
$(CARGOINST) --force $(if $(STACK_SIZES_VER),--version $(STACK_SIZES_VER),) stack-sizes
rustup target add riscv64imac-unknown-none-elf
rustup target add riscv64gc-unknown-none-elf
firsttime_fsp:
sudo apt-get install build-essential uuid-dev iasl gcc nasm python3-distutils libclang-dev
git submodule update --init --recursive
debiansysprepare:
sudo apt-get install device-tree-compiler pkg-config libssl-dev llvm-dev libclang-dev clang qemu-system-x86
# --default-toolchain is purely an optimization to avoid downloading stable Rust first.
# -y makes it non-interactive.
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $(TOOLCHAIN_VER)
.PHONY: ciprepare debiansysprepare firsttime
ciprepare: debiansysprepare firsttime firsttime_fsp
update:
rustup update
# Option used for formatting. If set, the command will only verify if
# formatting is correct (without actually changing the formatting).
# Returns 0 only if all files are properly formatted.
# Usage:
# $ make --keep-going format
# $ make --keep-going checkformat
check ?=
# NOTE: do NOT use the cargo command in targets below.
# ALWAYS USE MAKE!
ALLMAKEFILE := \
$(wildcard payloads/Makefile) \
$(wildcard payloads/*/Makefile) \
$(wildcard payloads/*/*/Makefile) \
$(wildcard payloads/*/*/*/Makefile) \
$(wildcard payloads/*/*/*/*/Makefile) \
$(wildcard src/Makefile) \
$(wildcard src/*/Makefile) \
$(wildcard src/*/*/Makefile) \
$(wildcard src/*/*/*/Makefile) \
$(wildcard src/*/*/*/*/Makefile)
# Ron still doesn't understand this
TEST_ALL_MAKE_DEFAULT := $(patsubst %/Makefile,%/Makefile.default,$(ALLMAKEFILE))
$(TEST_ALL_MAKE_DEFAULT):
cd $(dir $@) && make default
.PHONY: testdefault $(TEST_ALL_MAKE_DEFAULT)
testdefault: $(TEST_ALL_MAKE_DEFAULT)
CRATES_TO_FORMAT := $(patsubst %/Makefile,%/Makefile.format,$(ALLMAKEFILE))
$(CRATES_TO_FORMAT):
cd $(dir $@) && make format -- $(if $(check),--check,)
.PHONY: format $(CRATES_TO_FORMAT)
format: $(CRATES_TO_FORMAT)
CRATES_TO_CHECKFORMAT := $(patsubst %/Makefile,%/Makefile.checkformat,$(ALLMAKEFILE))
$(CRATES_TO_CHECKFORMAT):
cd $(dir $@) && make checkformat
.PHONY: checkformat $(CRATES_TO_CHECKFORMAT)
checkformat: $(CRATES_TO_CHECKFORMAT)
# There are a number of targets which can not test.
# Once those are fixed, we can just use a test target.
CRATES_TO_TEST := $(patsubst %/Makefile,%/Makefile.test,$(ALLMAKEFILE))
$(CRATES_TO_TEST):
cd $(dir $@) && make citest
.PHONY: test $(CRATES_TO_TEST)
test: $(CRATES_TO_TEST)
# TODO: Remove write_with_newline
CRATES_TO_CLIPPY := $(patsubst %/Makefile,%/Makefile.clippy,$(ALLMAKEFILE))
$(CRATES_TO_CLIPPY):
cd $(dir $@) && make ciclippy
.PHONY: clippy $(CRATES_TO_CLIPPY)
clippy: $(CRATES_TO_CLIPPY)
# convenience target: this should be the full ci flow
checkandbuildall: ciprepare clippy checkformat test mainboards
echo "Done CI!"
clean:
rm -rf $(wildcard src/mainboard/*/*/target)