Mochiweb: Include and compile other libraries
Asked Answered
C

2

-1

My app uses Mochiweb.

I have noticed that Mochiweb files reside in the myapp/deps/mochiweb directory and rebar compiles them when I run make in the myapp directory.

I wanted to add ibrowse to write a few tests which make http requests to my app. So I cloned ibrowse from github to myapp/deps/ibrowse directory.

But it seems that Erlang does not know where to get the .beam files for ibrowse and therefore all my tests that use the ibrowse module fail:

myapp
 ebin %%compiled tests reside here, tests which use ibrowse fail (badarg)
 deps
  mochiweb 
  ibrowse
   ebin %%compiled ibrowse module resides here
 src
 tests

How can I make my Mochiweb-based app use other Erlang/OTP external libraries?

Should I edit rebar.config or Makefile for that? Or maybe I should edit an _app.src file?

Edit: Maybe I should edit the list of directories in the myapp_sup.erl file? (myapp_deps:local_path(["priv", "www"])

P.S. How does my app know where all the mochiweb.beam files reside? (for example, the generic myapp_web.erl uses a call to mochiweb_http module, but there is no mochiweb_http.beam in the myapp/ebin directory).

Counterword answered 17/5, 2012 at 15:48 Comment(0)
C
0

Adding the following code to myapp_web.erl solved my problem:

ibrowse:start()

By default Mochiweb is started in the same function:

mochiweb_http:start()...

I am not sure if it the proper way to do this, but it works.

Counterword answered 18/5, 2012 at 23:36 Comment(0)
N
0

Dependencies in rebar are added via the rebar.config file:

%% What dependencies we have, dependencies can be of 3 forms, an application
%% name as an atom, eg. mochiweb, a name and a version (from the .app file), or
%% an application name, a version and the SCM details on how to fetch it (SCM
%% type, location and revision). Rebar currently supports git, hg, bzr and svn.
{deps, [application_name,
        {application_name, "1.0.*"},
        {application_name, "1.0.*",
         {git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}.

Then, you probably want to look at Erlang releases and release handling with rebar. Think to a release as a way of grouping applications.

http://www.erlang.org/doc/design_principles/release_handling.html

http://learnyousomeerlang.com/release-is-the-word

https://github.com/basho/rebar/wiki/Release-handling

Near answered 18/5, 2012 at 6:58 Comment(0)
C
0

Adding the following code to myapp_web.erl solved my problem:

ibrowse:start()

By default Mochiweb is started in the same function:

mochiweb_http:start()...

I am not sure if it the proper way to do this, but it works.

Counterword answered 18/5, 2012 at 23:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.