我目前正在使用
c(module_name)
一一构建我的 Erlang 文件。当 Erlang 的构建过程有多个文件时,如何处理?
每个人可能都应该使用 Erlang 的官方构建工具:rebar3。当我提供这个旧答案时它并不存在:
我首先使用 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
Erlang Make 和 Emakefiles 可能是一个很好的起点。
作为示例,您可能想查看 Erlang Web 的构建系统。
具体而言,您可能想查看他们的 Emakefile 和他们的 compile.erl。
您可以使用“rebar”,Basho 的一款符合 OTP 标准的 Erlang 构建工具:它将多个 erlang 应用程序设置为一致的目录结构,并允许您执行更多操作,而不仅仅是将文件编译为 .beams。 [钢筋编译]
例如,您可以
* 运行测试(eUnit + 功能/回归)[钢筋测试]
- 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 -c”将为您提供完整的图片。
rebar 来自 Basho,有各种变体,:-)
您可以在这里获取钢筋
wiki 说明了一切。