Skip to content

refactor toolchain SwiftPM libraries path #3660

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

Merged
merged 5 commits into from
Aug 19, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Aug 11, 2021

motivation: improve logic in how Manifest and Plugin APIs locations are derived

changes:

  • rename fields on ToolchainConfiguration to better articulate their meaning
  • change logic in UserToolchain to derive the SwiftPM libraries path more clearly and reliably
  • adjust call-sites and test

@tomerd tomerd force-pushed the refactor/toolchain-swiftpm-libs branch from 3e838b2 to d0ae07b Compare August 11, 2021 08:20
@tomerd
Copy link
Contributor Author

tomerd commented Aug 11, 2021

@swift-ci please smoke test

@tomerd tomerd force-pushed the refactor/toolchain-swiftpm-libs branch from d0ae07b to 6b48076 Compare August 11, 2021 23:58
@tomerd
Copy link
Contributor Author

tomerd commented Aug 12, 2021

@swift-ci please smoke test

if let pathEnvVariable = ProcessEnv.vars["SWIFTPM_CUSTOM_LIBS_DIR"] ?? ProcessEnv.vars["SWIFTPM_PD_LIBS"] {
if ProcessEnv.vars["SWIFTPM_PD_LIBS"] != nil {
print("SWIFTPM_PD_LIBS was deprecated in favor of SWIFTPM_CUSTOM_LIBS_DIR")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abertelrud @neonichu please note ^^, I think this new name makes more sense. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, this is clearer.

// Otherwise, fall back on the old location (this would indicate that we're using an old toolchain).
return self.toolchain.libDir.appending(version.runtimeSubpath)

// FIXME: how do we test this?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abertelrud do you know how I can test this? otherwise I was able to test all scenarios I was aware of

Copy link
Contributor

Choose a reason for hiding this comment

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

The only way I can think of would be to use a test fixture and then invoke swift package in a shell, setting the parameter and making sure that it gets used. One could probably even set it to a known broken location and checking for the error message due to its not finding PackageDescription et.al.

@tomerd
Copy link
Contributor Author

tomerd commented Aug 12, 2021

@swift-ci please smoke test macOS

@tomerd
Copy link
Contributor Author

tomerd commented Aug 12, 2021

@swift-ci please smoke test

var xctestLocation: AbsolutePath?
// FIXME: the following logic is pretty fragile, but has always been this way
// an alternative cloud be to force explicit locations to always be set explicitly when running in XCode/SwiftPM
// debug and assert if not set but we detect that we are in this mode
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, though I think this code shouldn't be concerned at all with debug mode. It should know about the default locations, and just expose optional overrides that clients (including swift-build etc) can use when they are built in debug mode.

Copy link
Contributor

@abertelrud abertelrud Aug 12, 2021

Choose a reason for hiding this comment

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

But that can be further refined in a later PR. This is a good improvement already.

Copy link
Contributor

@abertelrud abertelrud left a comment

Choose a reason for hiding this comment

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

Thanks for doing this cleanup!

@tomerd
Copy link
Contributor Author

tomerd commented Aug 14, 2021

@swift-ci please smoke test

@tomerd tomerd self-assigned this Aug 14, 2021
@tomerd
Copy link
Contributor Author

tomerd commented Aug 14, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Aug 14, 2021

@swift-ci please smoke test linux

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Aug 14, 2021
}

public init(root: AbsolutePath) {
self.init(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good convenience, I think. The idea was that if we add more of these, then the client (an IDE for example) should just be able to have a directory of support files, and then it's mostly SwiftPM's business what should be in that directory. So for a client to not have to enumerate these subdirectories in the default case is good.

@tomerd tomerd force-pushed the refactor/toolchain-swiftpm-libs branch from f0bde26 to 3bdc59b Compare August 17, 2021 17:34
@tomerd
Copy link
Contributor Author

tomerd commented Aug 17, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Aug 18, 2021

this is waiting for Windows validation to be complete by @compnerd

tomerd added 5 commits August 18, 2021 18:27
motivation: improve logic in how Manifest and Plugin APIs locations are derived

changes:
* rename fields on ToolchainConfiguration to better articulate their meaning
* change logic in UserToolchain to derive the SwiftPM libraries path more clearly and reliably
* adjust call-sites and test
@tomerd tomerd force-pushed the refactor/toolchain-swiftpm-libs branch from 3bdc59b to 021db1a Compare August 19, 2021 01:28
@tomerd
Copy link
Contributor Author

tomerd commented Aug 19, 2021

rebased. @swift-ci please smoke test

@tomerd tomerd merged commit 2d7b2bc into swiftlang:main Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants