2009-10-17 17 views

Odpowiedz

6

Oto Makefile i Emakefile, z których najczęściej korzystam przy pomocy make (pochodzenie nieznane).

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

używam Rakefile wywołanie Emakefile. Rakefile dla elastyczności i Emakefile dla prędkości!

System ten build jest dość silny, patrz erl_rake na GitHub

Generuje .app plików, buduje wersje automatycznie uruchamia testu EUnit. A biorąc pod uwagę, że jest zbudowany wokół Rakefile, dodałem łatwo wypuszczając wersję do AWS i wykonuję testy z etapem.

Dostosowałem starą wersję do moich projektów github.

+0

Twój link github jest 404. Dzięki –

+1

Thom. Chociaż ten komentarz jest nieaktualny. Tak jak wszyscy, teraz używam zbrojenia – cstar

15

Używamy również podobnego pliku Emakefile.

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

Używam funkcji make erlang do uruchamiania testów po pomyślnej kompilacji.

ekstrakt 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

Dzięki za wspaniałą odpowiedź! =) –

1

Można sprawdzić moje Makefile, wziąłem je z mochiweb czy coś takiego. Niestety ale kod mają niektóre części projektu określonym

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

proponuję moje własne narzędzie :) Eake ...jest bardzo podobny do natarcia z Ruby środowiska:

http://github.com/andrzejsliwa/eake

lub

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

Oto przykład 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) 
    ]) 
]. 

i jest to przykład za pomocą:

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

Użyj Sinan do budowania i Faxien do instalacji! Sprawdź erlware.org. Są znacznie lepsze niż plik make i zapewniają łatwą dystrybucję. Oboje są w ciężkim aktywnego rozwoju i będzie opisywany w: http://www.manning.com/logan/

Powiązane problemy