我可以将包含目录添加到 erl 命令中吗?

发布于 2024-10-06 05:00:07 字数 504 浏览 3 评论 0原文

当使用 erlc 编译 erlang 文件时,我可以添加其他包含目录,如下所示:

erlc -I /home/trotter/code/open-source/yaws/include src/myapp.erl

但是,当我从 erl 内部编译时,我看不到这样做的方法在命令行上。相反,我必须在 repl 中执行以下操作:

> compile:file("src/myapp", 
               [verbose,
                report_errors,
                {i,"/home/trotter/code/open-source/yaws/include"}]).

是否有更好的方法来执行此操作,但我不知道,例如将一些命令行参数传递给 erl?如果没有,任何关于干燥这个问题的建议要求我每次编译时都输入讨厌的路径。

When compiling an erlang file with erlc I can add additional include directories like so:

erlc -I /home/trotter/code/open-source/yaws/include src/myapp.erl

When I'm compiling from within erl though, I don't see a way to do this on the command line. Instead, I have to do the following within the repl:

> compile:file("src/myapp", 
               [verbose,
                report_errors,
                {i,"/home/trotter/code/open-source/yaws/include"}]).

Is there a better way to do this that I don't know about, such as passing some command line argument to erl? If not, any suggestions for drying this up that don't require me to type nasty paths everytime I compile.

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

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

发布评论

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

评论(2

她说她爱他 2024-10-13 05:00:07

我很少从 shell 进行编译 - 仅适用于使用 c(foo) 的小型测试脚本。我的设置是这样的:

我有一个构建基础设施。 make 构建软件(make 只是这里 rebar 的包装器)。然后,我可以通过点击绑定到 compile emacs 命令的 F12emacs 中构建代码。在 vim 中,如果我没记错的话(已经有几年了),你可以使用 :make 命令做同样的事情。现在,这当然会构建代码并将其放入 ebin 目录中。

下一步是在了解 ebin 目录的情况下启动 Erlang:

 erl -pa ./ebin

这意味着对模块 foo 的任何引用都会检查 ./ebin/foo.beam。当我发现我必须修复一些代码时,我在编辑器中修复它,使用 F12 编译代码,然后在 shell 中执行 l(foo) -加载代码。

它还有一个优点,即任何编译错误现在都在编辑的管辖范围内,因此我可以快速跳转到错误并修复它。

I rarely compile from the shell - only for small test scripts with c(foo). My setup is this:

I have a build infrastructure. make builds the software (make is just a wrapper for rebar here). I can then build code from within emacs by hitting F12 bound to the compile emacs command. In vim you can do the same with the :make command if my vim memory serves me (it has been a couple of years). Now this of course builds the code and throw it into an ebin dir.

The next step is to start Erlang with knowledge about the ebin dir:

 erl -pa ./ebin

which means that any reference to module foo goes and checks for ./ebin/foo.beam. When I then figure out I have to fix some code, I fix it in the editor, compile the code with F12 and then execute l(foo) in the shell which hot-loads the code.

It also has the advantage that any compilation error is now under the jurisdiction of the editor so I can quickly jump to the error and fix it.

浊酒尽余欢 2024-10-13 05:00:07

您可以设置ERL_COMPILER_OPTIONS

请参阅http://www.erlang.org/doc/man/compile.html

you can set ERL_COMPILER_OPTIONS.

see http://www.erlang.org/doc/man/compile.html

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