Просмотр исходного кода

fix(build): pre-compile parse_transform modules

Zaiming Shi 5 лет назад
Родитель
Сommit
aac3d79b7d
2 измененных файлов с 18 добавлено и 4 удалено
  1. 1 2
      apps/emqx_bridge_mqtt/rebar.config
  2. 17 2
      rebar.config.erl

+ 1 - 2
apps/emqx_bridge_mqtt/rebar.config

@@ -4,8 +4,7 @@
             warn_shadow_vars,
             warn_unused_import,
             warn_obsolete_guard,
-            debug_info,
-            {parse_transform}]}.
+            debug_info]}.
 
 {xref_checks, [undefined_function_calls, undefined_functions,
                locals_not_used, deprecated_function_calls,

+ 17 - 2
rebar.config.erl

@@ -2,7 +2,8 @@
 
 -export([do/2]).
 
-do(_Dir, CONFIG) ->
+do(Dir, CONFIG) ->
+    ok = compile_and_load_pase_transforms(Dir),
     dump(deps(CONFIG) ++ config()).
 
 bcrypt() ->
@@ -174,7 +175,7 @@ env(Name, Default) ->
 
 get_vsn() ->
     PkgVsn = case env("PKG_VSN", false) of
-                 false -> os:cmd("git describe --tags");
+                 false -> os:cmd("git describe --tags --always");
                  Vsn -> Vsn
              end,
     Vsn2 = re:replace(PkgVsn, "v", "", [{return ,list}]),
@@ -192,3 +193,17 @@ provide_bcrypt_dep() ->
 
 provide_bcrypt_release(ReleaseType) ->
     provide_bcrypt_dep() andalso ReleaseType =:= cloud.
+
+%% this is a silly but working patch.
+%% rebar3 does not handle umberella project's cross-app parse_transform well
+compile_and_load_pase_transforms(Dir) ->
+    PtFiles =
+        [ "apps/emqx_rule_engine/src/emqx_rule_actions_trans.erl"
+        ],
+    CompileOpts = [verbose,report_errors,report_warnings,return_errors,debug_info],
+    lists:foreach(fun(PtFile) -> {ok, _Mod} = compile:file(path(Dir, PtFile), CompileOpts) end, PtFiles).
+
+path(Dir, Path) -> str(filename:join([Dir, Path])).
+
+str(L) when is_list(L) -> L;
+str(B) when is_binary(B) -> unicode:characters_to_list(B, utf8).