你用什么工具来构建Erlang程序?

26

您使用哪个工具来构建Erlang程序:Emake、Makiefile还是其他工具?

7个回答

24

4
它实际上不是标准,而是一种贡献。由于它已经包含在发行版中,Erlang的make成为了一种标准。 - tuscland

15

我们也使用类似的Emakefile。

{"src/*", [debug_info, {outdir, "ebin"}, {i, "include"}]}.
我使用Erlang的构建功能在成功编译后运行测试。
Makefile提取如下:
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.

谢谢你的精彩回答!=) - Klas. S

7
我使用一个Rakefile来调用Emakefile。 Rakefile提供灵活性,而Emakefile提供速度!
这个构建系统非常强大,可以在GitHub上查看erl_rake。
它可以生成.app文件,自动构建发布版本,运行EUnit测试。 由于它是基于Rakefile构建的,因此我轻松地将发布推送到AWS,并使用etap运行我的测试。
我为我的github项目定制了一个旧版本。

1
谢谢Thom。虽然这个评论已经过时了。和其他人一样,我现在使用rebar。 - Eric

6

这里是我通常使用的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"}]}.

4
我提议使用我自己的工具 :) Eake ... 与 Ruby 环境中的 Rake 非常相似: http://github.com/andrzejsliwa/eake 或者 http://andrzejsliwa.com/2009/05/28/eake-narzedzie-budowania-dla-erlanga-bazujace-na-rake/ 这是一个 eakefile 的例子:
-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

2
使用Sinan进行构建,使用Faxien进行安装!请查看erlware.org。它们比make文件更好,并提供了分发的便利性。它们都在积极开发中,并将在以下内容中亮相:http://www.manning.com/logan/

1

你可以查看我的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 -*- ## Erlang
ERL := erl ERLC := $(ERL)c
INCLUDE_DIRS := ../include $(wildcard ../deps/*/include) EBIN_DIRS := $(wildcard ../deps/*/ebin) ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %)
ifndef no_debug_info ERLC_FLAGS += +debug_info endif
ifdef debug ERLC_FLAGS += -Ddebug endif
EBIN_DIR := ../ebin DOC_DIR := ../doc/edoc EMULATOR := beam
ERL_SOURCES := $(wildcard *.erl) ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl) ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.$(EMULATOR)) ERL_DOCUMENTS := $(ERL_SOURCES:%.erl=$(DOC_DIR)/%.html) ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR)) APP_FILES := $(wildcard *.app) REL_FILES := $(wildcard *.rel) EBIN_FILES_NO_DOCS = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app) $(REL_FILES:%.rel=../ebin/%.rel) EBIN_FILES = $(ERL_DOCUMENTS) $(EBIN_FILES_NO_DOCS)
MODULES = $(ERL_SOURCES:%.erl=%)
../ebin/%.app: %.app cp $

http://github.com/JLarky/eadc-hub/blob/master/src/Makefile

包含 ../support/include.mk
all: $(EBIN_FILES_NO_DOCS)
docs: $(ERL_DOCUMENTS) *强调文本* debug: $(MAKE) DEBUG=-DDEBUG
clean: rm -rf $(EBIN_FILES) $(PLUGINS_OBJECTS)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接