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

(WIP) allow custom override path when searching for Package.swift manifest file #3336

Closed
wants to merge 0 commits into from

Conversation

tayloraswift
Copy link
Member

@tayloraswift tayloraswift commented Mar 9, 2021

A first attempt at implementing a --manifest-prefix option, which specifies an override path when searching for Package.swift. This is extremely important for build systems using the SPM, as we would like automation tools to be able to generate root Package.swift files without clobbering or displacing the user’s original Package.swift.

An ideal build system workflow would parse the user-defined Package.swift, and place generated Package.swifts in a hidden subdirectory, when could then be used with --manifest-prefix:

.my-build-system
    .my-build-system/config1/ 
        .my-build-system/config1/Package.swift
    .my-build-system/config2/ 
        .my-build-system/config2/Package@swift-4.1.0.swift
Sources 
Tests 
Package.swift
README.md
...
swift build --manifest-prefix=.my-build-system/config1
swift build --manifest-prefix=.my-build-system/config2
...

Modifications:

This patch attempts to separate out manifestPath: AbsolutePath from packagePath : AbsolutePath which is currently used everywhere in the codebase as a standin for manifestPath.parentDirectory. The two paths should remain coupled for any package that is not a root package, or if the --manifest-prefix option is not used.

It also attempts to address some of the FIXMEs in PackageGraph+Loader.swift where we were trying to derive packagePath from manifest.path instead of the other way around.

Currently, the patch works for swift package init and swift build with no remote dependencies. For some reason, it does not work when there are dependencies present. I think the problem is related to PackageReference or LocalPackageContainer.swift, but I am not familiar enough with the code base to figure out why. Help with this would be appreciated

@abertelrud
Copy link
Contributor

@Kelvin13 Is this ready for review, or do you have any questions about how to proceed to get it ready?

@tayloraswift
Copy link
Member Author

@abertelrud like i said in the description, it’s not working yet for packages with dependencies, but if you know anything about how to get that part working that would be great

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.

None yet

2 participants