Skip to content

Commit

Permalink
Build As DLL, Use Swift 6.1 prelease, on Windows (#652)
Browse files Browse the repository at this point in the history
* Swift 6.1 can use the .buildCommand on Windows

* Fix Xcode version for CI

* also build as shared lib on Windows

* try using swift-6.1 snapshot on Windows

* Cleaned up Package.swift a bit.
  • Loading branch information
samdeane authored Jan 24, 2025
1 parent 7fef9be commit 129834e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.0"
xcode-version: "16.2"
- name: Build
run: swift build --build-tests --quiet
- name: Run tests (Swift testing)
Expand All @@ -40,8 +40,8 @@ jobs:
- name: Swift Install
uses: compnerd/gha-setup-swift@main
with:
branch: swift-6.0.3-release
tag: 6.0.3-RELEASE
branch: swift-6.1-branch
tag: 6.1-DEVELOPMENT-SNAPSHOT-2025-01-22-a
- uses: actions/checkout@v4
- name: Build
run: |
Expand Down
19 changes: 7 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
import CompilerPluginSupport
import PackageDescription

var libraryType: Product.Library.LibraryType
#if os(Windows)
libraryType = .static
#else
libraryType = .dynamic
#endif

// Products define the executables and libraries a package produces, and make them visible to other packages.
var products: [Product] = [
.library(
name: "SwiftGodot",
type: libraryType,
type: .dynamic,
targets: ["SwiftGodot"]
),

Expand Down Expand Up @@ -43,11 +36,12 @@ var products: [Product] = [

.library(
name: "SimpleExtension",
type: libraryType,
type: .dynamic,
targets: ["SimpleExtension"]
),
]

/// Targets are the basic building blocks of a package. A target can define a module, plugin, test suite, etc.
var targets: [Target] = [
.executableTarget(
name: "EntryPointGenerator",
Expand Down Expand Up @@ -95,13 +89,16 @@ var targets: [Target] = [
),

// This is a build-time plugin that invokes the generator and produces
// the bindings that are compiled into SwiftGodot
// the bindings that are compiled into SwiftGodot.
.plugin(
name: "CodeGeneratorPlugin",
capability: .buildTool(),
dependencies: ["Generator"]
),

// This is a build-time plugin that generates the EntryPoint.swift file,
// which is used to bootstrap the SwiftGodot API and register your
// extension and classes with Godot.
.plugin(
name: "EntryPointGeneratorPlugin",
capability: .buildTool(),
Expand Down Expand Up @@ -133,15 +130,13 @@ var targets: [Target] = [
exclude: ["SwiftSprite.gdextension", "README.md"],
swiftSettings: [.swiftLanguageMode(.v5)]
),
//linkerSettings: linkerSettings),

// This is the binding itself, it is made up of our generated code for the
// Godot API, supporting infrastructure and extensions to the API to provide
// a better Swift experience
.target(
name: "SwiftGodot",
dependencies: ["GDExtension"],
//linkerSettings: linkerSettings,
swiftSettings: [
.swiftLanguageMode(.v5),
.define("CUSTOM_BUILTIN_IMPLEMENTATIONS"),
Expand Down
15 changes: 5 additions & 10 deletions Plugins/CodeGeneratorPlugin/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,20 @@ import PackagePlugin
}
arguments.append(context.package.directoryURL.appending(path: "doc").path)
arguments.append("--combined")
commands.append(
Command.prebuildCommand(
displayName: "Generating Swift API from \(api) to \(genSourcesDir)",
executable: generator,
arguments: arguments,
outputFilesDirectory: genSourcesDir
)
)
#else
outputFiles.append(contentsOf: knownBuiltin.map { genSourcesDir.appending(["generated-builtin", $0]) })
outputFiles.append(contentsOf: known.map { genSourcesDir.appending(["generated", $0]) })
#endif

commands.append(
Command.buildCommand(
displayName: "Generating Swift API from \(api) to \(genSourcesDir)",
executable: generator,
arguments: arguments,
inputFiles: [api],
outputFiles: outputFiles))
#endif
outputFiles: outputFiles
)
)

return commands
}
Expand Down

0 comments on commit 129834e

Please sign in to comment.