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

Introduce new framework generation process #104

Merged
merged 40 commits into from
Oct 3, 2023
Merged

Conversation

giginet
Copy link
Owner

@giginet giginet commented Sep 25, 2023

This PR changes framework generation process.

Before

Scipio tries to consist of frameworks with PIF. Modify PIF to generate framework by injecting header and linker build phases.
But it breaks some packages. It's better to keep PIF as modified as possible.

After

Just build framework components with xcbuild. After that, assemble framework bundles manually.

  • PIF + xcbuild compiles binaries, Info.plist and swiftmodules in framework (Generated Framework)
  • FrameworkComponentsCollector collects framework components from the generated framework.
  • FrameworkBundleAssembler try to relocate them into framework bundle format (Assembled Framework)
  • XCBuildClient tries to generate XCFramework from the assembled frameworks

@giginet giginet changed the title Assemble frameworks Introduce new framework generation process Sep 26, 2023
Comment on lines +163 to +169
let notDuplicatedSymlinks = symlinks.filter { path in
notSymlinks.allSatisfy { FileManager.default.contentsEqual(atPath: path.pathString, andPath: $0.pathString) }
}
.map { $0.asURL.resolvingSymlinksInPath() }
.map(\.absolutePath)

return Set(notSymlinks + notDuplicatedSymlinks)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is the same logic PIFGenerater used to do this.

@testable import ScipioKit
import TSCBasic

final class InfoPlistGeneratorTests: XCTestCase {
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is a test case of an existing logic.

@giginet giginet marked this pull request as ready for review September 26, 2023 10:42
import Foundation
import TSCBasic

/// A assembler to generate framework bundle
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// A assembler to generate framework bundle

It is already described in name of struct

Copy link
Owner Author

Choose a reason for hiding this comment

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

There is an additional doccomment following line. So it's better to remain this line.


/// FileLists to assemble a framework bundle
struct FrameworkComponents {
var name: String
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
var name: String
var frameworkName: String

I'm not sure whether the name of "Component" or "Framework"

Comment on lines 110 to 124
private func findInfoPlist(in frameworkBundlePath: AbsolutePath) throws -> AbsolutePath {
let infoPlistLocationCandidates = [
// In a regular framework bundle, Info.plist should be on its root
frameworkBundlePath.appending(component: "Info.plist"),
// In a versioned framework bundle (for macOS), Info.plist should be in Resources
frameworkBundlePath.appending(components: "Resources", "Info.plist"),
]
guard let infoPlistPath = infoPlistLocationCandidates.first(where: fileSystem.exists(_:)) else {
throw Error.infoPlistNotFound(frameworkBundlePath: frameworkBundlePath)
}
return infoPlistPath
}

/// Collects *.swiftmodules* in a generated framework bundle
private func collectSwiftModules(of targetName: String, in frameworkPath: AbsolutePath) throws -> AbsolutePath? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is difference of collect and find?

Copy link
Owner Author

Choose a reason for hiding this comment

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

No, I'll unify them to collect.

giginet and others added 12 commits October 3, 2023 10:06
Run for 15.0

Revert "Run for 15.0"

This reverts commit 200f4b4.

Do not remove Package.resolved

Specify DEPLOYMENT_TARGET
In this commit, I bumped up the macOS support version to macOS 12.0 or
above. Because current HEAD of swift-driver only supports that.
@giginet giginet merged commit ba240dc into main Oct 3, 2023
@giginet giginet deleted the framework-constructor branch October 3, 2023 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants