From b6b32fc64efb3b8a48f144fa850bfef923f66d45 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 6 Jul 2015 22:54:43 -0500 Subject: ensure necessary directories exist to compile mibs files --- src/rebar_erlc_compiler.erl | 7 +++++-- src/rebar_prv_compile.erl | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index b9072a3..87cf352 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -404,10 +404,13 @@ target_base(OutDir, Source) -> -spec compile_mib(file:filename(), file:filename(), rebar_state:t()) -> 'ok'. compile_mib(Source, Target, Config) -> + Dir = rebar_state:dir(Config), ok = filelib:ensure_dir(Target), - ok = filelib:ensure_dir(filename:join("include", "dummy.hrl")), - Opts = [{outdir, "priv/mibs"}, {i, ["priv/mibs"]}] ++ + ok = filelib:ensure_dir(filename:join([Dir, "include", "dummy.hrl"])), + Opts = [{outdir, filename:join([Dir, "priv", "mibs"])} + ,{i, [filename:join([Dir, "priv", "mibs"])]}] ++ rebar_state:get(Config, mib_opts, []), + case snmpc:compile(Source, Opts) of {ok, _} -> Mib = filename:rootname(Target), diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 6eb8a4f..25d5193 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -126,7 +126,20 @@ copy_app_dirs(State, OldAppDir, AppDir) -> false -> ok end, + filelib:ensure_dir(filename:join(AppDir, "dummy")), + + %% link or copy mibs if it exists + case filelib:is_dir(filename:join(OldAppDir, "mibs")) of + true -> + %% If mibs exist it means we must ensure priv exists. + %% mibs files are compiled to priv/mibs/ + filelib:ensure_dir(filename:join([OldAppDir, "priv", "dummy"])), + symlink_or_copy(OldAppDir, AppDir, "mibs"); + false -> + ok + end, + %% link to src_dirs to be adjacent to ebin is needed for R15 use of cover/xref SrcDirs = rebar_dir:all_src_dirs(State, ["src"], ["test"]), [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include"] ++ SrcDirs]; -- cgit v1.1