-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (36 loc) · 1.04 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
SWIFT_TOOLCHAIN := ~/Developer/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-03-a-debian12/usr/bin
SWIFT := $(SWIFT_TOOLCHAIN)/swift
SWIFTC := $(SWIFT_TOOLCHAIN)/swiftc
CLANG := $(SWIFT_TOOLCHAIN)/clang
ARCH := armv7em
TARGET := $(ARCH)-none-none-eabi
.PHONY: build
build:
@echo "compiling..."
$(SWIFT) build \
--configuration release \
--verbose \
--triple $(TARGET) \
-Xcc -ffreestanding \
-Xswiftc -Xfrontend -Xswiftc -disable-stack-protector
$(CLANG) -target $(TARGET) -c Support/Startup.c -o .build/Startup.o
$(CLANG) -target $(TARGET) -c Support/Support.c -o .build/Support.o
@echo "linking..."
$(CLANG) -v -target $(TARGET) -fuse-ld=lld -nostdlib -static \
-Wl,-e,vector_table -Wl,--gc-sections -Wl,-T,linkerscript.ld \
.build/Startup.o \
.build/Support.o \
.build/release/libApplication.a \
-o a.elf
.PHONY: flash
flash:
@echo "flashing..."
~/ST/bin/STM32_Programmer_CLI -c port=SWD -d a.elf -s
.PHONY: run
run: build flash
.PHONY: clean
clean:
@echo "cleaning..."
@$(SWIFT) package clean
@rm -f a.elf
@rm -rf .build