The "merging" of external libraries in Erlang?

I have an erlang application that I am writing that uses the erldis library to communicate with redis.

Being a little new to actually deploying erlang applications for production, I wanted to know if I needed to “link” these external libraries with the application, and not install / usr / lib / erlang / lib / on my system.

Currently, my directory structure looks like ...

\
--\conf
--\ebin
--\src

I have a main Makefile that I stole from a friends project, but I'm not sure how to write them correctly.

I suspect that this answer may include a story about how to write the Makefile correctly, and not just the directory into which the code of the external library is laid out.

+3
source share
5 answers

I use motibel-inspired style. To see an example, get your copy of mochiweb:

svn checkout http://mochiweb.googlecode.com/svn/trunk/ mochiweb

and use

path/to/mochiweb/scripts/new_mochiweb.erl new_project_name

create a sample structure project (feel free to delete everything inside src afterwards and use it for your project).

It looks like this:

/
/ebin/
/deps/
/src/
/include/
/support/
/support/include.mk
Makefile
start.sh
  • ebin contains * .beam files
  • src contains ***. erl files and local * .hrl files
  • include contains global * .hrl files
  • deps contains symlinks to dependency root directories

Makefile and include.mk takes care of including the appropriate paths when building the project.

start.sh takes care of including the appropriate paths when starting the project.

, symlinks deps, , . , rsync .

:

~/code/erlang/libs/*/
~/code/category/project/*/
~/code/category/project/*/deps/*/

~/code/erlang/libs/ .

+3

, . - , / Erlang.

, . , , dev, elibs, ERL_LIBS.

~/dev/ngerakines-etap
~/dev/jacobvorreuter-log_roller
~/dev/elib/etap -> ~/dev/ngerakines-etap
~/dev/elib/log_roller -> ~/dev/jacobvorreuter-log_roller

package-rpm, package-apt , . init.d /, .

+4

- erldir , script -pa runtime erlang, , .

( , OTP) reltool (http://www.erlang.org/doc/man/reltool.html) systools (http://www.erlang.org/doc/man/systools.html), , erldis.

+1

, , , , ERL_LIBS. unix dos.

Erlang "ebin" .

*.app , .

.

+1
source

Another way is the lib path in ~ / .erlang.

code:add_pathz("/Users/brucexin/sources/mochiweb/ebin").
code:add_pathz("/Users/brucexin/sources/webnesia/ebin").
code:add_pathz("./ebin").
code:add_pathz("/Users/brucexin/sources/erlang-history/ebin/2.15.2").
0
source

Source: https://habr.com/ru/post/1723749/


All Articles