我可以将包含目录添加到 erl 命令中吗?
当使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很少从 shell 进行编译 - 仅适用于使用
c(foo)
的小型测试脚本。我的设置是这样的:我有一个构建基础设施。
make
构建软件(make 只是这里rebar
的包装器)。然后,我可以通过点击绑定到compile
emacs 命令的F12
在emacs
中构建代码。在vim
中,如果我没记错的话(已经有几年了),你可以使用:make
命令做同样的事情。现在,这当然会构建代码并将其放入ebin
目录中。下一步是在了解
ebin
目录的情况下启动 Erlang:这意味着对模块
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 forrebar
here). I can then build code from withinemacs
by hittingF12
bound to thecompile
emacs command. Invim
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 anebin
dir.The next step is to start Erlang with knowledge about the
ebin
dir: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 withF12
and then executel(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.
您可以设置
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