Current section

13 Versions

Jump to

Compare versions

7 files changed
+39 additions
-24 deletions
  @@ -29,4 +29,4 @@
29 29 {<<"GitHub">>,<<"https://github.com/clojerl/rebar3_clojerl">>}]}.
30 30 {<<"name">>,<<"rebar3_clojerl">>}.
31 31 {<<"requirements">>,[]}.
32 - {<<"version">>,<<"0.8.1">>}.
32 + {<<"version">>,<<"0.8.2">>}.
  @@ -1,6 +1,6 @@
1 1 {application,rebar3_clojerl,
2 2 [{description,"Compile clojerl projects"},
3 - {vsn,"0.8.1"},
3 + {vsn,"0.8.2"},
4 4 {registered,[]},
5 5 {applications,[kernel,stdlib]},
6 6 {env,[]},
  @@ -7,7 +7,7 @@
7 7 -define(PROVIDER, compile).
8 8 -define(NAMESPACE, clojerl).
9 9 -define(NAMESPACE_PROVIDER, {?NAMESPACE, ?PROVIDER}).
10 - -define(DEPS, [{default, lock}]).
10 + -define(DEPS, [{default, compile}]).
11 11
12 12 -type config() :: #{ ebin_dir => file:name()
13 13 , protocols_dir => file:name()
  @@ -45,7 +45,7 @@ do(State) ->
45 45 AppsPaths = [rebar_app_info:ebin_dir(AppInfo) || AppInfo <- ProjectApps],
46 46 ok = code:add_pathsa(AppsPaths),
47 47
48 - Apps0 = Deps1 ++ ProjectApps,
48 + AllApps0 = Deps1 ++ ProjectApps,
49 49 Config = #{protocols_dir => protocols_dir(State)},
50 50
51 51 try
  @@ -58,8 +58,12 @@ do(State) ->
58 58 Providers = rebar_state:providers(State),
59 59 rebar_hooks:run_all_hooks(Cwd, pre, ?NAMESPACE_PROVIDER, Providers, State),
60 60
61 - Apps1 = compile_clojerl(Apps0, Config, Providers, State),
62 - [compile(AppInfo, Config, Providers, State) || AppInfo <- Apps1],
61 + %% The Erlang modules for clojerl have been compiled at this point.
62 + %% Make sure the clojerl application is available and started.
63 + ok = rebar3_clojerl_utils:ensure_clojerl(),
64 +
65 + AllApps1 = compile_clojerl(AllApps0, Config, Providers, State),
66 + [compile(AppInfo, Config, Providers, State) || AppInfo <- AllApps1],
63 67
64 68 %% Run top level post hooks
65 69 rebar_hooks:run_all_hooks(Cwd, post, ?NAMESPACE_PROVIDER, Providers, State)
  @@ -88,13 +92,21 @@ protocols_dir(State) ->
88 92 %% When there are no applications use Clojerl's ebin
89 93 [] ->
90 94 Deps = rebar_state:all_deps(State),
91 - {ok, ClojerlApp} = rebar3_clojerl_utils:find_app(Deps, ?CLOJERL),
92 - ProtoDir = rebar_app_info:ebin_dir(ClojerlApp),
93 - rebar_api:debug( "No project apps, using Clojerl's "
94 - "ebin as protocol dir: ~s"
95 - , [ProtoDir]
96 - ),
97 - ProtoDir
95 + case rebar3_clojerl_utils:find_app(Deps, ?CLOJERL) of
96 + {ok, ClojerlApp} ->
97 + ProtoDir = rebar_app_info:ebin_dir(ClojerlApp),
98 + rebar_api:debug( "No project apps, using Clojerl's "
99 + "ebin as protocol dir: ~s"
100 + , [ProtoDir]
101 + ),
102 + ProtoDir;
103 + notfound ->
104 + rebar_api:debug( "No project apps or Clojerl as a dep, "
105 + "using './ebin' as protocol dir"
106 + , []
107 + ),
108 + "ebin"
109 + end
98 110 end.
99 111
100 112 -spec compile_clojerl( [rebar_app_info:t()]
  @@ -103,12 +115,13 @@ protocols_dir(State) ->
103 115 , rebar_state:t()
104 116 ) ->
105 117 [rebar_app_info:t()].
106 - compile_clojerl(Apps, Config, Providers, State) ->
107 - case rebar3_clojerl_utils:find_app(Apps, ?CLOJERL) of
108 - notfound -> Apps;
118 + compile_clojerl(AllApps, Config, Providers, State) ->
119 + case rebar3_clojerl_utils:find_app(AllApps, ?CLOJERL) of
120 + notfound ->
121 + AllApps;
109 122 {ok, ClojerlApp} ->
110 123 compile(ClojerlApp, Config, Providers, State),
111 - Apps -- [ClojerlApp]
124 + AllApps -- [ClojerlApp]
112 125 end.
113 126
114 127 -spec backup_duplicates([rebar_app_info:t()], config()) -> ok.
  @@ -157,8 +170,6 @@ compile(AppInfo0, Config0, Providers, State) ->
157 170 , State
158 171 ),
159 172
160 - ok = rebar3_clojerl_utils:ensure_clojerl(),
161 -
162 173 Graph = load_graph(AppInfo),
163 174 Config1 = Config0#{graph => Graph},
164 175 AppName = rebar_app_info:name(AppInfo),
  @@ -191,7 +202,7 @@ compile(AppInfo0, Config0, Providers, State) ->
191 202
192 203 -spec compile_clje(file:name(), config()) -> ok.
193 204 compile_clje(Src, Config) ->
194 - io:format("%%% Compiling ~s...~n", [Src]),
205 + io:format("===> Compiling ~s...~n", [Src]),
195 206
196 207 SrcDir = list_to_binary(maps:get(src_dir, Config)),
197 208 EbinDir = list_to_binary(maps:get(ebin_dir, Config)),
  @@ -6,7 +6,6 @@
6 6
7 7 -define(PROVIDER, escriptize).
8 8 -define(NAMESPACE, clojerl).
9 - -define(NAMESPACE_PROVIDER, {?NAMESPACE, ?PROVIDER}).
10 9 -define(DEPS, [{?NAMESPACE, compile}]).
11 10
12 11 %% =============================================================================
  @@ -4,7 +4,6 @@
4 4
5 5 -define(PROVIDER, release).
6 6 -define(NAMESPACE, clojerl).
7 - -define(NAMESPACE_PROVIDER, {?NAMESPACE, ?PROVIDER}).
8 7 -define(DEPS, [{?NAMESPACE, compile}]).
9 8
10 9 %% =============================================================================
Loading more files…