Skip to content

Commit

Permalink
Boilerplate
Browse files Browse the repository at this point in the history
git-svn-id: http://dev.brendonh.org/svn/veracity/trunk@2 9d18217e-6996-4b5f-b398-a6959e6ab315
  • Loading branch information
brendonh committed Dec 25, 2008
1 parent f8b7332 commit 47817be
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 0 deletions.
63 changes: 63 additions & 0 deletions veracity/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
PKG_NAME = veracity
PKG_PREFIX = veracity

SRC_DIR = src
EBIN_DIR = ebin
INCLUDE_DIR = include
TESTS_DIR = tests

SOURCES = $(wildcard $(SRC_DIR)/*.erl)
TESTS = $(wildcard $(TESTS_DIR)/*.erl)
INCLUDES = $(wildcard $(INCLUDE_DIR)/*.hrl)
TARGETS = $(patsubst $(SRC_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES))

ERLC_INCLUDES = -I $(INCLUDE_DIR)
ERLC_EBINS = $(EBIN_DIR)

ERLC = erlc
ERLC_OPTS = $(ERLC_INCLUDES) -o $(EBIN_DIR) -Wall -v +debug_info

ERLC_ASN_OPTS = -bber_bin +optimize +compact_bit_string -Wall -v +debug_info
ERLC_ASN = $(ERLC) $(ERLC_ASN_OPTS)

REL_VSN=1
RELEASE_NAME=$(PKG_NAME)-$(REL_VSN)

ERL_CMD=erl \
-boot start_sasl \
-config $(PKG_NAME) \
+W w \
-pa $(ERLC_EBINS)

all: $(TARGETS)

run_prereqs: all

$(RELEASE_NAME).boot: $(RELEASE_NAME).rel
env ERL_LIBS=.. erl -s systools make_script $(RELEASE_NAME) local -s init stop

run: run_prereqs
$(ERL_CMD) -sname $(PKG_NAME) -s $(PKG_PREFIX)_app

daemon: run_prereqs
$(ERL_CMD) -detached -sname $(PKG_NAME) -s $(PKG_PREFIX)_app >> $(PKG_NAME).log 2>&1

boot: run_prereqs $(RELEASE_NAME).boot
erl -pa ebin -boot $(RELEASE_NAME) -config $(PKG_NAME)

release: $(RELEASE_NAME).rel
env ERL_LIBS=.. erl -s systools make_script $(RELEASE_NAME) -s init stop

stop:
erl_call -a '$(PKG_NAME)_app stop_and_halt []' -sname $(PKG_NAME)

clean: cleanlog
rm -f $(TARGETS)
rm -f $(EBIN_DIR)/*.beam
rm -f $(RELEASE_NAME).boot $(RELEASE_NAME).script

cleanlog:
rm -f $(PKG_NAME).log auth.log report.log sasl_err.log erl_crash.dump

$(EBIN_DIR)/%.beam: $(SRC_DIR)/%.erl $(INCLUDES)
$(ERLC) $(ERLC_OPTS) $<
11 changes: 11 additions & 0 deletions veracity/ebin/veracity.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{application, veracity,
[{description, "Veracity"},
{id, "Veracity"},
{vsn, "0.0.1"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib]},
{mod, {veracity_app, []}},
{env, []}
]}.

34 changes: 34 additions & 0 deletions veracity/src/veracity_app.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%%%-------------------------------------------------------------------
%%% File : veracity_app.erl
%%% Author : Brendon Hogger <brendonh@lightblue>
%%% Description : IRC!
%%%
%%% Created : 25 Dec 2008 by Brendon Hogger <brendonh@lightblue>
%%%-------------------------------------------------------------------
-module(veracity_app).

-behaviour(application).

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

%% API
-export([start/0]).


%%====================================================================
%% Application callbacks
%%====================================================================
start(_Type, StartArgs) ->
veracity_sup:start_link(StartArgs).

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

stop(_State) ->
ok.


%%====================================================================
%% Internal functions
%%====================================================================
36 changes: 36 additions & 0 deletions veracity/src/veracity_sup.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%%%-------------------------------------------------------------------
%%% File : veracity_sup.erl
%%% Author : Brendon Hogger <brendonh@lightblue>
%%% Description :
%%%
%%% Created : 25 Dec 2008 by Brendon Hogger <brendonh@lightblue>
%%%-------------------------------------------------------------------
-module(veracity_sup).

-behaviour(supervisor).

%% API
-export([start_link/1]).

%% Supervisor callbacks
-export([init/1]).

-define(SERVER, ?MODULE).

%%====================================================================
%% API functions
%%====================================================================
start_link(Args) ->
supervisor:start_link({local, ?SERVER}, ?MODULE, Args).


%%====================================================================
%% Supervisor callbacks
%%====================================================================
init(_Args) ->
{ok,{{one_for_one,0,1}, []}}.


%%====================================================================
%% Internal functions
%%====================================================================
5 changes: 5 additions & 0 deletions veracity/veracity.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{sasl, [
{sasl_error_logger, {file, "sasl_err.log"}}
]}
].

0 comments on commit 47817be

Please sign in to comment.