Skip to content

Commit

Permalink
This builds and generates something, but I have still work left to do…
Browse files Browse the repository at this point in the history
…: the generated uid is broken, and I need solve the need for two libraries rather than one, and the clash with the Editor
  • Loading branch information
migueldeicaza committed Oct 2, 2023
1 parent 6506c69 commit a215240
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Sources/SwiftGodotEditorExtension/SwiftEditorPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SwiftEditorPlugin: EditorPlugin {

/// The filename where we generate the Swift dynamic library type initialization
lazy var typeRegistrationFile: String = {
projectBaseDir + "Sources/\(extensionName)/Startup.swift"
projectBaseDir + "Sources/\(extensionName)/_Startup.swift"
}()

/// Points to the directory where the Swift source files are stored
Expand Down Expand Up @@ -86,7 +86,7 @@ class SwiftEditorPlugin: EditorPlugin {


for file in files {
print ("BUILD CONSIDERING: \(file)")
guard file != "_Startup.swift" else { continue }
guard file.hasSuffix(".swift") else { continue }
let basename = String (file.dropLast (6))
if typeList != "" {
Expand All @@ -98,6 +98,7 @@ class SwiftEditorPlugin: EditorPlugin {

let typeInit =
"""
import SwiftGodot
import SwiftGodotMacros
#initSwiftExtension (cdecl: "\(extensionEntryPoint)", types: [\(typeList)])
Expand Down Expand Up @@ -146,10 +147,14 @@ class SwiftEditorPlugin: EditorPlugin {
// TODO: for Apple platforms, I should lipo the binaries into a single one
for platform in ["x86_64-apple-macosx", "arm64-apple-macosx"] {
for kind in ["debug", "release"] {
for library in ["SwiftGodot", "SwiftExtension"] {
for library in ["SwiftGodot", "SwiftExtension", "SwiftGodotMacros"] {
// TODO: add support for Windows and Linux (dll and .so) but will need to
for ext in ["dylib"] {
try? FileManager.default.copyItem(atPath: "\(projectBaseDir)/.build/\(platform)/\(kind)/lib\(library).\(ext)", toPath: "\(projectBaseDir)/bin/")
let file = "lib\(library).\(ext)"
let source = "\(projectBaseDir)/.build/\(platform)/\(kind)/\(file)"
let target = "\(projectBaseDir)/bin/\(file)"
print ("Copying \(source) to \(target)")
try? FileManager.default.copyItem(atPath: source, toPath: target)
}
}
}
Expand Down Expand Up @@ -235,7 +240,7 @@ let package = Package(
targets: [
.target(
name: "@EXT_NAME@",
dependencies: ["SwiftGodot"],
dependencies: ["SwiftGodot", .product (name: "SwiftGodotMacros", package: "SwiftGodot")],
swiftSettings: [.unsafeFlags (["-suppress-warnings"])],
linkerSettings: [.unsafeFlags (
["-Xlinker", "-undefined",
Expand Down

0 comments on commit a215240

Please sign in to comment.