Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emakefile - custom behaviour undefined

My test project is structured this way:

./Emakefile:

{"source/*", [debug_info, {outdir, "binary"}]}.

./source/test.erl:

-module(test).
-behaviour(test_behaviour).

./source/test_behaviour.erl:

-module(test_behaviour).
-export([behaviour_info/1]).

behaviour_info(callbacks) -> [];
behaviour_info(_) -> undefined.

When I use the command erl -make in the project directory (.), I get the following output:

Recompile: source/test_behaviour
Recompile: source/test
source/test.erl:2: Warning: behaviour test_behaviour undefined

Why does erl print this warning ? It compiled test_behaviour.erl before test.erl, so I guess it should be able to find test_behaviour.beam in the binary folder.

like image 583
Muja Null Avatar asked Oct 04 '22 07:10

Muja Null


1 Answers

Behaviors are resolved at the compile time. Hence the Erlang compiler should find the behavior beam file and call the behavior module's behaviour_info/1 function.

Here test_behaviour.beam is not in the code path of the compiler. You can run by calling

erl -pa ebin -make

This solved the problem for me. I tried specifying in Emakefile but with no luck. Could not find the documentation also. Also found that oder of -pa ebin has to be before -make (not sure why though).

like image 150
Vinod Avatar answered Oct 13 '22 11:10

Vinod