[erlang-questions] erlc speed (or lack thereof), Make and emake

Loïc Hoguin essen@REDACTED
Tue Jan 29 12:03:47 CET 2013


On 01/29/2013 03:32 AM, Serge Aleynikov wrote:
> Loïc,
>
> There's a little trick you can use in a make file to avoid spawning
> external shell to comma delimit files:
>
> empty :=
> space := $(empty) $(empty)
> comma := $(empty), $(empty)
>
> FILES   := $(wildcard src/*.erl)
> MODULES := $(subst $(space),$(comma),$(sort $(FILES:src/%.erl=%)))
>
> example:
>      @echo "UsingShell = $(shell ls src/*.erl | sed
> 's/src\///;s/\.erl/,/' | sed '$$s/.$$//')"
>      @echo "UsingMake  = $(MODULES)"

Your "little" trick is a lot more verbose. :) I don't think the external 
call slows anything down. Good to know it's possible though.

> And also for the app target you can just do:
>
> ebin/$(PROJECT).app: src/$(PROJECT).app.src
> 	sed 's/{modules, \[\]}/{modules, \[$(MODULES)\]}/' $< > $@
>
> app: deps/ranch ebin/$(PROJECT).app
> 	@$(MAKE) -C $(DEPS_DIR)/ranch

I'm using the ebin/$(PROJECT).app rule to compile only the modified .erl 
files, and the ebin/$(PROJECT).app needs to be compiled everytime for 
that to work properly, not just when .app.src is modified.

Thanks for the interesting tips!

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the erlang-questions mailing list