mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Sketching out templating system
This commit is contained in:
parent
3ed1b99438
commit
2d9af6cf48
6 changed files with 118 additions and 2 deletions
|
@ -23,8 +23,10 @@
|
||||||
rebar_rel_utils,
|
rebar_rel_utils,
|
||||||
rebar_reltool,
|
rebar_reltool,
|
||||||
rebar_subdirs,
|
rebar_subdirs,
|
||||||
|
rebar_templater,
|
||||||
rebar_utils,
|
rebar_utils,
|
||||||
getopt ]},
|
getopt,
|
||||||
|
mustache ]},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel,
|
{applications, [kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
|
@ -39,7 +41,8 @@
|
||||||
%% any_dir processing modules
|
%% any_dir processing modules
|
||||||
{any_dir_modules, [
|
{any_dir_modules, [
|
||||||
rebar_subdirs,
|
rebar_subdirs,
|
||||||
rebar_deps
|
rebar_deps,
|
||||||
|
rebar_templater
|
||||||
]},
|
]},
|
||||||
|
|
||||||
%% Dir specific processing modules
|
%% Dir specific processing modules
|
||||||
|
|
15
priv/templates/simpleapp.app
Normal file
15
priv/templates/simpleapp.app
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{application, {{appid}},
|
||||||
|
[
|
||||||
|
{description, ""},
|
||||||
|
{vsn, "1"},
|
||||||
|
{modules, [
|
||||||
|
{{appid}}_app,
|
||||||
|
{{appid}}_sup
|
||||||
|
]},
|
||||||
|
{registered, []},
|
||||||
|
{applications, [
|
||||||
|
kernel,
|
||||||
|
stdlib
|
||||||
|
]},
|
||||||
|
{env, []}
|
||||||
|
]}.
|
3
priv/templates/simpleapp.template
Normal file
3
priv/templates/simpleapp.template
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{file, "simpleapp.app", "ebin/{{appid}}.app"}.
|
||||||
|
{file, "simpleapp_app.erl", "src/{{appid}}_app.erl"}.
|
||||||
|
{file, "simpleapp_sup.erl", "src/{{appid}}_sup.erl"}.
|
16
priv/templates/simpleapp_app.erl
Normal file
16
priv/templates/simpleapp_app.erl
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
-module({{appid}}_app).
|
||||||
|
|
||||||
|
-behaviour(application).
|
||||||
|
|
||||||
|
%% Application callbacks
|
||||||
|
-export([start/2, stop/1]).
|
||||||
|
|
||||||
|
%% ===================================================================
|
||||||
|
%% Application callbacks
|
||||||
|
%% ===================================================================
|
||||||
|
|
||||||
|
start(_StartType, _StartArgs) ->
|
||||||
|
{{appid}}_sup:start_link().
|
||||||
|
|
||||||
|
stop(_State) ->
|
||||||
|
ok.
|
28
priv/templates/simpleapp_sup.erl
Normal file
28
priv/templates/simpleapp_sup.erl
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
-module({{appid}}_sup).
|
||||||
|
|
||||||
|
-behaviour(supervisor).
|
||||||
|
|
||||||
|
%% API
|
||||||
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
%% Supervisor callbacks
|
||||||
|
-export([init/1]).
|
||||||
|
|
||||||
|
%% Helper macro for declaring children of supervisor
|
||||||
|
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
|
||||||
|
|
||||||
|
%% ===================================================================
|
||||||
|
%% API functions
|
||||||
|
%% ===================================================================
|
||||||
|
|
||||||
|
start_link() ->
|
||||||
|
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
|
||||||
|
|
||||||
|
%% ===================================================================
|
||||||
|
%% Supervisor callbacks
|
||||||
|
%% ===================================================================
|
||||||
|
|
||||||
|
init([]) ->
|
||||||
|
{ok, {one_for_one, 5, 10}, []}.
|
||||||
|
|
51
src/rebar_templater.erl
Normal file
51
src/rebar_templater.erl
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
||||||
|
%% ex: ts=4 sw=4 et
|
||||||
|
%% -------------------------------------------------------------------
|
||||||
|
%%
|
||||||
|
%% 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_templater).
|
||||||
|
|
||||||
|
-export([create/2]).
|
||||||
|
|
||||||
|
-include("rebar.hrl").
|
||||||
|
|
||||||
|
%% ===================================================================
|
||||||
|
%% Public API
|
||||||
|
%% ===================================================================
|
||||||
|
|
||||||
|
create(_Config, _) ->
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%% ===================================================================
|
||||||
|
%% Internal functions
|
||||||
|
%% ===================================================================
|
||||||
|
|
||||||
|
% execute_template([]) ->
|
||||||
|
% ok;
|
||||||
|
% execute_template([{file, Input, Output} | Rest]) ->
|
||||||
|
% ok;
|
||||||
|
% execute_template([{dir, Name} | Rest]) ->
|
||||||
|
% ok.
|
Loading…
Reference in a new issue