Skip to content

Commit

Permalink
This other library might work if I make it static, but also land supp…
Browse files Browse the repository at this point in the history
…ort for skipping specific classes from being generated
  • Loading branch information
migueldeicaza committed Oct 7, 2024
1 parent 793a278 commit 44b7e26
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
10 changes: 6 additions & 4 deletions Generator/Generator/ClassGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = [ "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<String>()
#else
var okList: [String] = []
var okList = Set<String>()
var skipList = Set<String>()
#endif

func generateClasses (values: [JGodotExtensionAPIClass], outputDir: String?) async {
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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)
}
}
Expand Down
9 changes: 9 additions & 0 deletions Generator/Generator/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
27 changes: 12 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand All @@ -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

Expand Down

0 comments on commit 44b7e26

Please sign in to comment.