diff options
Diffstat (limited to 'src/rebar_protobuffs_compiler.erl')
-rw-r--r-- | src/rebar_protobuffs_compiler.erl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl index 122440c..421b258 100644 --- a/src/rebar_protobuffs_compiler.erl +++ b/src/rebar_protobuffs_compiler.erl @@ -1,4 +1,4 @@ -%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 et %% ------------------------------------------------------------------- %% @@ -40,8 +40,8 @@ compile(_Config, _AppFile) -> [] -> ok; FoundFiles -> - %% Check for protobuffs library -- if it's not present, fail since we have - %% .proto files that need building + %% Check for protobuffs library -- if it's not present, fail + %% since we have.proto files that need building case protobuffs_is_present() of true -> %% Build a list of output files - { Proto, Beam, Hrl } @@ -51,7 +51,8 @@ compile(_Config, _AppFile) -> %% Compile each proto file compile_each(Targets); false -> - ?ERROR("Protobuffs library not present in code path!\n", []), + ?ERROR("Protobuffs library not present in code path!\n", + []), ?FAIL end end. @@ -60,7 +61,9 @@ compile(_Config, _AppFile) -> clean(_Config, _AppFile) -> %% Get a list of generated .beam and .hrl files and then delete them Protos = filelib:wildcard("src/*.proto"), - Targets = [fq_beam_file(F) || F <- Protos] ++ [fq_hrl_file(F) || F <- Protos], + BeamFiles = [fq_beam_file(F) || F <- Protos], + HrlFiles = [fq_hrl_file(F) || F <- Protos], + Targets = BeamFiles ++ HrlFiles, case Targets of [] -> ok; @@ -100,15 +103,18 @@ compile_each([{Proto, Beam, Hrl} | Rest]) -> ?CONSOLE("Compiling ~s\n", [Proto]), case protobuffs_compile:scan_file(Proto) of ok -> - %% Compilation worked, but we need to move the .beam and .hrl file - %% into the ebin/ and include/ directories respectively - %% TODO: Protobuffs really needs to be better about this...sigh. - [] = os:cmd(?FMT("mv ~s ebin", [Beam])), + %% Compilation worked, but we need to move the + %% beam and .hrl file into the ebin/ and include/ + %% directories respectively + %% TODO: Protobuffs really needs to be better about this + ok = filelib:ensure_dir(filename:join("ebin","dummy")), + ok = rebar_file_utils:mv(Beam, "ebin"), ok = filelib:ensure_dir(filename:join("include", Hrl)), - [] = os:cmd(?FMT("mv ~s include", [Hrl])), + ok = rebar_file_utils:mv(Hrl, "include"), ok; Other -> - ?ERROR("Protobuff compile of ~s failed: ~p\n", [Proto, Other]), + ?ERROR("Protobuff compile of ~s failed: ~p\n", + [Proto, Other]), ?FAIL end; false -> |