-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (60 loc) · 2.16 KB
/
Makefile
File metadata and controls
74 lines (60 loc) · 2.16 KB
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
# SPDX-License-Identifier: MIT
all: build
CONFIG_PATH = .config/config.mk
include $(CONFIG_PATH)
MAKEFLAGS += --silent -j$(shell nproc)
SHELL := /usr/bin/env bash
OUTPUT = $(shell pwd)/output
BUILDDIR = $(shell pwd)/build
BADGER_RAMFS_ROOT ?= $(shell pwd)/../files/root
CROSS_COMPILE = $(CONFIG_PREFIX)
GDB ?= $(CROSS_COMPILE)gdb
CLANG_FORMAT ?= clang-format-18
CLANG_TIDY ?= clang-tidy-18
DRIVE ?= /dev/null
PORT ?= /dev/ttyUSB1
.PHONY: build
build: cmake-configure
mkdir -p target
echo "pub const RELEASE: &'static str = \"$$(echo -n $$(git describe --tags --always --dirty))\";" > target/version.rs
echo "pub const VERSION: &'static str = \"$$(echo -n $$(date '+%Y-%m-%d %H:%M:%S %Z'))\";" >> target/version.rs
cmake --build '$(BUILDDIR)'
cmake --install '$(BUILDDIR)' --prefix '$(OUTPUT)'
.PHONY: cmake-configure
cmake-configure:
mkdir -p '$(BUILDDIR)'
cmake -B '$(BUILDDIR)'
.PHONY: config
config: cmake-configure
ccmake . -B build
.PHONY: selarch
selarch:
./tools/selarch.py
.PHONY: clean
clean:
rm -rf '$(BUILDDIR)' '$(OUTPUT)'
.PHONY: clang-format-check
clang-format-check: cmake-configure
echo "clang-format check the following files:"
jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$'
echo "analysis results:"
$(CLANG_FORMAT) --dry-run $(shell jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$')
.PHONY: clang-tidy-check
clang-tidy-check: cmake-configure
echo "clang-tidy check the following files:"
jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$'
echo "analysis results:"
$(CLANG_TIDY) -p build $(shell jq -r '.[].file' build/compile_commands.json | grep '\.[ch]$$') \
--checks=-*widening*multiplication*,-*insecureAPI* \
--warnings-as-errors="*"
.PHONY: gdb
gdb:
$(GDB) -x misc/gdbinit build/badger-os.elf
.PHONY: burn
burn: build
sudo dd if=$(OUTPUT)/image.iso of=$(DRIVE) bs=1M oflag=sync conv=nocreat
.PHONY: monitor
monitor:
echo -e "\033[1mType ^A^X to exit.\033[0m"
picocom -q -b 115200 '$(PORT)' \
| ../tools/address-filter.py -A $(CROSS_COMPILE)addr2line '$(OUTPUT)/badger-os.elf'; echo -e '\033[0m'