From 44b7e26fde1e84a94559d65ce3a8af1cf936d597 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sun, 6 Oct 2024 21:41:19 -0400 Subject: [PATCH] This other library might work if I make it static, but also land support for skipping specific classes from being generated --- Generator/Generator/ClassGen.swift | 10 ++++++---- Generator/Generator/main.swift | 9 +++++++++ Package.swift | 27 ++++++++++++--------------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Generator/Generator/ClassGen.swift b/Generator/Generator/ClassGen.swift index 45ffa75dd..ddff3a722 100644 --- a/Generator/Generator/ClassGen.swift +++ b/Generator/Generator/ClassGen.swift @@ -462,9 +462,11 @@ func generateProperties (_ p: Printer, } #if false -var okList = [ "RefCounted", "Node", "Sprite2D", "Node2D", "CanvasItem", "Object", "String", "StringName", "AStar2D", "Material", "Camera3D", "Node3D", "ProjectSettings", "MeshInstance3D", "BoxMesh", "SceneTree", "Window", "Label", "Timer", "AudioStreamPlayer", "PackedScene", "PathFollow2D", "InputEvent", "ClassDB", "AnimatedSprite2D", "Input", "CollisionShape2D", "SpriteFrames", "RigidBody2D" ] +var okList: Set = [ "RefCounted", "Node", "Sprite2D", "Node2D", "CanvasItem", "Object", "String", "StringName", "AStar2D", "Material", "Camera3D", "Node3D", "ProjectSettings", "MeshInstance3D", "BoxMesh", "SceneTree", "Window", "Label", "Timer", "AudioStreamPlayer", "PackedScene", "PathFollow2D", "InputEvent", "ClassDB", "AnimatedSprite2D", "Input", "CollisionShape2D", "SpriteFrames", "RigidBody2D" ] +var skipList = Set() #else -var okList: [String] = [] +var okList = Set() +var skipList = Set() #endif func generateClasses (values: [JGodotExtensionAPIClass], outputDir: String?) async { @@ -730,7 +732,7 @@ func processClass (cdef: JGodotExtensionAPIClass, outputDir: String?) async { } // Remove code that we did not want generated - if okList.count > 0 && !okList.contains (cdef.name) { + if skipList.contains (cdef.name) || (okList.count > 0 && !okList.contains (cdef.name)) { p.result = oResult } } @@ -742,7 +744,7 @@ func processClass (cdef: JGodotExtensionAPIClass, outputDir: String?) async { print ("Internal error: in processClass \(cdef.name)") continue } - if okList.count == 0 || okList.contains (cdef.name) { + if !skipList.contains (cdef.name) && (okList.count == 0 || okList.contains (cdef.name)) { generateVirtualProxy(p, cdef: cdef, methodName: methodName, method: methodDef) } } diff --git a/Generator/Generator/main.swift b/Generator/Generator/main.swift index 9991c5249..e1c504a13 100644 --- a/Generator/Generator/main.swift +++ b/Generator/Generator/main.swift @@ -148,6 +148,15 @@ if singleFile { try! FileManager.default.createDirectory(atPath: generatedDir, withIntermediateDirectories: true) } +//#if os(Windows) +//// Because we generate too many symbols for Windows to be able to compile the library +//// we eliminate some rare classes from the build. This is a temporary hack to unblock +//// people while I split SwiftGodot into smaller chunks. +//skipList.insert("RenderingServer") +//skipList.insert("WebXRInterface") +//skipList.insert("OpenXRInterface") +//#endif + let semaphore = DispatchSemaphore(value: 0) let _ = Task { let coreDefPrinter = await PrinterFactory.shared.initPrinter("core-defs") diff --git a/Package.swift b/Package.swift index 847c00de1..8590485d2 100644 --- a/Package.swift +++ b/Package.swift @@ -12,8 +12,19 @@ import CompilerPluginSupport //])) //#endif +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, + targets: ["SwiftGodot"]), .library( name: "SwiftGodotStatic", targets: ["SwiftGodot"]), @@ -26,26 +37,12 @@ var products: [Product] = [ .plugin(name: "CodeGeneratorPlugin", targets: ["CodeGeneratorPlugin"]), ] -#if os(Windows) -products.append( - .library( - name: "SwiftGodot", - type: .static, - targets: ["SwiftGodot"])) -#else -products.append( - .library( - name: "SwiftGodot", - type: .dynamic, - targets: ["SwiftGodot"])) -#endif - // Macros aren't supported on Windows before 5.9.1 and this sample uses them #if !(os(Windows) && swift(<5.9.1)) products.append( .library( name: "SimpleExtension", - type: .dynamic, + type: libraryType, targets: ["SimpleExtension"])) #endif