Support SwiftPM and add Swift bindings for v6#2958
Draft
Lancelotbronner wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Your checklist for this pull request
Detailed description
I'm depending on capstone v6 for a macOS app prototype, as such I need Swift bindings and integration into SwiftPM.
While there is already another PR that did so, it seemed extremely intrusive to capstone, attempting to force it into SwiftPM's default convention rather than configuring SwiftPM appropriately.
Here are my changes to support building capstone with SwiftPM:
Package.swift, thecapstonetarget builds capstone.incfile, they can be manually added toexcludeto avoid them but I didn't feel like doing that yet.module.modulemap, this is needed by Clang as part of Xcode's build systemHere are my changes to add (nice, safer) Swift bindings:
Package.swift, theCapstoneKittarget wraps capstone where possible.Capstone.apinotes, a sidecar file that provides Clang with additional information and renames to make the automatically generated Swift bindings more "Swifty". It's very incomplete and some parts could likely be script-generated. See Clang's documentation. See Swift's extensions.bindings/swift/CapstoneKit.swiftwith a few work-in-progress wrapper typesTest plan
All
Capstone.apinotesbindings are automatically generated by Swift.There is no need to separately test them.
Only the APIs in
bindings/swiftneed to be tested, and I'm using them in my prototype.