mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
More work
This commit is contained in:
parent
c828f59056
commit
be2a9096f6
3 changed files with 88 additions and 7 deletions
|
@ -49,20 +49,42 @@ install(Config, File) ->
|
|||
%% continue if it's set
|
||||
case rebar_config:get_global(force, "0") of
|
||||
"0" ->
|
||||
?ERROR("~s already exists. Installation failed.", []),
|
||||
?ERROR("~s already exists. Installation failed.\n", [AppId]),
|
||||
?FAIL;
|
||||
"1" ->
|
||||
?WARN("~s already exists, but forcibly overwriting.", [])
|
||||
?WARN("~s already exists, but forcibly overwriting.\n", [AppId])
|
||||
end;
|
||||
false ->
|
||||
ok
|
||||
end.
|
||||
end,
|
||||
|
||||
%% Wipe out any previous versions
|
||||
% ok = rebar_file_utils:rm_rf(Appdir),
|
||||
ok = rebar_file_utils:rm_rf(AppDir),
|
||||
|
||||
%% Re-create target
|
||||
% ok = rebar_file_utils:mkdir_p(AppDir).
|
||||
ok = rebar_file_utils:mkdir_p(AppDir),
|
||||
|
||||
%% By default we copy the ebin, include, src and priv directories
|
||||
ok = rebar_file_utils:cp_r(["ebin", "src", "priv", "include"],
|
||||
AppDir),
|
||||
|
||||
%% Check the config to see if we have any binaries that need to be
|
||||
%% linked into the erlang path
|
||||
case rebar_config:get_list(Config, app_bin, []) of
|
||||
[] ->
|
||||
ok;
|
||||
List ->
|
||||
ok
|
||||
end.
|
||||
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
install_binaries([], _AppDir, _BinDir) ->
|
||||
ok;
|
||||
install_binaries([Bin | Rest], AppDir, BinDir) ->
|
||||
FqBin = filename:join([Bin, AppDir]),
|
||||
rebar_file_utils:ln_sf(FqBin, BinDir),
|
||||
install_binaries(Rest, AppDir, BinDir).
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
%% Public API
|
||||
%% ===================================================================
|
||||
|
||||
compile(Config, Dir) ->
|
||||
compile(Config, _AppFile) ->
|
||||
do_compile(Config, "src/*.erl", "ebin", ".erl", ".beam",
|
||||
fun compile_erl/2,
|
||||
rebar_config:get_list(Config, erl_first_files, [])),
|
||||
|
@ -41,7 +41,7 @@ compile(Config, Dir) ->
|
|||
fun compile_mib/2,
|
||||
rebar_config:get_list(Config, mib_first_files, [])).
|
||||
|
||||
clean(Config, Dir) ->
|
||||
clean(_Config, _AppFile) ->
|
||||
%% TODO: This would be more portable if it used Erlang to traverse
|
||||
%% the dir structure and delete each file; however it would also
|
||||
%% much slower.
|
||||
|
|
59
src/rebar_file_utils.erl
Normal file
59
src/rebar_file_utils.erl
Normal file
|
@ -0,0 +1,59 @@
|
|||
%% -------------------------------------------------------------------
|
||||
%%
|
||||
%% rebar: Erlang Build Tools
|
||||
%%
|
||||
%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
|
||||
%%
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
%% in the Software without restriction, including without limitation the rights
|
||||
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
%% copies of the Software, and to permit persons to whom the Software is
|
||||
%% furnished to do so, subject to the following conditions:
|
||||
%%
|
||||
%% The above copyright notice and this permission notice shall be included in
|
||||
%% all copies or substantial portions of the Software.
|
||||
%%
|
||||
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
%% THE SOFTWARE.
|
||||
%% -------------------------------------------------------------------
|
||||
-module(rebar_file_utils).
|
||||
|
||||
-export([rm_rf/1,
|
||||
mkdir_p/1,
|
||||
cp_r/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
%% Public API
|
||||
%% ===================================================================
|
||||
|
||||
rm_rf(Target) ->
|
||||
[] = os:cmd(?FMT("rm -rf ~s", [Target])),
|
||||
ok.
|
||||
|
||||
mkdir_p(Target) ->
|
||||
[] = os:cmd(?FMT("mkdir -p ~s", [Target])),
|
||||
ok.
|
||||
|
||||
cp_r(Sources, Dest) ->
|
||||
SourceStr = string:join(Sources, " "),
|
||||
[] = os:cmd(?FMT("cp -R ~s ~s", [SourceStr, Dest])),
|
||||
ok.
|
||||
|
||||
ln_sf(Source, Dest) ->
|
||||
case filelib:is_dir(Dest) of
|
||||
true ->
|
||||
ActualDest = filename:join([Dest, filename:basename(Source)]);
|
||||
false ->
|
||||
ActualDest = Dest
|
||||
end,
|
||||
[] = os:cmd(?FMT("ln -sf ~s ~s", [Source, Dest])),
|
||||
ok.
|
||||
|
Loading…
Reference in a new issue