Skip to content

Fix missing Homebrew prefix resolution. #230

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 1 commit into from
Mar 9, 2021

Conversation

eonil
Copy link
Contributor

@eonil eonil commented Feb 28, 2021

Make package making script to work with arbitrary (non-default) Homebrew locations.

@@ -46,24 +46,21 @@ extension String: Error {
}

func makeFile() throws {
let pkgConfigPath = "/usr/local/lib/pkgconfig"
guard let brew = which("brew") else { throw "Missing callable `brew` instance." }
Copy link
Collaborator

@matthewseaman matthewseaman Mar 2, 2021

Choose a reason for hiding this comment

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

We cannot assume the LLVM installation was done via brew because that breaks Linux users who didn't use brew to install (or Mac users who didn't use brew for that matter). This is why the CI is failing.

Copy link
Contributor Author

@eonil eonil Mar 5, 2021

Choose a reason for hiding this comment

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

I see.
I'm going to add platform branching. (#available)

For the Linux, I don't know well about it. Just keep /usr/local/ for Linux with hoping some Linux expert to come up to fix it.

For the macOS, I think /usr/local can cover only x86 Homebrew at default location. (maybe some other package managers?) How about calling brew --prefix first and falling back to /usr/local?

Copy link
Collaborator

@matthewseaman matthewseaman Mar 6, 2021

Choose a reason for hiding this comment

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

I'm not sure how useful #available will be since brew is now available for Linux I think, so in theory someone could install it that way.

As for trying brew first then falling back to /usr/local, that's probably fine. @segiddins @dduan what do you think? Could still be a problem for those who have brew installed but installed it via some other means. Not sure how much we care about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree to that #available is not necessary.

guard let brewPrefix = run(brew, args: ["--prefix"]) else { return nil }
return which(brewPrefix + "/opt/llvm/bin/llvm-config")
}
let brewLLVMConfig = which(brewPrefix + "/opt/llvm/bin/llvm-config")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep this in a closure since it only needs to be executed if the other 2 which calls on line 63 returned nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

Copy link
Collaborator

@matthewseaman matthewseaman left a comment

Choose a reason for hiding this comment

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

See above comments. Basically we can't assume that brew was used to install LLVM.

@eonil
Copy link
Contributor Author

eonil commented Mar 6, 2021

@matthewseaman I pushed new commit. Thanks.

Copy link
Collaborator

@matthewseaman matthewseaman left a comment

Choose a reason for hiding this comment

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

Looks good to me, though @segiddins or @dduan should take a look before merging to make sure this is fine.

@eonil
Copy link
Contributor Author

eonil commented Mar 7, 2021

Okay

@matthewseaman matthewseaman requested review from segiddins and removed request for segiddins March 8, 2021 20:32
@matthewseaman
Copy link
Collaborator

@eonil Thanks for this!

@matthewseaman matthewseaman merged commit ca22dde into llvm-swift:master Mar 9, 2021
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.

3 participants