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

Use official ASWF source, reduce SWG modifications #4

Open
furby-tm opened this issue Feb 11, 2024 · 1 comment
Open

Use official ASWF source, reduce SWG modifications #4

furby-tm opened this issue Feb 11, 2024 · 1 comment
Assignees

Comments

@furby-tm
Copy link
Member

furby-tm commented Feb 11, 2024

Libraries across the ASWF should not have to be modified, or modified very minimally - figure out a way (perhaps through the usage of git submodules) or Swift package plugins, so that our (or the Swift Working Group) changes are very minimal, we want to ensure we are shipping as close to the official libraries as we can.

In the end it is our preference that the code we maintain is just the Swift code and/or Swift extensions of these C and C++ ASWF projects.

SWG proposal pending.

@furby-tm furby-tm converted this from a draft issue Feb 11, 2024
@furby-tm furby-tm moved this from Todo to In Progress in Open Metaverse Feb 11, 2024
@furby-tm
Copy link
Member Author

furby-tm commented Feb 11, 2024

It appears the best way to do this is what we would like to call SPM Jiu-Jitsu

The steps are as follows.

  1. Say you have a Swift target named "CXXLibrary"
.target(
  name: "CXXLibrary",
  dependencies: []
)
  1. This library failed to build because it contains a header file called CXXLibraryConfig.h.in, but the source code is attempting to find a file called CXXLibraryConfig.h, a frequent problem when escaping a build system like CMake! Unfortunately SwiftPM is unable to generate files, even SwiftPM build plugins do not support the generation of files that are *.h or *.cpp as they only support the generation of *.swift files. The solution here, is to introduce this file manually in its own isolated swift target, and provide it as a dependency of "CXXLibrary".
.target(
  name: "CXXLibraryConfigHeader",
  dependencies: []
)

.target(
  name: "CXXLibrary",
  dependencies: [
    .target(name: "CXXLibraryConfigHeader")
  ]
)
  1. Now "CXXLibrary" can remain unmodified - in the case of the SWG this is to ensure we can pull the official source code in the form of submodules without having to make edits across the ASWF projects.

Important

The Jiu-Jitsu part of this equation is the complexity increases substantially when there are source files that need to be edited, say; in the case that a *.mm file uses retain and release calls which ARC explicitly forbids (we will exclude them from the official CXX target) but we will (re)provide the offending source with any necessary modifications needed to compile in their own isolated Swift targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants