thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
64 stars 4 forks source link

Custom LLVM paths with an environment variable #42

Closed mz2 closed 2 years ago

mz2 commented 2 years ago

Adds handling for a LIBCLANG_PATH environment variable to allow passing in custom paths for the Clang dynamic library. I found myself again adding to the set of fixed paths in host_props.rs as I upgraded my copy of LLVM between major versions on macOS, and on Ubuntu 21.10 so figured I'd instead tackle this in some more generalisable way.

Also suggesting this since keeping with the convention of adding fixed paths is not going to be a very good solution on at least macOS, since people often keep multiple Xcodes around seasonally (stable release, plus beta version for the upcoming SDK / OS release, etc) and the exact LLVM you're going to want to depend on can be a user specific weird path for example in those cases (beside my unusual "homebrew under home directory" setup).

I'm posting this really to propose the idea (also as a means of fixing #31), happy to try clean up the implementation further if the idea seems sane.

(Also, apologies, I seem to have accidentally opened this branch on the upstream repo at first -- I imagine I am not intended to have direct write access to the upstream repo?)

mz2 commented 2 years ago

A few more things to note now that I am reading through it myself:

mz2 commented 2 years ago

(Yup, changed it indeed so that when LIBCLANG_PATH is given, the default paths given in the module are not considered at all, and also added handling for $HOME/homebrew/... as discussed over at https://github.com/thlorenz/rid/issues/31#issuecomment-929189081)

And I realise the code changes are pretty gross. The force is just not strong enough in me to appease rustc to compiling it successfully whilst still retaining any of the static &str consts. Again, ideas / rewrite very welcome if the general idea seems good.

mz2 commented 2 years ago

Heh, looks like I should not try write Rust close to midnight since all the lifecycle oddities I got stuck with last night that warranted changing from static constants to locals were trivial to resolve in the morning. Now it's actually not so gross anymore, actually happy with the solution :smile:

mz2 commented 2 years ago

Review feedback addressed, I think.

thlorenz commented 2 years ago

Cool LGTM, I'm assuming CI is passing on your fork? I'll pull this down this week and merge it if all checks out. (currently swamped)