From f83f18eb3bcaebc746c72ffe728379c9a44668f1 Mon Sep 17 00:00:00 2001 From: Charles McKnight Date: Wed, 5 Jan 2011 16:00:00 -0800 Subject: Fix error where ebin was created as a file This patch remedies an issue where the ebin directory would be erroneously created as a file by the first "mv" command in rebar_protobuffs_compile.erl [line 106] if the ebin file did not exist at the root application level. In essence, the patch ensures that the ebin directory exists at the application directory level before any "mv" commands are executed. The following code was inserted at line 106: ok = filelib:ensure_dir(filename:join("ebin","dummy")), --- src/rebar_protobuffs_compiler.erl | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rebar_protobuffs_compiler.erl') diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl index 122440c..2a2139f 100644 --- a/src/rebar_protobuffs_compiler.erl +++ b/src/rebar_protobuffs_compiler.erl @@ -103,6 +103,7 @@ compile_each([{Proto, Beam, Hrl} | Rest]) -> %% 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. + ok = filelib:ensure_dir(filename:join("ebin","dummy")), [] = os:cmd(?FMT("mv ~s ebin", [Beam])), ok = filelib:ensure_dir(filename:join("include", Hrl)), [] = os:cmd(?FMT("mv ~s include", [Hrl])), -- cgit v1.1 From 52ca7795feb001f0624ec87e717e3019f8a810bd Mon Sep 17 00:00:00 2001 From: Juhani Rankimies Date: Sun, 5 Dec 2010 02:07:12 +0200 Subject: Unify executable invocation Add flags to rebar_utils:sh to control output and error handling. Replace calls to os:cmd with calls to rebar_utils:sh. --- src/rebar_protobuffs_compiler.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rebar_protobuffs_compiler.erl') diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl index 2a2139f..eafed41 100644 --- a/src/rebar_protobuffs_compiler.erl +++ b/src/rebar_protobuffs_compiler.erl @@ -104,9 +104,9 @@ compile_each([{Proto, Beam, Hrl} | Rest]) -> %% into the ebin/ and include/ directories respectively %% TODO: Protobuffs really needs to be better about this...sigh. ok = filelib:ensure_dir(filename:join("ebin","dummy")), - [] = os:cmd(?FMT("mv ~s ebin", [Beam])), + 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]), -- cgit v1.1 From c466076ffb5a1ea4c00d49fefff0dcfbceb58236 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 31 Jan 2011 17:43:31 +0100 Subject: Clean up emacs file local variables --- src/rebar_protobuffs_compiler.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_protobuffs_compiler.erl') diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl index eafed41..8ad0318 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 %% ------------------------------------------------------------------- %% -- cgit v1.1 From 63de05d914f3c2bef6dcfc6cf966400d93c9c80d Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 28 Jan 2011 16:08:27 +0100 Subject: Clean up code --- src/rebar_protobuffs_compiler.erl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/rebar_protobuffs_compiler.erl') diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl index 8ad0318..421b258 100644 --- a/src/rebar_protobuffs_compiler.erl +++ b/src/rebar_protobuffs_compiler.erl @@ -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,16 +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. + %% 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)), 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 -> -- cgit v1.1