When developing Nerves codes, which can works on both :host and :target, on host machine, I’d like to exclude compilation of codes which works on only :target. (The codes use “import Nerves.Runtime”, so compilation failed.)
How could I do that?
When developing Nerves codes, which can works on both :host and :target, on host machine, I’d like to exclude compilation of codes which works on only :target. (The codes use “import Nerves.Runtime”, so compilation failed.)
How could I do that?
Put the codes to conditionally compile into the separate folder, e.g. lib_target
on the top level.
In your project file mix.exs
do the following
def project do
[
...
elixirc_paths: elixirc_paths(Mix.env()),
...
]
defp elixirc_paths(:target), do: ["lib", "lib_target"]
defp elixirc_paths(_), do: ["lib"]
@mudasobwa Thank you for your quick reply.
I modify your advice codes for Nerves, like below
def project do
[
...
elixirc_paths: elixirc_paths(Mix.target()),
...
]
end
defp elixirc_paths(:host), do: ["lib"]
defp elixirc_paths(target) when target in @all_targets, do: ["lib", "lib_target"]
Thanks a lot !!