2009-10-17 9 views

Répondre

24

Depuis ces réponses, une nouvelle norme a vu le jour dans la communauté Erlang:

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

+4

Ce n'est pas une norme en effet, mais une contribution. La marque d'Erlang est une norme car elle est incluse dans la distribution. – tuscland

6

Voici le fichier Makefile et Emakefile que j'utilise habituellement avec make (origine inconnue).

Makefile:

ERL=erl 
APPFILE=myApp.app 

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

ebin/$(APPFILE): src/$(APPFILE) 
    cp $< [email protected] 

Emakefile:

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

J'utilise un Rakefile appeler un Emakefile. Rakefile pour la flexibilité et Emakefile pour vitesse!

Ce système de construction est assez puissant, voir erl_rake sur GitHub

.app fichiers Génère, builds versions, exécute automatiquement EUnit essai. Et étant donné qu'il est construit autour d'un Rakefile, j'ai ajouté facilement la version AWS et j'ai exécuté mes tests avec etap à la place.

J'ai personnalisé une ancienne version pour mes projets github.

+0

Votre lien GitHub est 404. –

+1

Merci Thom. Bien que ce commentaire soit obsolète. Comme tout le monde, j'utilise maintenant les barres d'armature – cstar

15

Nous utilisons également un fichier Emake similaire. J'utilise la fonctionnalité erlang make pour exécuter des tests après une compilation réussie.

extrait de 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. 
+0

Merci pour cette excellente réponse! =) –

1

Vous pouvez vérifier mes Makefiles, je les ai pris de mochiweb ou quelque chose comme ça. Désolé, mais le code ont certaines parties spécifiées projet-

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: 
mkdir -p doc/edoc 

doc/html: 
mkdir -p doc/html 

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

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/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

 
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) 
4

Je vous propose mon propre outil :) Eake ...est très similaire à ratisser de l'environnement Ruby:

http://github.com/andrzejsliwa/eake

ou

http://andrzejsliwa.com/2009/05/28/eake-narzedzie-budowania-dla-erlanga-bazujace-na-rake/

Voici par exemple 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) 
    ]) 
]. 

ce qui est par exemple en utilisant:

 
$ eake db:migrate 
$ eake db:migrate db:rollback 
$ eake db:migrate=[1,atom] 
$ eake db:migrate=name 
2

Utilisez Sinan pour la construction et Faxien pour l'installation! Découvrez erlware.org. Ils sont bien meilleurs qu'un fichier make et facilitent la distribution. Ils sont à la fois dans le développement actif lourd et seront présentés dans: http://www.manning.com/logan/

Questions connexes