Sfoglia il codice sorgente

add compile type for dynamic project compilation

pull/1893/head
Tristan Sloughter 6 anni fa
parent
commit
8df694d426
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: AAB97DDECCEB8150
3 ha cambiato i file con 28 aggiunte e 2 eliminazioni
  1. +1
    -1
      src/rebar_app_discover.erl
  2. +14
    -0
      src/rebar_app_info.erl
  3. +13
    -1
      src/rebar_prv_compile.erl

+ 1
- 1
src/rebar_app_discover.erl Vedi File

@ -427,7 +427,7 @@ try_handle_app_src_file(AppInfo, _, _AppDir, [], _Validate) ->
%% a .app after this step
case filelib:is_file(filename:join(rebar_app_info:dir(AppInfo), "mix.exs")) of
true ->
{true, AppInfo};
{true, rebar_app_info:compile_type(AppInfo, mix)};
false ->
false
end;

+ 14
- 0
src/rebar_app_info.erl Vedi File

@ -47,6 +47,8 @@
set/3,
source/1,
source/2,
compile_type/1,
compile_type/2,
is_lock/1,
is_lock/2,
is_checkout/1,
@ -89,6 +91,7 @@
is_lock=false :: boolean(),
is_checkout=false :: boolean(),
valid :: boolean() | undefined,
compile_type :: rebar3 | mix | undefined,
is_available=false :: boolean()}).
%%============================================================================
@ -500,6 +503,17 @@ is_available(#app_info_t{is_available=IsAvailable}) ->
is_available(AppInfo=#app_info_t{}, IsAvailable) ->
AppInfo#app_info_t{is_available=IsAvailable}.
%% @doc
-spec compile_type(t()) -> atom().
compile_type(#app_info_t{compile_type=CompileType}) ->
CompileType.
%% @doc
-spec compile_type(t(), atom()) -> t().
compile_type(AppInfo=#app_info_t{}, CompileType) ->
AppInfo#app_info_t{compile_type=CompileType}.
%% @doc returns whether the app is valid (built) or not
-spec valid(t()) -> boolean().
valid(AppInfo=#app_info_t{valid=undefined}) ->

+ 13
- 1
src/rebar_prv_compile.erl Vedi File

@ -150,7 +150,19 @@ compile(State, Providers, AppInfo) ->
AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State),
AppInfo2 = rebar_hooks:run_all_hooks(AppDir, pre, ?ERLC_HOOK, Providers, AppInfo1, State),
rebar_erlc_compiler:compile(AppInfo2),
case rebar_app_info:compile_type(AppInfo) of
mix ->
rebar_utils:sh("mix compile --no-deps-check --no-protocol-consolidation",
[{cd, AppDir},
{return_on_error, true},
{use_stdout, true},
{env, [{"MIX_BUILD_PATH", filename:join(AppDir, "../../")},
{"MIX_ENV", "prod"}]}]);
_ ->
rebar_erlc_compiler:compile(AppInfo2)
end,
AppInfo3 = rebar_hooks:run_all_hooks(AppDir, post, ?ERLC_HOOK, Providers, AppInfo2, State),
AppInfo4 = rebar_hooks:run_all_hooks(AppDir, pre, ?APP_HOOK, Providers, AppInfo3, State),

Caricamento…
Annulla
Salva