Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift: Config for Swift Package build #2420

Closed
wants to merge 3 commits into from

Conversation

andyf-canva
Copy link
Collaborator

@andyf-canva andyf-canva commented Jun 19, 2024

Recently we have opened a new ThorVG for Swift repo: thorvg.swift.

Code will be migrated from a Swift fork thorvg-swift. You can see more details here at the GitHub issue on the repo.

In order to build the Swift Package, with the thorvg core as a submodule inside the thorvg.swift repo, the following changes need to take place for the upstream thorvg repo. These are what are currently allowing the thorvg-swift repo to build.

Config header file

When building the thorvg source using the meson build system, we spit out a config.h inside the output builddir/ directory. Many of the C++ source files refer to this at compile time.

Swift Package Manager doesn't follow the same paradigm, and requires all files to be present in the target directory at compile time. Thus, we need to generate a config.h file ahead of time so that SPM can see that header file and successfully build all of the C++ source files.

For time being, I've put this underneath the C API bindings folder, but am open to another destination for this file.

@hermet hermet added the infrastructure Dev infrastructure label Jun 19, 2024
@andyf-canva andyf-canva marked this pull request as ready for review August 21, 2024 01:01
@andyf-canva andyf-canva changed the title [draft] swift: Config for Swift Package build swift: Config for Swift Package build Aug 21, 2024
@andyf-canva
Copy link
Collaborator Author

@hermet @tinyjin I've now marked this PR as ready to review as @tinyjin and I have been collaborating on the Swift API as you can see here. And we're getting close to merging that PR! 🎉

For this PR, these are the minimal requirements to get the Swift Package building. As mentioned, where I've added the symbolic link and the config file may not be the best place to put them so would love your feedback as code owners of this repo 😄

Copy link
Member

@hermet hermet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyf-canva Thanks! Quick comment here. I think ThorVG doesn't need changes for this. The best approach would be to generate the config.h during the build & packaging thorvg swift with the latest throvg release. Or, at the very least, this change should be included thorvg.swift side.

@andyf-canva
Copy link
Collaborator Author

@hermet thanks for the feedback ❤️ That's a fair call. From memory, I wasn't able to perform a sort of "build step" from the SPM side, but let me take a look again. Because I agree, seems like something that should just happen at build time. Will report back soon. 👍

@andyf-canva
Copy link
Collaborator Author

Good news - I've removed the symbolic link because we can point the Swift Package path to a layer higher to include the inc directory. I'll also push the changes to the thorvg.swift PR.

Last thing to figure out: the config.h file. Will report back and see if I can hack together a pre-build script or something.

@andyf-canva
Copy link
Collaborator Author

An update: I've removed the config.h file and have created a pre-build script that consumers have to run in-order to copy the config file into the correct position to compile the Package. I will add more details in the PR here.

@andyf-canva
Copy link
Collaborator Author

That means that this PR is now not making any changes on the thorvg repo and can thus be closed. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Dev infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants