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

[draft] swift: Config for Swift Package build #2420

Draft
wants to merge 1 commit into
base: v0.13.x
Choose a base branch
from

Conversation

andyf-canva
Copy link
Collaborator

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.

Note: I've marked this PR as draft because these changes are particular to the new thorvg.swift repo and are subject to change.

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.

Symbolic link for inc folder

Swift Package Manager allows us to define a single path to the source code that we wish to build. We use the path parameter of this target function available to us inside the Package.swift manifest.

However, the umbrella file of the thorvg API (thorvg.h) is one step removed from the src directory. For more context, have a look at this diagram:

thorvg/
│
├── inc/
│ ├── meson.build
│ ├── thorvg.h <-- umbrella file
│
├── src/ <-- where the Swift Package path point to (everything we want to build)
│ └── ...

We need this umbrella file to be accessible by Swift Package Manager because many of the C++ files rely on that header file to build successfully. Currently, the meson build system takes care of this, but to get around this issue, we need to add a symbolic link inside the src/ directory pointing to the inc/ directory. After we do this, the package builds successfully.

I'm unsure how we get around this in a more elegant way without moving many of the files around, but this is the current solution that works.

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.

None yet

2 participants