diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2009-11-30 07:00:48 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2009-11-30 07:00:48 -0700 |
commit | be2a9096f6a99a599c25184aece8183da95436c7 (patch) | |
tree | 05616d8207fead5437c2f355a834dcec3645e6b3 | |
parent | c828f590568e09ee258f8906781c5594b6bc36f4 (diff) |
More work
-rw-r--r-- | src/rebar_app_installer.erl | 32 | ||||
-rw-r--r-- | src/rebar_erlc_compiler.erl | 4 | ||||
-rw-r--r-- | src/rebar_file_utils.erl | 59 |
3 files changed, 88 insertions, 7 deletions
diff --git a/src/rebar_app_installer.erl b/src/rebar_app_installer.erl index 0d1e986..e860d6a 100644 --- a/src/rebar_app_installer.erl +++ b/src/rebar_app_installer.erl @@ -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). diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index ac1e733..7b36ae5 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -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. diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl new file mode 100644 index 0000000..af47ea8 --- /dev/null +++ b/src/rebar_file_utils.erl @@ -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. + |