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

build: add support to vendor dependencies #158

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Conversation

compnerd
Copy link
Contributor

@compnerd compnerd commented Dec 8, 2023

When building swift-crypto outside of the toolchain (e.g. to build LSP), it is convenient to support vendoring dependencies. Add support for falling back to local builds of the dependencies when not provided as an existing build.

@compnerd
Copy link
Contributor Author

compnerd commented Dec 8, 2023

CC: @yim-lee

@compnerd
Copy link
Contributor Author

compnerd commented Dec 8, 2023

@swift-server-bot please test

@compnerd
Copy link
Contributor Author

compnerd commented Dec 8, 2023

@swift-server-bot please test

message("-- Vending swift-asn1")
FetchContent_Declare(ASN1
GIT_REPOSITORY https://github.com/apple/swift-asn1
GIT_TAG 1.1.0)
Copy link
Member

Choose a reason for hiding this comment

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

It is highly likely that we will forget to keep this in-sync with Package.swift. Would it be better to require users of this feature to set a version environment variable so they don't use a wrong version by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does make it a lot more complicated to use. The intention here is to enable the use of the CMake based build to debug LSP, which requires SPM, which requires this package.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yim-lee Can we amend the soundness script to validate that these two match?

Copy link
Member

@yim-lee yim-lee Dec 19, 2023

Choose a reason for hiding this comment

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

If we look at the rule for swift-crypto:

.package(url: "https://github.com/apple/swift-crypto.git", "2.5.0" ..< "4.0.0"),

What's the swift-crypto version that we would extract from this for comparison/validation?

If we extract from Package.resolved instead, the resolved version may not necessarily match the one in this file. This might be annoying but could work I suppose? I don't think we do swift build or swift package resolve in the soundness check though.

And it's possible for the resolved dependency version to be different depending on how the dependency is included right? i.e., the swift-crypto version when building swift-certificates vs. SwiftPM is probably different, so which Package.resolved should be looked at (and when)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, these are all good questions. I'm just wondering if we can get to a local maximum of "least likely to be outside the band of reasonableness".

When building swift-crypto outside of the toolchain (e.g. to build LSP),
it is convenient to support vendoring dependencies.  Add support for
falling back to local builds of the dependencies when not provided as an
existing build.
@compnerd
Copy link
Contributor Author

@yim-lee ping? This has been sitting for a while, and is blocking other work. Can we please merge it and address the feedback for tooling in a follow up?

@yim-lee
Copy link
Member

yim-lee commented Jan 31, 2024

@compnerd Frankly I still prefer that we don't hardcode dependency versions, but I don't have time to look into alternatives. If we must merge this PR as-is, then I feel strongly that at the minimum the owners of this repository should not be held responsible for updating the versions. Can we agree to that?

@compnerd
Copy link
Contributor Author

@yim-lee I think we can agree to that - I expect that the occasional patch to bring this back into sync isn't a big deal, but having it track precisely is not a requirement.

CMakeLists.txt Outdated Show resolved Hide resolved
@yim-lee
Copy link
Member

yim-lee commented Jan 31, 2024

@swift-server-bot test this please

Co-authored-by: Yim Lee <yim_lee@apple.com>
@compnerd
Copy link
Contributor Author

@swift-server-bot test this please

@yim-lee
Copy link
Member

yim-lee commented Jan 31, 2024

@compnerd OK. I have a question about keeping the versions in-sync with update-checkout and whether we want to use the latest, otherwise I can merge this if you think it's ready.

@compnerd
Copy link
Contributor Author

I think that we could use the latest, but I feel more comfortable with trying to match the update-checkout because it is going to be the closest to what is actually in the toolchain. The primary use of this is for ease of debugging projects like the LSP which cannot be built with SPM on Windows due to SPM limitations.

@yim-lee
Copy link
Member

yim-lee commented Jan 31, 2024

Yeah, update-checkout doesn't use the latest:

https://github.com/apple/swift/blob/main/utils/update_checkout/update-checkout-config.json#L116-L118

@compnerd
Copy link
Contributor Author

compnerd commented Jan 31, 2024

BTW, FTR, this is not the mechanism for building the toolchain - the toolchain builds rely on update-checkout and builds everything from that checkout, which is why drift here is not a major concern - this is a developer productivity solution.

@yim-lee yim-lee merged commit f53dbc4 into apple:main Jan 31, 2024
6 of 7 checks passed
@compnerd compnerd deleted the vendor branch February 1, 2024 00:35
@hamzahrmalik hamzahrmalik added the semver/none No version bump required. label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants