【发布时间】:2013-02-09 09:28:13
【问题描述】:
我正在使用
c(module_name)
一个一个地构建我的 Erlang 文件。当 Erlang 有多个文件时,如何处理它们的构建过程?
【问题讨论】:
标签: erlang
我正在使用
c(module_name)
一个一个地构建我的 Erlang 文件。当 Erlang 有多个文件时,如何处理它们的构建过程?
【问题讨论】:
标签: erlang
我首先使用Erlang make,因为它会启动一次虚拟机并编译所有需要重新编译的内容。
在您的源目录中尝试以下操作,它将编译那些缺少相应 Beam 文件的 .erl 文件或自 Beam 文件编译后 .erl 文件已被修改的那些:
erl -make
了解 Emakefile 以获得更多技巧,例如使用 debug_info 编译所有源文件并将 .beam 文件放入 ebin:
{'*',
[{outdir,"../ebin"},
debug_info]}.
【讨论】:
这会编译您当前所在目录中的所有内容:
cover:compile_directory().
【讨论】:
很多项目使用常规的旧 make 文件和 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
【讨论】:
您可以使用“rebar”,这是来自 Basho 的符合 OTP 的 Erlang 构建工具:它将多个 erlang 应用程序设置到一致的目录结构中,并且允许您做的不仅仅是将文件编译成 .beams。 [钢筋编译]
例如,您可以
* 运行测试(eUnit + 特征/回归)[rebar 测试]
- 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
要查看所有 rebar 命令,“rebar -c”将为您提供完整的图片。
rebar 来自 Basho,有各种变体,:-)
你可以得到钢筋here
wiki 说明了一切。
【讨论】:
Erlang Make and Emakefiles 可能是一个不错的起点。
例如,您可能想看看Erlang Web 的构建系统。
具体来说,你可能想看看他们的Emakefile 和他们的compile.erl。
【讨论】: