I’m attempting to use the dependency ElixirALE and I’m very confused about getting it into my project.
I’m using mix and have declared it as a dependency, but the library doesn’t have an app file, so the usual mechanism of starting the library as an app isn’t available.
Despite lots of searching I don’t seem to be able to figure out how to do an equivalent of a Ruby require so I can use this library code. The instructions in their README are pretty standard and ain’t helping.
This lib is a little different in that it has a C core and a Makefile, but compilation is working OK. Here’s my dependency line from my mix.exs:
defp deps do
[
{
:elixir_ale, "~> 0.6.0",
compile: ~s(CC="rpxc arm-linux-gnueabihf-gcc" CROSSCOMPILE=rpxc ERL_EI_INCLUDE_DIR=/rpxc/sysroot/usr/lib/erlang/usr/include ERL_EI_LIBDIR=/rpxc/sysroot/usr/lib/erlang/usr/lib make),
app: false,
}
]
end
I’ve tried clearing and recompiling the dependencies a few times to no avail.
Any use of the library results in e.g.
warning: function ElixirALE.I2C.read/2 is undefined (module ElixirALE.I2C is not available)
Are you sure that library is not supposed to create an app file? I can’t find anything in elixir_ale’s code to suggest this and there is no mention that app: false in its documentation.
Hi Eric, it looks like this might be related to me overriding the compile option to just do a make. I didn’t know that app files could be generated so I wasn’t really focused on that.
I’ve switched the compile override to do a mix compile with the appropriate ENV vars and I’m seeing Generated elixir_ale app in the output, but _build/dev/lib/elixir_ale/ is still empty. The .app file is generated correctly if I run the same command from a git checkout of the library.
What’s the correct way to override dependency compilation to add ENV vars while still having the library’s mix compile work correctly?
I glanced over the code, and mix does alters some bits of the in memory config to put compilation output to your projects _build-folder, but by specifying mix compile as as compilation command, mix thinks it were in its project basedir and uses this. Have you tried to set the environment variables on your end when compiling deps?
Personally I’d try to convince the maintainer of ElixirALE to find a way to make the crosscompilation stuff work via regular mix-config capabilities.
edit
Or I’d set these ENV-VARs in my build machine permanently or per job. So that I can easily crosscompile to different targets by just using new values for ENV-VARS and without the necessity to alter the mix file or some other config on the fly.
The catch with the latter being they’re effectively global variables across all dependencies at that point, with potential collisions between identically-named ENV vars in different libraries (though not in this case, yet).
Did you have any mix-config capabilities in mind for altering elixir ale? I don’t mind putting in a PR there myself.