您使用哪个工具来构建Erlang程序:Emake、Makiefile还是其他工具?
自那以后,Erlang社区出现了一种新的标准:
我们也使用类似的Emakefile。
{"src/*", [debug_info, {outdir, "ebin"}, {i, "include"}]}.
我使用Erlang的构建功能在成功编译后运行测试。all: compile
compile:
erlc -o ebin +debug_info erl_make.erl
erl -pa ./ebin -eval "erl_make:make(development)" -s init stop -noshell
erl_make.erl
-module(erl_make).
-export([make/1]).
make(Mode) ->
case make:all([{d, Mode}]) of
error ->
error;
_ ->
test_suite:test()
end.
这里是我通常使用的Makefile和Emakefile,使用make命令(来源未知)。
Makefile:
ERL=erl
APPFILE=myApp.app
all: ebin/$(APPFILE)
$(ERL) -make
ebin/$(APPFILE): src/$(APPFILE)
cp $< $@
Emakefile:
{"src/*", [debug_info, {outdir, "ebin"}, {i, "include"}]}.
-module(eakefile). -compile([export_all]). -import(eake, [task/3, namespace/3, run_target/2, run/1]).这是一个使用示例:
execute() -> [
namespace(db, "test", [ task(migrate, "That is migration", fun(Params) -> io:format("in migration params: ~w", [Params]), run_target('db:rollback', []) end),
task(rollback, "That is rollback", fun(_) -> io:format("in rollback"), run("ls") end) ]) ].
$ eake db:migrate $ eake db:migrate db:rollback $ eake db:migrate=[1,atom] $ eake db:migrate=name
你可以查看我的Makefiles,我从mochiweb或类似的地方获取了它们。 抱歉,但代码有一些特定于项目的部分。
http://github.com/JLarky/eadc-hub/blob/master/Makefile
MARKDOWN_SOURCES=$(wildcard doc/*.md) MARKDOWN_TARGETS=$(patsubst doc/%.md,doc/html/%.html,$(MARKDOWN_SOURCES))
all: eadc boot deps
eadc: ebin cd src && $(MAKE)
deps: (cd deps/somedeps;$(MAKE);)
docs: erlang-docs # html-docs
erlang-docs: doc/edoc (cd src;$(MAKE) docs)
html-docs: doc/html $(MARKDOWN_TARGETS)
doc/edoc: 创建目录 doc/edoc
doc/html: 创建目录 doc/html
doc/html/%.html: doc/%.md (title=`grep '^# ' $ $@ ;\ python doc/buildtoc.py $$t ;\ markdown $$t >> $@ ;\ rm $$t ;\ cat doc/footer.html >> $@)
ebin: 创建目录 ebin
clean: clean-docs (cd src;$(MAKE) clean) (cd deps/*/; $(MAKE) clean) $(RM) -r priv $(RM) ebin/*.boot ebin/*.script ebin/*crash.dump ebin/*~ src/*~ priv/*~ *~ \#*\#
clean-docs: clean-html $(rm) -rf doc/edoc
clean-html: rm -rf doc/html
boot: ebin/eadc.boot
ebin/eadc.boot: ebin/eadc.rel ebin/eadc.app erl -pa ebin -noshel -run eadc_utils make_script -run erlang halt
cleandb: $(RM) -r ebin/Mnesia*
http://github.com/JLarky/eadc-hub/blob/master/support/include.mk
## -*- makefile -*- ## Erlanghttp://github.com/JLarky/eadc-hub/blob/master/src/Makefile
包含 ../support/include.mk