1
0
Fork 0
mirror of https://github.com/correl/rebar.git synced 2024-12-20 12:56:02 +00:00
rebar/priv/templates/basicnif.erl

37 lines
728 B
Erlang
Raw Normal View History

2010-03-26 04:32:53 +00:00
-module({{module}}).
-export([new/0,
myfunction/1]).
-on_load(init/0).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
init() ->
case code:priv_dir({{module}}) of
{error, bad_name} ->
SoName = filename:join("../priv", {{module}});
Dir ->
SoName = filename:join(Dir, {{module}})
end,
erlang:load_nif(SoName, 0).
new() ->
"NIF library not loaded".
myfunction(Ref) ->
"NIF library not loaded".
%% ===================================================================
%% EUnit tests
%% ===================================================================
-ifdef(TEST).
basic_test() ->
{ok, Ref} = new(),
ok = myfunction(Ref).
-endif.