From 7b8d7f5870e164b1e36987a22b36ff730baa8341 Mon Sep 17 00:00:00 2001 From: Jan Vincent Liwanag Date: Mon, 30 Jul 2012 21:01:25 +0800 Subject: [PATCH] Use apps directory for the apps Create a temporary apps directory for the OpenACD and include_apps for lib_dir --- .gitignore | 3 +- hooks.sh | 42 ++++++++++++----------- include_apps/oacd_dummy/rebar.config | 2 +- include_apps/oacd_freeswitch/rebar.config | 3 +- rebar.config | 5 +-- rel/reltool.config | 2 +- 6 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 2e641dfb..2e113efd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ ebin OpenACD/ include/commit_ver.hrl +apps/* include_apps/**/doc # unique config files @@ -65,4 +66,4 @@ install-sh missing #editor swap files -*~ \ No newline at end of file +*~ diff --git a/hooks.sh b/hooks.sh index 0d9e4b90..f601d84d 100755 --- a/hooks.sh +++ b/hooks.sh @@ -12,11 +12,11 @@ function pre_compile { # record what commit/version openacd is at OPENACD_COMMIT="" - if [ -d ".git" ] + if [ -d "$BASEDIR/.git" ] then OPENACD_COMMIT=`git log -1 --pretty=format:%H` fi - if [ -e "include/commit_ver.hrl" ] && [ ! $OPENACD_COMMIT ] + if [ -e "$BASEDIR/include/commit_ver.hrl" ] && [ ! $OPENACD_COMMIT ] then exit 0 else @@ -30,7 +30,7 @@ function pre_compile { echo "%% automatically generated by OpenACD precompile script. Editing means %% it will just get overwritten again. --define(OPENACD_COMMIT, $OPENACD_COMMIT)." > include/commit_ver.hrl +-define(OPENACD_COMMIT, $OPENACD_COMMIT)." > "$BASEDIR"/include/commit_ver.hrl } function pre_get-deps { @@ -42,21 +42,29 @@ function pre_get-deps { fi } -function pre_generate { - # hack for reltool - oaDir="$BASEDIR/OpenACD" - if [ ! -d "$oaDir" ]; then +function post_get-deps { + # needed by rebar to be added to lib path + mkdir -p "$BASEDIR/ebin" + + # create temp apps directory + appsDir="$BASEDIR/apps" + if [ ! -d "$appsDir" ]; then + mkdir -p "$appsDir" + ln -s "$BASEDIR"/include_apps/* "$appsDir" + + oaDir="$appsDir"/OpenACD mkdir "$oaDir" - ln -sf ../ebin "$oaDir"/ebin - ln -sf ../src "$oaDir"/src - ln -sf ../include "$oaDir"/include - ln -sf ../priv "$oaDir"/priv - ln -sf ../deps "$oaDir"/deps + ln -sf "$BASEDIR"/ebin "$oaDir"/ebin + ln -sf "$BASEDIR"/src "$oaDir"/src + ln -sf "$BASEDIR"/include "$oaDir"/include + ln -sf "$BASEDIR"/priv "$oaDir"/priv + ln -sf "$BASEDIR"/deps "$oaDir"/deps fi } -function post_generate { - rm -rf "$BASEDIR/OpenACD" +function post_clean { + appsDir="$BASEDIR/apps" + rm -Rf "$appsDir" } case "$1" in @@ -68,12 +76,6 @@ case "$1" in pre_compile;; "post_compile") post_compile;; - "pre_clean") - pre_clean;; "post_clean") post_clean;; - "pre_generate") - pre_generate;; - "post_generate") - post_generate;; esac diff --git a/include_apps/oacd_dummy/rebar.config b/include_apps/oacd_dummy/rebar.config index 6f6e20a7..5f236b8c 100644 --- a/include_apps/oacd_dummy/rebar.config +++ b/include_apps/oacd_dummy/rebar.config @@ -1,6 +1,6 @@ {erl_opts, [{src_dirs, ["contrib/"]}]}. -{lib_dirs, ["../.."]}. +{lib_dirs, ["../../apps"]}. {post_hooks, [{compile, "cat success_message"}]}. diff --git a/include_apps/oacd_freeswitch/rebar.config b/include_apps/oacd_freeswitch/rebar.config index f9c64c8a..b299883f 100644 --- a/include_apps/oacd_freeswitch/rebar.config +++ b/include_apps/oacd_freeswitch/rebar.config @@ -1,7 +1,6 @@ {erl_opts, [{src_dirs, ["contrib/"]}]}. -%{sub_dirs, ["rel"]}. -{lib_dirs, ["../..", "../../deps"]}. +{lib_dirs, ["../../apps", "../../deps"]}. {post_hooks, [{compile, "./hooks.sh post_compile"}]}. diff --git a/rebar.config b/rebar.config index b385c663..4d389a31 100644 --- a/rebar.config +++ b/rebar.config @@ -24,11 +24,12 @@ ]}. {pre_hooks, [ - {compile, "./hooks.sh pre_compile"}, {'get-deps', "./hooks.sh pre_get-deps"}, - {clean, "./hooks.sh pre_clean"} + {'compile', "./hooks.sh pre_compile"} ]}. {post_hooks, [ + {'get-deps', "./hooks.sh post_get-deps"}, + {clean, "./hooks.sh post_clean"} ]}. {cover_enabled, true}. diff --git a/rel/reltool.config b/rel/reltool.config index 5d19fe1a..840f74e5 100644 --- a/rel/reltool.config +++ b/rel/reltool.config @@ -1,5 +1,5 @@ {sys, [ - {lib_dirs, ["../deps", "..", "../include_apps"]}, + {lib_dirs, ["../deps", "../apps"]}, {rel, "openacd", "1", [ kernel,