繁体   English   中英

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

[英]What tool do you use to build an Erlang program?

您使用什么工具来构建Erlang程序:Emake,makiefile或其他?

自从这些答案以来,Erlang社区出现了一个新标准:

Rebar https://github.com/basho/rebar/

我们也使用类似的Emakefile。

{"src/*", [debug_info, {outdir, "ebin"}, {i, "include"}]}.

我使用erlang make功能在成功编译后运行测试。

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.

我使用调用Emakefile的Rakefile。 Rakefile的灵活性和Emakefile的速度

这个构建系统非常强大,请参阅GitHub上的 erl_rake

生成.app文件,自动构建版本,运行EUnit测试。 鉴于它是围绕Rakefile构建的,我已经添加了轻松推送发布到AWS并使用etap运行我的测试。

我为我的github项目定制了一个旧版本。

这是我通常与make一起使用的Makefile和Emakefile(origin unknown)。

Makefile文件:

ERL=erl
APPFILE=myApp.app

all: ebin/$(APPFILE)
    $(ERL) -make 

ebin/$(APPFILE): src/$(APPFILE)
    cp $< $@ 

Emakefile:

{"src/*", [debug_info, {outdir, "ebin"}, {i, "include"}]}.

我提出了自己的工具:) 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

使用思南建设和Faxien安装! 查看erlware.org。 它们比make文件更好,并且易于分发。 它们都处于积极的发展阶段,将在以下网站上发布: http//www.manning.com/logan/

你可以查看我的Makefiles,我从mochiweb或类似的东西中取出它们。 对不起,但代码有一些项目指定的部分

http://github.com/JLar​​ky/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:
mkdir -p doc/edoc

doc/html:
mkdir -p doc/html

doc/html/%.html: doc/%.md
(title=`grep '^# ' $ $@ ;\
python doc/buildtoc.py  $$t ;\
markdown $$t >> $@ ;\
rm $$t ;\
cat doc/footer.html >> $@)

ebin:
mkdir -p 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/JLar​​ky/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/JLar​​ky/eadc-hub/blob/master/src/Makefile

include ../support/include.mk

all: $(EBIN_FILES_NO_DOCS)

docs: $(ERL_DOCUMENTS)
 *emphasized text*
debug:
$(MAKE) DEBUG=-DDEBUG

clean:
rm -rf $(EBIN_FILES) $(PLUGINS_OBJECTS)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM