Can I add include directories to the erl command?
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 argu开发者_如何学运维ment to erl? If not, any suggestions for drying this up that don't require me to type nasty paths everytime I compile.
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.
you can set ERL_COMPILER_OPTIONS
.
see http://www.erlang.org/doc/man/compile.html
精彩评论