SCons builder for erlang

Héctor Rivas Gándara keymon@REDACTED
Tue May 17 13:17:13 CEST 2005


Hi,

I send the definition of a SCons[1] builder for Erlang beams. SCons its 
a great tool for project building and a good replacement for make:

-- 8< ------ 8< ---  <file:SConstruct> --- 8< ------ 8< ------
import os
env = Environment(ENV = os.environ)

#######################################################################
# Erlang Builder
#ERLANG_BIN = ""
#ERLC = os.path.join(ERLANG_BIN, 'erlc')
ERLC = 'erlc'

beam_builder = Builder(
	generator =
		lambda source, target, env, for_signature:
			ERLC +
			# Append include entries
			reduce(lambda acum, path: acum+' -I'+str(path),
				[""] + env.get('ERLINCLUDE', [])) +
			# Append path entries
			reduce(lambda acum, path: acum+' -pa'+str(path),
				[""] + env.get('ERLPATH', [])) +
			' -o $TARGET $SOURCES' ,
   	    suffix = '.beam',
           src_suffix = '.erl')

env.Append(BUILDERS = {'Beam': beam_builder})

#######################################################################
# Example use
env.Append(ERLINCLUDE = [Dir("."), Dir("./subsystem")])
env.Append(ERLPATH = [Dir("/path/to/any/library"), 
Dir("/path/to/other/library")])

erlang_sources = Split("""
	asource.erl othersource.erl
	""")

beams = []

for erlang_source in erlang_sources:
	beam = env.Beam(erlang_source)
	beams.append(beam)

DIST_BEANS="./dist/bin"

install_beans = Install(DIST_BEANS, beams)
Alias('install', install_beans)
-- 8< ------ 8< ---  </file:SConstruct> --- 8< ------ 8< ------

--
[1] http://www.scons.org
--
Saudos
Keymon




More information about the erlang-questions mailing list