1 %% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
2 %%%-------------------------------------------------------------------
3 %%%---------------------------------------------------------------------------
4 %%% @author Eric Merritt <ericbmerritt@gmail.com>
6 %%% This provides echo functionality to sinan. The ability to echo paths,
7 %%% include directories, etc to The caller
9 %%% @copyright (C) 2012 Erlware
10 %%%---------------------------------------------------------------------------
11 -module(sin_task_echo
).
15 -include_lib("sinan/include/sinan.hrl").
18 -export([description
/0, do_task
/2]).
21 -define(DEPS
, [depends
]).
23 %%====================================================================
25 %%====================================================================
27 %% @doc provides a description of this task
28 -spec
description() -> sin_task:task_description().
35 This task echos the information that the user requests to back to the caller in
36 a way that erlang can make use of. It mostly exists to make it easier to
37 integrate Sinan with make.
39 The two support arguments at the moment are `paths` and `includes`
41 You can get other information out of the state but it will not be nicely
48 example
= "echo paths",
50 short_desc
= "Displays the requested information on the command line",
53 %% @doc run all tests for all modules in the system
54 do_task(Config
, State0
) ->
55 lists:foldl(fun print_correct
/2, State0
, Config:match(additional_args
, [])).
58 %%====================================================================
59 %%% Internal functions
60 %%====================================================================
61 print_correct("paths", State
) ->
62 lists:foreach(fun(#app
{path
=Path
}) ->
63 io:format("-pa ~s ", [filename:join(Path
, "ebin")])
64 end, sin_state:get_value(release_apps
, State
)),
66 print_correct("includes", State
) ->
67 lists:foreach(fun(#app
{path
=Path
}) ->
68 io:format("-I ~s ", [filename:join(Path
, "include")])
69 end, sin_state:get_value(release_apps
, State
)),
71 print_correct(Else
, State
) ->
72 AtomRep
= erlang:list_to_atom(Else
),
73 io:format("~s ", [sin_state:get_value(AtomRep
, State
)]),