added naive Makefile, stubs of modules, unit test coordinator (test_master)
This commit is contained in:
25
Makefile
Normal file
25
Makefile
Normal 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
48
src/erldev.erl
Normal 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
6
src/ezic.erl
Normal file
@@ -0,0 +1,6 @@
|
||||
-module(ezic).
|
||||
|
||||
-export([start/0]).
|
||||
|
||||
start() ->
|
||||
void.
|
||||
5
tests/test_master.erl
Normal file
5
tests/test_master.erl
Normal file
@@ -0,0 +1,5 @@
|
||||
-module(test_master).
|
||||
-export([start/0]).
|
||||
|
||||
start() ->
|
||||
void.
|
||||
Reference in New Issue
Block a user