Skip to content

Commit

Permalink
use @main instead of top-level code
Browse files Browse the repository at this point in the history
This commit renames main.swift to Generator.swift, which is necessary to use the @main annotation.

This commit attaches the @main annotation to GeneratorCommand and
removes the top-level code that used a DispatchSemaphore hack to wait
synchronously for an async to finish.
  • Loading branch information
Rob Mayoff committed Nov 25, 2024
1 parent a8b4d28 commit 1e8ea51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let generateResettableCache = false
//skipList.insert("OpenXRInterface")
//#endif

@main
struct GeneratorCommand: AsyncParsableCommand {
@Flag(
help: "Generator all output to a single Swift file. Possibly useful on Windows."
Expand Down Expand Up @@ -205,12 +206,3 @@ struct Generator {
}
}
}

let semaphore = DispatchSemaphore(value: 0)
let _ = Task {
defer { semaphore.signal() }
await GeneratorCommand.main()
}
semaphore.wait()

//print ("Done")
4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ var targets: [Target] = [
exclude: ["README.md"],
swiftSettings: [
// Uncomment for using legacy array-based marshalling
//.define("LEGACY_MARSHALING")
//.define("LEGACY_MARSHALING"),

//.enableExperimentalFeature("StrictConcurrency"),
]
),

Expand Down

0 comments on commit 1e8ea51

Please sign in to comment.