-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathMakefile
55 lines (48 loc) · 1.63 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
##===----------------------------------------------------------------------===##
##
## This source file is part of the Swift open source project
##
## Copyright (c) 2023 Apple Inc. and the Swift project authors.
## Licensed under Apache License v2.0 with Runtime Library Exception
##
## See https://swift.org/LICENSE.txt for license information
##
##===----------------------------------------------------------------------===##
# Paths
REPOROOT := $(shell git rev-parse --show-toplevel)
TOOLSROOT := $(REPOROOT)/Tools
TOOLSET := $(TOOLSROOT)/Toolsets/stm32f74x-lcd.json
MACHO2BIN := $(TOOLSROOT)/macho2bin.py
SWIFT_BUILD := swift build
# Flags
ARCH := armv7em
TARGET := $(ARCH)-apple-none-macho
SWIFT_BUILD_ARGS := \
--configuration release \
--triple $(TARGET) \
--toolset $(TOOLSET) \
--disable-local-rpath
BUILDROOT := $(shell $(SWIFT_BUILD) $(SWIFT_BUILD_ARGS) --show-bin-path)
.PHONY: build
build:
@echo "building..."
$(SWIFT_BUILD) \
$(SWIFT_BUILD_ARGS) \
-Xlinker -map -Xlinker $(BUILDROOT)/Application.mangled.map \
--verbose
@echo "demangling linker map..."
cat $(BUILDROOT)/Application.mangled.map \
| c++filt | swift demangle > $(BUILDROOT)/Application.map
@echo "disassembling..."
otool \
-arch $(ARCH) -v -V -d -t \
$(BUILDROOT)/Application \
| c++filt | swift demangle > $(BUILDROOT)/Application.disassembly
@echo "extracting binary..."
$(MACHO2BIN) \
$(BUILDROOT)/Application $(BUILDROOT)/Application.bin --base-address 0x00200000 --segments '__TEXT,__DATA,__VECTORS'
.PHONY: clean
clean:
@echo "cleaning..."
@swift package clean
@rm -rf .build