构建多个 Erlang Beam 文件?

发布于 2024-08-27 08:04:39 字数 106 浏览 3 评论 0原文

我目前正在使用

c(module_name)

一一构建我的 Erlang 文件。当 Erlang 的构建过程有多个文件时如何处理?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

辞取 2024-09-03 08:04:39

每个人可能都应该使用 Erlang 的官方构建工具:rebar3。当我提供这个较旧的答案时,它并不存在:

我首先使用 Erlang make,因为它启动VM一次并编译所有需要重新编译的内容。

在源目录中尝试以下操作,它将编译那些缺少相应 Beam 文件的 .erl 文件,或者自编译 Beam 文件以来 .erl 文件已被修改的文件:

erl -make

了解 Emakefile 以获取其他技巧,例如编译所有文件带有 debug_info 的源文件并将 .beam 文件放入 ebin 中:

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

Everyone should probably be using the official build tool for Erlang: rebar3. It did not exist when I provided this older answer:

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]}.
清风夜微凉 2024-09-03 08:04:39

这会编译您当前所在目录中的所有内容:

cover:compile_directory().

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

cover:compile_directory().
作妖 2024-09-03 08:04:39

许多项目使用常规的旧 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

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
坦然微笑 2024-09-03 08:04:39

Erlang Make 和 Emakefiles 可能是一个很好的起点。

例如,您可能想查看 Erlang Web 的构建系统。

具体来说,您可能需要查看他们的 Emakefile 及其compile.erl

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.

岛徒 2024-09-03 08:04:39

您可以使用“rebar”,这是 Basho 提供的一个符合 OTP 标准的 Erlang 构建工具:它将多个 erlang 应用程序设置为一致的目录结构,并且允许您执行的操作不仅仅是将文件编译为 .beams。 [rebar 编译]

例如,您可以
* 运行测试(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”将为您提供完整的图片。

钢筋来自 Basho,其变体四处浮动,:- )

您可以这里获取rebar

wiki 说明了一切。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文