Maxim Sokhatsky 10 years ago
parent
commit
34bebfe5ea
4 changed files with 16 additions and 1 deletions
  1. BIN
      mad
  2. 1 1
      rebar.config
  3. 13 0
      src/compile/mad_leex.erl
  4. 2 0
      src/mad_compile.erl

BIN
mad


+ 1 - 1
rebar.config

@@ -1,2 +1,2 @@
 {deps_dir,"deps"}.
-{deps, [{sh, ".*", {git, "git://github.com/synrc/sh", "HEAD"}}]}.
+{deps, [{sh, ".*", {git, "git://github.com/synrc/sh", {tag, "0.9"}}}]}.

+ 13 - 0
src/compile/mad_leex.erl

@@ -0,0 +1,13 @@
+-module(mad_leex).
+-copyright('Sina Samavati').
+-compile(export_all).
+
+xrl_to_erl(F) -> filename:join(filename:dirname(F),filename:basename(F, ".xrl")) ++ ".erl".
+
+compile(File,Inc,Bin,Opt) ->
+    ErlFile = xrl_to_erl(File),
+    Compiled = mad_compile:is_compiled(ErlFile,File),
+    if Compiled == false ->
+        leex:file(File),
+        mad_erl:compile(ErlFile,Inc,Bin,Opt); true -> ok end.
+

+ 2 - 0
src/mad_compile.erl

@@ -26,6 +26,7 @@ dep(Cwd, _Conf, ConfigFile, Name) ->
     SrcDir = filename:join([mad_utils:src(DepPath)]),
 
     Files = files(SrcDir,".yrl") ++ 
+            files(SrcDir,".xrl") ++ 
             files(SrcDir,".erl") ++ % comment this to build with erlc/1
             files(SrcDir,".app.src"),
 
@@ -56,6 +57,7 @@ compile_fun(Inc,Bin,Opt) -> fun(File) -> (module(filetype(File))):compile(File,I
 module("erl") -> mad_erl;
 module("erl.src") -> mad_utils;
 module("yrl") -> mad_yecc;
+module("xrl") -> mad_leex;
 module("app.src") -> mad_app.
 
 filetype(Path) -> string:join(tl(string:tokens(filename:basename(Path), ".")), ".").