From b7e2088c273708bd5ce46b3c135c20f2229c7ccf Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 25 Nov 2009 15:23:42 -0700 Subject: Initial commit --- src/rebar_app_utils.erl | 39 ++++++++++++++++++++++++++++++++++++ src/rebar_config.erl | 44 +++++++++++++++++++++++++++++++++++++++++ src/rebar_doterl_compiler.erl | 46 +++++++++++++++++++++++++++++++++++++++++++ src/rebar_rel_utils.erl | 38 +++++++++++++++++++++++++++++++++++ src/rebar_utils.erl | 31 +++++++++++++++++++++++++++++ 5 files changed, 198 insertions(+) create mode 100644 src/rebar_app_utils.erl create mode 100644 src/rebar_config.erl create mode 100644 src/rebar_doterl_compiler.erl create mode 100644 src/rebar_rel_utils.erl create mode 100644 src/rebar_utils.erl (limited to 'src') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl new file mode 100644 index 0000000..24c8e1b --- /dev/null +++ b/src/rebar_app_utils.erl @@ -0,0 +1,39 @@ +%% ------------------------------------------------------------------- +%% +%% 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_app_utils). + +-export([is_app_dir/0, is_app_dir/1]). + +is_app_dir() -> + is_app_dir(rebar_util:get_cwd()). + +is_app_dir(Dir) -> + Fname = filename:join([Dir, "ebin/*.app"]), + case filelib:wildcard(Fname) of + [AppFile] -> + {true, AppFile}; + _ -> + false + end. diff --git a/src/rebar_config.erl b/src/rebar_config.erl new file mode 100644 index 0000000..a6ad5b2 --- /dev/null +++ b/src/rebar_config.erl @@ -0,0 +1,44 @@ +%% ------------------------------------------------------------------- +%% +%% 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_config). + +-export([new/1, + get_modules/2]). + +-record(config, { dir, + opts }). + +new(Dir) -> + {ok, DefaultConfig} = application:get_env(rebar, default_config), + #config { dir = Dir, + opts = orddict:from_list(DefaultConfig)}. + +get_modules(Config, app) -> + case orddict:find(app_modules, Config#config.opts) of + error -> + []; + {ok, Modules} -> + Modules + end. diff --git a/src/rebar_doterl_compiler.erl b/src/rebar_doterl_compiler.erl new file mode 100644 index 0000000..91828cd --- /dev/null +++ b/src/rebar_doterl_compiler.erl @@ -0,0 +1,46 @@ +%% ------------------------------------------------------------------- +%% +%% 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_doterl_compiler). + +-export([compile/2, + clean/2]). + +-include("rebar.hrl"). + +%% =================================================================== +%% Public API +%% =================================================================== + +compile(Config, Dir) -> + io:format(".erl compiling: ~s\n", [Dir]), + ok. + +clean(Config, Dir) -> + rebar_utils:delete_files("ebin/*.beam"). + + +%% =================================================================== +%% Internal functions +%% =================================================================== diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl new file mode 100644 index 0000000..0b12d66 --- /dev/null +++ b/src/rebar_rel_utils.erl @@ -0,0 +1,38 @@ +%% ------------------------------------------------------------------- +%% +%% 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_rel_utils). + +-export([is_rel_dir/0, is_rel_dir/1]). + +is_rel_dir() -> + is_rel_dir(rebar_util:get_cwd()). + +is_rel_dir(Dir) -> + case filelib:wildcard("*.rel") of + [_File] -> + true; + _ -> + false + end. diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl new file mode 100644 index 0000000..0ad6edc --- /dev/null +++ b/src/rebar_utils.erl @@ -0,0 +1,31 @@ +%% ------------------------------------------------------------------- +%% +%% 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_utils). + +-export([get_cwd/0]). + +get_cwd() -> + {ok, Dir} = file:get_cwd(), + Dir. -- cgit v1.1