开发者

Building multiple Erlang Beam files?

开发者 https://www.devze.com 2022-12-24 23:40 出处:网络
开发者_如何学运维I am currently using c(module_name) to build my Erlang files one by one. How can the build process for Erlang be handle when they have multiple files?I start out by using Erlang ma

开发者_如何学运维I am currently using

c(module_name)

to build my Erlang files one by one. How can the build process for Erlang be handle when they have multiple files?


I start out by using Erlang make, because it starts the VM once and compiles everything that needs to be recompiled.

Try the following in your source directory, it will compile those .erl files that are missing a corresponding Beam file or those where the .erl file has been modified since the Beam file was compiled:

erl -make

Learn about Emakefile for additional tricks, such as compiling all source files with debug_info and placing the .beam files in ebin:

{'*',
    [{outdir,"../ebin"},
    debug_info]}.


This compiles everything in the directory you're currently in:

cover:compile_directory().


a lot of projects use a regular old make file and erlc

erlc -h
Usage:  erlc [options] file.ext ...
Options:
-b type        type of output file (e.g. jam or beam)
-d             turn on debugging of erlc itself
-Dname         define name
-Dname=value   define name to have value
-hybrid        compile using hybrid-heap emulator
-help          shows this help text
-I path        where to search for include files
-o name        name output directory or file
-pa path       add path to the front of Erlang's code path
-pz path       add path to the end of Erlang's code path
-smp           compile using SMP emulator
-v             verbose compiler output
-Werror        make all warnings into errors
-W0            disable warnings
-Wnumber       set warning level to number
-Wall          enable all warnings
-W             enable warnings (default; same as -W1)
-E             generate listing of expanded code (Erlang compiler)
-S             generate assembly listing (Erlang compiler)
-P             generate listing of preprocessed code (Erlang compiler)
+term          pass the Erlang term unchanged to the compiler


You can use 'rebar', an Erlang build tool from Basho that is OTP compliant: this sets up multiple erlang applications into a consistent directory structure and allows you to do more than just compile files into .beams. [rebar compile]

For instance, you can
* run tests (eUnit + feature/regression) [rebar test]

 - build releases [rebar rel]
 - start ci-builds 
 - specify dependencies from multiple sources in its config file
 - enable SNMPwalks through data collected by SNMP agents of various types
 - (in conjunction with xref and grapherl) generate call graphs of entire applications
 - (in conjunction with fprof and fprof_graph) generate profiling diagrams
 - run dialyzer to do static code analysis 

To see all rebar commands, 'rebar -c' will give you a complete picture.

rebar is from Basho with variants floating around, :-)

You can get rebar here

The wiki says it all.


Erlang Make and Emakefiles are probably a good way to start.

As an example, you might want to have a look to the build system of Erlang Web.

In the specific, you might want to look at their Emakefile and their compile.erl.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号