Skip to content

Commit

Permalink
Swift 6, SwiftUnicodeDataTables, Other Improvements (#106)
Browse files Browse the repository at this point in the history
* Require Swift 6 and tools v6

* Fix build error

* Remove pdc flag skip-unown

* Add build flag for linking swiftUnicodeDataTables

* Improve swift toolchain lookup

* Use clang in swift toolchain

* Improve product module lookup

* Add documentation

* Fix build errors

* Chip away at deprecations

* Remove merge conflict junk

* Add hack for SwiftUnicodeDataTables

* Use chosen Playdate SDK

* Show built pdx path in build output

* Improve build output

* Add swiftUnicodeDataTables source as a module

* Export so symbols are available

* Remove linking hacks

* Fix deprecations

* Add support for C/C++ modules

* Fix deprecation

* Link compiled Clang libraries

* Continue Add support for C/C++ modules

* Remove unused var

* Use Task

* Remove explicit cxx language mode

* Remove debug symbols from pdx

* Verify file exists first

* Fix flag order

Flags were being ignored by the pdc cli

* Increase output clarity

* Remove trailing slash

URL takes care of this. The previous Path type did not

* Remove tmp debug output

* Revert fix flag order

* Add output note
  • Loading branch information
STREGA authored Dec 10, 2024
1 parent d76c975 commit cb1af58
Show file tree
Hide file tree
Showing 25 changed files with 57,775 additions and 170 deletions.
95 changes: 59 additions & 36 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
// swift-tools-version: 5.10
// swift-tools-version: 6.0

import PackageDescription

let gccIncludePrefix =
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/lib/gcc/arm-none-eabi/9.2.1"

let playdateSDKPath: String = if let path = Context.environment["PLAYDATE_SDK_PATH"] {
path
} else {
"\(Context.environment["HOME"]!)/Developer/PlaydateSDK/"
}

let package = Package(
name: "PlaydateKit",
platforms: [.macOS(.v14)],
Expand All @@ -19,32 +10,64 @@ let package = Package(
.plugin(name: "PDCPlugin", targets: ["PDCPlugin"])
],
targets: [
.target(name: "PlaydateKit", dependencies: ["CPlaydate"], swiftSettings: [
.enableExperimentalFeature("Embedded"),
.unsafeFlags([
"-Xfrontend", "-disable-objc-interop",
"-Xfrontend", "-disable-stack-protector",
"-Xfrontend", "-function-sections",
"-Xfrontend", "-gline-tables-only",
"-Xcc", "-DTARGET_EXTENSION",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include-fixed",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/../../../../arm-none-eabi/include",
"-I", "\(playdateSDKPath)/C_API"
]),
]),
.target(name: "CPlaydate", cSettings: [
.unsafeFlags([
"-DTARGET_EXTENSION",
"-I", "\(gccIncludePrefix)/include",
"-I", "\(gccIncludePrefix)/include-fixed",
"-I", "\(gccIncludePrefix)/../../../../arm-none-eabi/include",
"-I", "\(playdateSDKPath)/C_API"
])
]),
.target(
name: "PlaydateKit",
dependencies: ["CPlaydate", "SwiftUnicodeDataTables"],
swiftSettings: swiftSettings
),
.target(
name: "CPlaydate",
cSettings: [
.unsafeFlags([
"-DTARGET_EXTENSION",
"-I", "\(gccIncludePrefix)/include",
"-I", "\(gccIncludePrefix)/include-fixed",
"-I", "\(gccIncludePrefix)/../../../../arm-none-eabi/include",
"-I", "\(playdateSDKPath)/C_API"
])
]
),
.target(
name: "SwiftUnicodeDataTables",
cxxSettings: [
.define("SWIFT_STDLIB_ENABLE_UNICODE_DATA")
]
),
.plugin(
name: "PDCPlugin",
capability: .command(intent: .custom(verb: "pdc", description: "Runs the Playdate compiler"))
)
]
capability: .command(intent:
.custom(verb: "pdc", description: "Runs the Playdate compiler")
)
),
],
swiftLanguageModes: [.v6]
)


// MARK: - Helper Variables
// note: These must be computed variables when beneath the `let package =` declaration.

var swiftSettings: [SwiftSetting] {[
.enableExperimentalFeature("Embedded"),
.unsafeFlags([
"-whole-module-optimization",
"-Xfrontend", "-disable-objc-interop",
"-Xfrontend", "-disable-stack-protector",
"-Xfrontend", "-function-sections",
"-Xfrontend", "-gline-tables-only",
"-Xcc", "-DTARGET_EXTENSION",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include-fixed",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/../../../../arm-none-eabi/include",
"-I", "\(playdateSDKPath)/C_API"
]),
]}
var gccIncludePrefix: String {
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/lib/gcc/arm-none-eabi/9.2.1"
}
var playdateSDKPath: String {
if let path = Context.environment["PLAYDATE_SDK_PATH"] {
return path
}
return "\(Context.environment["HOME"]!)/Developer/PlaydateSDK/"
}
Loading

0 comments on commit cb1af58

Please sign in to comment.