-
Notifications
You must be signed in to change notification settings - Fork 3
/
Package.swift
97 lines (95 loc) · 3.32 KB
/
Package.swift
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
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "RP2040",
products: [
// The main executable for the RP2040, written in Swift.
// This is the program we want to flash to the RP2040.
//
// Ideally, this would be an executable product, but I couldn't get that
// to work under Embedded Swift. So we build a static library and then
// use the Link plugin to link it into an .elf file.
.library(name: "App", type: .static, targets: ["App"]),
.library(name: "RP2040Boot2", type: .static, targets: ["RP2040Boot2"]),
],
targets: [
// The main executable for the RP2040, written in Swift.
.target(
name: "App",
dependencies: ["RP2040"],
swiftSettings: [
.enableExperimentalFeature("Embedded"),
.unsafeFlags([
"-whole-module-optimization",
"-Xfrontend", "-function-sections",
]),
]
),
// Our RP2040 "SDK", written in Swift. Vends the APIs used by the app.
.target(
name: "RP2040",
dependencies: ["MMIOVolatile", "RP2040Support"],
swiftSettings: [
.enableExperimentalFeature("Embedded"),
.unsafeFlags([
"-whole-module-optimization",
"-Xfrontend", "-function-sections",
]),
]
),
.target(name: "MMIOVolatile", publicHeadersPath: ""),
// Minimal RP2040 runtime support, linker script, etc.
.target(
name: "RP2040Support",
exclude: [
"linker-script",
],
publicHeadersPath: "",
cSettings: [
.headerSearchPath("headers"),
.define("NDEBUG"),
.unsafeFlags([
"-mfloat-abi=soft",
"-march=armv6m",
"-ffunction-sections",
"-fdata-sections",
]),
]
),
// The second-stage bootloader (Boot2) for the RP2040.
.target(
name: "RP2040Boot2",
exclude: [
"linker-script",
],
publicHeadersPath: "",
cSettings: [
.headerSearchPath("headers"),
.define("NDEBUG"),
.unsafeFlags([
"-mfloat-abi=soft",
"-march=armv6m",
"-ffunction-sections",
"-fdata-sections",
]),
]
),
// SwiftPM plugin for linking the final executable.
// This creates the .elf file we can flash to the RP2040.
.plugin(
name: "Link",
capability: .command(
intent: .custom(
verb: "link",
description: "Links the final executable for the RP2040"
)
),
dependencies: [
"RP2040Boot2Checksum",
]
),
// Computes the CRC32 checksum for the second-stage bootloader.
.executableTarget(name: "RP2040Boot2Checksum"),
]
)