rustler
rustler copied to clipboard
Cache Mix.env() to trigger recompilation
When using MIX_ENV to configure the build profile, changing MIX_ENV
in a subsequent run needs to trigger the mechanism for recompilation to determine if that mode was build. For this, we need to cache value of Mix.env()
and detect when that changes. If it changes, we write the cache, @external_resource
can pick that up.
Close #479
See also https://github.com/rusterlium/rustler/issues/479#issuecomment-1244239121.
I haven't looked into this much, but would making rust use a different target directory for each mix compilation mode be another option?
What are the pros/cons of these two options?
I haven't looked into this much, but would making rust use a different target directory for each mix compilation mode be another option?
The library which is loaded is hard-coded into the module at compile time, see the Rustler module (config.lib
defaults to true
in Rustler.Compiler.Config). So, unless I am missing something, the library path will not change, unless a recompilation is triggered. Also, the library directory already depends on the build profile. It defaults to _build/rustler/{debug,release}
.
So, we need to find a way to ensure that a module recompilation is triggered (use
needs to be expanded again), if the mix environment changes.
But maybe we really should get rid of MIX_ENV
handling altogether instead and tell users to pick the build profile explicitly in use Rustler
.
Closing in favor of https://github.com/rusterlium/rustler/pull/496.