Browse Source

merl shipped with Erlang/OTP as of v18.0.

Andreas Stenius 10 years ago
parent
commit
b992c452c1
7 changed files with 51 additions and 19 deletions
  1. 3 2
      .travis.yml
  2. 1 1
      Makefile
  3. 3 2
      rebar-slex.config
  4. 3 12
      rebar.config
  5. 31 0
      rebar.config.script
  6. 4 0
      src/erlydtl_beam_compiler.erl
  7. 6 2
      test/erlydtl_eunit_testrunner.erl

+ 3 - 2
.travis.yml

@@ -1,4 +1,5 @@
 language: erlang
+sudo: false
 otp_release:
 # Test on all supported releases accepted by the `require_otp_vsn` in rebar.config
    - 18.0
@@ -18,9 +19,9 @@ otp_release:
 #   - R15B failing with timeout
 
 # since Travis is naughty and calls rebar get-deps behind our backs,
-# we'll have to clean it up and build merl our selves..
+# we'll have to clean it up and build merl our selves.. (pre OTP 18.0)
 script: 
-  - "make -C deps/merl && make check"
+  - "[ ! -d deps/merl ] || make -C deps/merl && make check"
 
 notifications:
   irc: "chat.freenode.net#erlydtl"

+ 1 - 1
Makefile

@@ -44,7 +44,7 @@ plt: compile
 		$(PLT_APPS) deps/* || [ $$? -eq 2 ];
 
 clean:
-	@echo "Clean merl..." ; $(MAKE) -C deps/merl clean
+	@[ ! -d deps/merl ] || { echo "Clean merl..." ; $(MAKE) -C deps/merl clean ;}
 	@$(REBAR) -C rebar-slex.config clean
 	rm -fv erl_crash.dump
 

+ 3 - 2
rebar-slex.config

@@ -1,8 +1,9 @@
 %% -*- mode: erlang -*-
 
 {deps,
- [{slex, ".*", {git, "git://github.com/erlydtl/slex.git", {branch, "master"}}},
-  {merl, ".*", {git, "git://github.com/erlydtl/merl.git", {branch, "erlydtl"}}, [raw]}
+ [ %% uncomment merl dep in not building on OTP 18.0 or later..
+   %% {merl, ".*", {git, "git://github.com/erlydtl/merl.git", {branch, "erlydtl"}}, [raw]},
+   {slex, ".*", {git, "git://github.com/erlydtl/slex.git", {branch, "master"}}}
  ]
 }.
 

+ 3 - 12
rebar.config

@@ -18,21 +18,12 @@
  ]}.
 
 {deps,
- [{merl, ".*",
-   {git, "git://github.com/erlydtl/merl.git", {branch, "erlydtl"}},
-   [raw]},
-  {eunit_formatters, ".*",
+ [{eunit_formatters, ".*",
    {git, "git://github.com/seancribbs/eunit_formatters", {branch, "master"}}}
  ]}.
 
 {pre_hooks,
- [{"(linux|darwin|solaris)", compile, "make -C \"$REBAR_DEPS_DIR/merl\" all -W test"},
-  {"(freebsd|netbsd|openbsd)", compile, "gmake -C \"$REBAR_DEPS_DIR/merl\" all"},
-  {"win32", compile, "make -C \"%REBAR_DEPS_DIR%/merl\" all -W test"},
-  {eunit,
+ [{eunit,
    "erlc -I include/erlydtl_preparser.hrl -o test"
-   " test/erlydtl_extension_testparser.yrl"},
-  {"(linux|darwin|solaris)", eunit, "make -C \"$REBAR_DEPS_DIR/merl\" test"},
-  {"(freebsd|netbsd|openbsd)", eunit, "gmake -C \"$REBAR_DEPS_DIR/merl\" test"},
-  {"win32", eunit, "make -C \"%REBAR_DEPS_DIR%/merl\" test"}
+   " test/erlydtl_extension_testparser.yrl"}
  ]}.

+ 31 - 0
rebar.config.script

@@ -0,0 +1,31 @@
+%% -*- mode: erlang -*-
+
+Patch = fun (Key, Value, Config) ->
+                case lists:keysearch(Key, 1, Config) of
+                    {value, {_, Org}} ->
+                        lists:keyreplace(Key, 1, Config, {Key, Org ++ Value});
+                    false ->
+                        [{Key, Value}|Config]
+                end
+        end,
+
+application:load(syntax_tools),
+case application:get_key(syntax_tools, vsn) of
+    {ok, Vsn} when "1.7" > Vsn ->
+        Deps = [{merl, ".*",
+                 {git, "git://github.com/erlydtl/merl.git", {branch, "erlydtl"}},
+                 [raw]}],
+        PreHooks =
+            [{"(linux|darwin|solaris)", compile, "make -C \"$REBAR_DEPS_DIR/merl\" all -W test"},
+             {"(freebsd|netbsd|openbsd)", compile, "gmake -C \"$REBAR_DEPS_DIR/merl\" all"},
+             {"win32", compile, "make -C \"%REBAR_DEPS_DIR%/merl\" all -W test"},
+             {"(linux|darwin|solaris)", eunit, "make -C \"$REBAR_DEPS_DIR/merl\" test"},
+             {"(freebsd|netbsd|openbsd)", eunit, "gmake -C \"$REBAR_DEPS_DIR/merl\" test"},
+             {"win32", eunit, "make -C \"%REBAR_DEPS_DIR%/merl\" test"}],
+        lists:foldl(fun ({K, V}, C) -> Patch(K, V, C) end, CONFIG,
+                    [{deps, Deps},
+                     {pre_hooks, PreHooks},
+                     {erl_opts, [{d, 'MERL_DEP'}]}]);
+    _ ->
+        CONFIG
+end.

+ 4 - 0
src/erlydtl_beam_compiler.erl

@@ -67,7 +67,11 @@
          load_library/4, shorten_filename/2, push_auto_escape/2,
          pop_auto_escape/1, token_pos/1, is_stripped_token_empty/1]).
 
+-ifdef(MERL_DEP).
 -include_lib("merl/include/merl.hrl").
+-else.
+-include_lib("syntax_tools/include/merl.hrl").
+-endif.
 -include("erlydtl_ext.hrl").
 
 

+ 6 - 2
test/erlydtl_eunit_testrunner.erl

@@ -60,8 +60,12 @@ run_compile(T) ->
     of
         {ok, M, W0} ->
             ?assertEqual(T#test.module, M),
-            %% ignore useless_building warnings on line 588 in anonymous files
-            W = W0 -- [{[], [{588, sys_core_fold, useless_building}]}],
+            %% ignore useless_building warnings
+            W = lists:flatten(
+                  [case W1 of
+                       {_, [{_, sys_core_fold, useless_building}]} -> [];
+                       _ -> W1
+                   end || W1 <- W0]),
             ?assertEqual(T#test.warnings, W);
         {error, E, W} ->
             ?assertEqual(T#test.errors, E),