Преглед на файлове

Merge pull request #948 from toland/fix_mib_compiler

Fix a small bug in the MIB compiler when building dependencies
pull/953/head
Fred Hebert преди 9 години
родител
ревизия
46181c8bf5
променени са 2 файла, в които са добавени 18 реда и са изтрити 8 реда
  1. +8
    -4
      src/rebar_erlc_compiler.erl
  2. +10
    -4
      test/rebar_compile_SUITE.erl

+ 8
- 4
src/rebar_erlc_compiler.erl Целия файл

@ -520,15 +520,20 @@ target_base(OutDir, Source) ->
rebar_dict()) -> 'ok'.
compile_mib(Source, Target, Opts) ->
Dir = filename:dirname(Target),
IncludeDir = filename:join(Dir, "include"),
Mib = filename:rootname(Target),
HrlFilename = Mib ++ ".hrl",
ok = filelib:ensure_dir(Target),
ok = filelib:ensure_dir(filename:join([Dir, "include", "dummy.hrl"])),
ok = filelib:ensure_dir(filename:join([IncludeDir, "dummy.hrl"])),
AllOpts = [{outdir, Dir}
,{i, [Dir]}] ++
rebar_opts:get(Opts, mib_opts, []),
case snmpc:compile(Source, AllOpts) of
{ok, _} ->
Mib = filename:rootname(Target),
MibToHrlOpts =
case proplists:get_value(verbosity, AllOpts, undefined) of
undefined ->
@ -537,8 +542,7 @@ compile_mib(Source, Target, Opts) ->
#options{specific = [{verbosity, Verbosity}]}
end,
ok = snmpc:mib_to_hrl(Mib, Mib, MibToHrlOpts),
Hrl_filename = Mib ++ ".hrl",
rebar_file_utils:mv(Hrl_filename, "include"),
rebar_file_utils:mv(HrlFilename, IncludeDir),
ok;
{error, compilation_failed} ->
?FAIL

+ 10
- 4
test/rebar_compile_SUITE.erl Целия файл

@ -1018,11 +1018,14 @@ mib_test(Config) ->
rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
%% check a beam corresponding to the src in the extra src_dir exists in ebin
%% check a bin corresponding to the mib in the mibs dir exists in priv/mibs
PrivMibsDir = filename:join([AppDir, "_build", "default", "lib", Name, "priv", "mibs"]),
true = filelib:is_file(filename:join([PrivMibsDir, "SIMPLE-MIB.bin"])),
%% check the extra src_dir was linked into the _build dir
%% check a hrl corresponding to the mib in the mibs dir exists in priv/mibs/include
true = filelib:is_file(filename:join([PrivMibsDir, "include", "SIMPLE-MIB.hrl"])),
%% check the mibs dir was linked into the _build dir
true = filelib:is_dir(filename:join([AppDir, "_build", "default", "lib", Name, "mibs"])).
umbrella_mib_first_test(Config) ->
@ -1065,11 +1068,14 @@ umbrella_mib_first_test(Config) ->
rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
%% check a beam corresponding to the src in the extra src_dir exists in ebin
%% check a bin corresponding to the mib in the mibs dir exists in priv/mibs
PrivMibsDir = filename:join([AppsDir, "_build", "default", "lib", Name, "priv", "mibs"]),
true = filelib:is_file(filename:join([PrivMibsDir, "SIMPLE-MIB.bin"])),
%% check the extra src_dir was linked into the _build dir
%% check a hrl corresponding to the mib in the mibs dir exists in priv/mibs/include
true = filelib:is_file(filename:join([PrivMibsDir, "include", "SIMPLE-MIB.hrl"])),
%% check the mibs dir was linked into the _build dir
true = filelib:is_dir(filename:join([AppsDir, "_build", "default", "lib", Name, "mibs"])).
only_default_transitive_deps(Config) ->

Зареждане…
Отказ
Запис