1
votes

I've created an erlang application where I can use application:start(Name) to successfully start the application.

I tried to create a makefile step that uses rebar to compile, and then manually start the application. But it doesn't seem to work. Here's what I have now:

all: compile start

compile:
    ./rebar compile

start:
    erl -s application load shoutcast -s application start shoutcast

All this does is loads up an interactive erlang shell

2
The third argument of -s (shoutcast in this case) is sent as a list. So your code will call application:start([shoutcast]) which does not work. You could write a function that does this or perhaps look into creating a release.Burbas

2 Answers

2
votes
Aplication:start(Name)

calls

Name:start/2 

while the -s flag calls

Name:start() or Name:start([arg1, arg2, ...]).

So, I don't think you can successfully invoke Application in this way. Assuming you don't want to create a release and boot file, you could (I think) add a method to you application module, start/0

-module(shoutcast).

-behaviour(application).

%% Application callbacks
-export([start/2, stop/1]).

%% Allow for erl -s invocation 
-export([start/0]).

 ... Snip ...

start() ->
    application:start(shoutcast).

... Snip ...

Then within your makefile

erl -s shoutcast

I'm not sure if this violates a best practice, but it should work.

0
votes

It could be better to keep useful things in common Makefile https://github.com/virtan/erlang-makefile