makefileerlangerlang-otpmochiwebrebar

Mochiweb: Include and compile other libraries


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).


Solution

  • 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.