Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where to place my erlang library module myerlib.erl into elixir tree directory for calling from elixir modules

Tags:

elixir

I have myerlib/src/myerlib.erl erlang library module and I need call its functions from Elixir modules. Too call myerlib module functions from elixir code I could write :myerlib.function(.....) but

If I put myerlib subrirectory under deps/ elixir directory and use mix.exs:

def deps do
  [
    {:myerlib, path: "deps/myerlib"}
    # ...
  ]
end

then when I do iex -S mix I get this error:

*** (Mix) :path option can only be used with mix projects, invalid path dependency for :myerlib

like image 956
user1694815 Avatar asked Aug 20 '15 09:08

user1694815


1 Answers

If you have a src directory with .erl files in it then they will be compiled when you run mix.compile (either with mix compile or implicitly with something like iex -S mix).

You can see this in the mix compile.erlang task. This can be the default path src, but this can be changed by modifying the erlc_paths option in your mix.exs file.

def project do
  [app: :my_app,
   version: "0.0.1",
   elixir: "~> 1.0",
   erlc_paths: ["foo"], # ADD THIS OPTION
   build_embedded: Mix.env == :prod,
   start_permanent: Mix.env == :prod,
   deps: deps]
end
like image 106
Gazler Avatar answered Oct 17 '22 10:10

Gazler