summaryrefslogtreecommitdiff
path: root/deps/setup/rebar.config.script
blob: ac3280149bced8fd2c8cd655b95e1fd9c30ac655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
%% -*- erlang -*-
%%
%% If the environment variable X_COMP is set, it is an indication that self is being compiled
%% as a dependency under exodev. Since exodev lists all dependency in its root rebar.config 
%% file in order to have a flat view of the dependency tree, we should nil out our local
%% deps list provided by our local rebar.config
%%
C0 = case os:getenv("EXODEV_COMP") of
    false ->
        CONFIG;

    _ ->
        case lists:keytake(deps, 1, CONFIG) of
            { value, _, Remainder } -> Remainder;
            _ -> CONFIG
        end
end,
C1 = case os:getenv("REBAR_DEPS") of
         false -> C0;
         [] -> C0;
         Dir ->
             lists:keystore(deps_dir, 1, C0, {deps_dir, Dir})
     end.

C3 =
case os:getenv("TGT") of
    false ->
	C1;
    [] ->
	C1;
    Tgt ->
	io:fwrite("Tgt = ~p~n", [Tgt]),
	{_, Opts} = lists:keyfind(edoc_opts, 1, C1),
	{_, {F,URL}} = lists:keyfind(top_level_readme, 1, Opts),
	Name = lists:last(string:tokens(URL, "/")),
	io:fwrite("Name = ~s~n", [Name]),
	NewURL = re:replace(URL, "[^/]+/" ++ Name, Tgt ++ "/" ++ Name,
			    [{return, list}]),
	C2 =
	    lists:keyreplace(
	      edoc_opts, 1,
	      C1,
	      {edoc_opts, lists:keyreplace(top_level_readme, 1, Opts,
					   {top_level_readme, {F, NewURL}})}),
	io:fwrite("CONFIG1 = ~p~n", [C2]),
	C2
end.

REBAR = escript:script_name().
case lists:keyfind(post_hooks, 1, C3) of
    {_, PostHooks} ->
	PH1 = lists:map(
		fun({compile, "make escriptize"}) ->
			{compile, REBAR ++ " escriptize"};
		   (X) -> X
		end, PostHooks),
	lists:keyreplace(
	  post_hooks, 1, C3, {post_hooks, PH1});
    false ->
	C3
end.