added naive Makefile, stubs of modules, unit test coordinator (test_master)

This commit is contained in:
aj
2010-11-03 00:30:59 -07:00
parent 992a7d8e1a
commit 59f18e4270
4 changed files with 84 additions and 0 deletions

25
Makefile Normal file
View File

@@ -0,0 +1,25 @@
ERLC_WARNINGS = -W1
MNESIA_DIR = db
RUN_INIT = -s ezic start
all : clean compile
nowarn : ERLC_WARNINGS = -W0
nowarn : clean compile
test : ERLC_WARNINGS = -W0
test : OPTIONS := $(OPTIONS) -DTEST
test : all
erlc $(ERLC_WARNINGS) $(OPTIONS) -o ./ebin ./tests/*.erl
erl -noshell -pa ebin -s test_master start -s erlang halt
compile :
erlc $(ERLC_WARNINGS) $(OPTIONS) -o ./ebin ./src/*.erl
-erl -noshell -pa ebin -s erldev make_app . -s erlang halt
clean :
-@rm ebin/*
run :
erl -pa ebin -mnesia dir $(MNESIA_DIR) $(RUN_INIT)

48
src/erldev.erl Normal file
View File

@@ -0,0 +1,48 @@
-module(erldev).
%% Contains development-related functions.
%-compile([export_all]).
-export([make_app/1]).
%% "Compiles" a *.app.src file into a .app file, and places it in
%% the appropriate ebin folder
make_app([AppDirAtom]) ->
%%@todo: module name conflicts?
AppDir = atom_to_list(AppDirAtom),
Modules = get_modules(AppDir),
AppSrc = try get_app_src(AppDir)
catch error:{badmatch, _} ->
io:format("Couldn't get AppSrcFile for ~p~n", [AppDir]),
erlang:halt()
end,
{application, Name, Opts} = AppSrc,
NewOpts = [ {modules, Modules} | Opts ],
AppFile = filename:join([AppDir, "ebin", atom_to_list(Name) ++ ".app"]),
ok = file:write_file(AppFile, io_lib:format("~p.~n", [{application, Name, NewOpts}])),
io:format("Wrote .app contents to: ~p~n", [AppFile]),
ok.
%% Returns a list of module names of all *.erl files in a given Application
%% folder (assuming OTP directory structure)
get_modules(AppDir) ->
lists:map(
fun(X)-> filename:basename(X, ".erl") end,
filelib:wildcard(
filename:join([AppDir, "src", "*.erl"])
)
).
%% Converts the contsnts of the *.app.src file into erlang terms
get_app_src(AppDir) ->
[AppSrcFile] = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])),
{ok, [AppSrc]} = file:consult(AppSrcFile),
%io:format("AppSrc: ~p~n", [AppSrc]),
AppSrc.

6
src/ezic.erl Normal file
View File

@@ -0,0 +1,6 @@
-module(ezic).
-export([start/0]).
start() ->
void.

5
tests/test_master.erl Normal file
View File

@@ -0,0 +1,5 @@
-module(test_master).
-export([start/0]).
start() ->
void.