Skip to content

Commit ec41a6e

Browse files
committed
Move generated registers into discrete modules
Updates the stm32 examples to put generated register interfaces into their own module. This improves build performance because the swiftmodule containing the generated registers doesn't need to be rebuilt when the primary application changes. Ideally these registers would be generated using the SVD2SwiftPlugin instead of directly checked into the repo, however there is a huge build time cost to this because SwiftPM has separate build graphs for plugins vs the primary build. This results in 2 copies of swift-syntax getting built which inflates build time to 5+ minutes. Worse, SwiftPM randomly triggers rebuilds of swift-syntax in the plugin graph making using the plugin effectively impossible.
1 parent 2c0edcc commit ec41a6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+6095
-5961
lines changed

stm32-lcd-logo/Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "5728b1ec253c3300a921ee6ddc3c43ff685abaa7f6ca8d86433af91b7883bf79",
2+
"originHash" : "0259de139c240d30a60426d7d7f2d119ccc92fffcb5377eccefe0c9a21e3ef9c",
33
"pins" : [
44
{
55
"identity" : "swift-argument-parser",
@@ -16,7 +16,7 @@
1616
"location" : "https://github.com/apple/swift-mmio",
1717
"state" : {
1818
"branch" : "main",
19-
"revision" : "daf25ecacc0d9b71036c6af32cb7786a01802799"
19+
"revision" : "5232c5129a8c70beafc3d6acfbae2716c1b6822a"
2020
}
2121
},
2222
{

stm32-lcd-logo/Package.swift

+18-9
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,28 @@ let package = Package(
1111
.package(url: "https://github.com/apple/swift-mmio", branch: "main")
1212
],
1313
targets: [
14-
// SVD2Swift \
15-
// --input Tools/SVDs/stm32f7x6.patched.svd \
16-
// --output stm32-lcd-logo/Sources/STM32F7x6 \
17-
// --peripherals FLASH GPIOA GPIOB GPIOC GPIOD GPIOE GPIOF GPIOG GPIOH GPIOI GPIOJ GPIOK LTDC RCC
1814
.executableTarget(
1915
name: "Application",
20-
dependencies: [
21-
.product(name: "MMIO", package: "swift-mmio"),
22-
"Support",
23-
],
16+
dependencies: ["STM32F7X6", "Support"],
2417
swiftSettings: [
2518
.enableExperimentalFeature("InlineArrayTypeSugar"),
2619
.enableExperimentalFeature("SymbolLinkageMarkers"),
2720
]),
21+
// SVD2Swift \
22+
// --input Sources/STM32F7X6/stm32f7x6.patched.svd \
23+
// --output Sources/STM32F7X6 \
24+
// --access-level public \
25+
// --indentation-width 2 \
26+
// --peripherals FLASH GPIOA GPIOB GPIOC GPIOD GPIOE GPIOF GPIOG GPIOH GPIOI GPIOJ GPIOK LTDC RCC
27+
.target(
28+
name: "STM32F7X6",
29+
dependencies: [
30+
.product(name: "MMIO", package: "swift-mmio")
31+
],
32+
plugins: [
33+
// Plugin disabled because SwiftPM is slow.
34+
// .plugin(name: "SVD2SwiftPlugin", package: "swift-mmio")
35+
]),
2836
.target(name: "Support"),
29-
])
37+
],
38+
swiftLanguageModes: [.v5])

stm32-lcd-logo/Sources/Application/Application.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
import STM32F7X6
1213
import Support
1314

1415
@main

stm32-lcd-logo/Sources/Application/HAL/GPIOA+Helpers.swift

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
import STM32F7X6
13+
1214
extension GPIOA {
1315
public enum Port: Int {
1416
case a, b, c, d, e, f, g, h, i, j, k

stm32-lcd-logo/Sources/Application/HAL/LTDC+Helpers.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
import STM32F7X6
1213
import Support
1314

1415
extension LTDC {

stm32-lcd-logo/Sources/Application/HAL/RCC+Helpers.swift

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift project authors.
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
import STM32F7X6
13+
114
extension RCC {
215
func enableGPIOPortClock(_ port: GPIOA.Port) {
316
switch port {

stm32-lcd-logo/Sources/Application/Registers/Device.swift

-45
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Generated by svd2swift.
2+
3+
import MMIO
4+
5+
/// FLASH
6+
public let flash = FLASH(unsafeAddress: 0x40023c00)
7+
8+
/// General-purpose I/Os
9+
public let gpioa = GPIOA(unsafeAddress: 0x40020000)
10+
11+
/// General-purpose I/Os
12+
public let gpiob = GPIOB(unsafeAddress: 0x40020400)
13+
14+
/// General-purpose I/Os
15+
public let gpioc = GPIOC(unsafeAddress: 0x40020800)
16+
17+
/// General-purpose I/Os
18+
public let gpiod = GPIOD(unsafeAddress: 0x40020c00)
19+
20+
/// General-purpose I/Os
21+
public let gpioe = GPIOE(unsafeAddress: 0x40021000)
22+
23+
/// General-purpose I/Os
24+
public let gpiof = GPIOF(unsafeAddress: 0x40021400)
25+
26+
/// General-purpose I/Os
27+
public let gpiog = GPIOG(unsafeAddress: 0x40021800)
28+
29+
/// General-purpose I/Os
30+
public let gpioh = GPIOH(unsafeAddress: 0x40021c00)
31+
32+
/// General-purpose I/Os
33+
public let gpioi = GPIOI(unsafeAddress: 0x40022000)
34+
35+
/// General-purpose I/Os
36+
public let gpioj = GPIOJ(unsafeAddress: 0x40022400)
37+
38+
/// General-purpose I/Os
39+
public let gpiok = GPIOK(unsafeAddress: 0x40022800)
40+
41+
/// LCD-TFT Controller
42+
public let ltdc = LTDC(unsafeAddress: 0x40016800)
43+
44+
/// Reset and clock control
45+
public let rcc = RCC(unsafeAddress: 0x40023800)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift project authors.
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
// This file is intentionally left empty for SwiftPM to recognize the target as
13+
// a Swift source module.

0 commit comments

Comments
 (0)