elixir-circuits / circuits_i2c

Communicate over I2C from Elixir
Apache License 2.0
62 stars 12 forks source link

Improve target detection for building i2c_dev #161

Closed fhunleth closed 7 months ago

fhunleth commented 7 months ago

It turns out that people sometimes have MIX_TARGET set when they're not compiling for Nerves. On MacOS which doesn't support i2c_dev, this causes the following error:

==> circuits_i2c
"**** CIRCUITS_I2C_BACKEND set to [normal] ****"
Makefile:44: *** Circuits.I2C Linux i2c-dev backend is not supported on non-Linux platforms. Review circuits_i2c backend configuration or report an issue if improperly detected..  Stop.
could not compile dependency :circuits_i2c, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile circuits_i2c --force", update it with "mix deps.update circuits_i2c" or clean it with "mix deps.clean circuits_i2c"

This is pretty confusing. This change makes the Nerves detection smarter by first checking the MIX_TARGET and then checking if crosscompilation environment variables are actually set. If not, the host compiler will be used, so use the default for host builds.