summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2013-01-18 04:04:07 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2013-01-18 19:39:29 -0600
commit879596443b58dce0ab18b051745d6b5428c031e4 (patch)
tree4436f26bbdb9dab3509e7c25b0fb85a9a8f12e33
parent989a54666dc2112cb219dc0848b1de7e11dd08c4 (diff)
tb: size CCACHE_DIR when specified on a per profile or per branch
-rw-r--r--tb/tb_internals.sh49
1 files changed, 48 insertions, 1 deletions
diff --git a/tb/tb_internals.sh b/tb/tb_internals.sh
index ee24fe0..068d4d5 100644
--- a/tb/tb_internals.sh
+++ b/tb/tb_internals.sh
@@ -195,8 +195,21 @@ check_branch_profile_gerrit()
{
local b="$1"
+ # unset higher level CCACHE_DIR setting
+ unset CCACHE_DIR
+
source_branch_level_config "${b?}" "gerrit"
+ # if CCACHE_DIR is set it has been set by the branch's profile
+ # if TB_CCACHE_SIZE is set make sure the cache is as big as specified
+ # note: no need to restore the old CCACHE value
+ # since check_branches is run in a sub-shell
+ if [ -n "${CCACHE_DIR}" ] ; then
+ if [ -n "${TB_CCACHE_SIZE}" ] ; then
+ ccache -M "${TB_CCACHE_SIZE?}" > /dev/null
+ fi
+ fi
+
# if we did not die yet... we are good for this branch: print it
echo "${b?}"
@@ -211,6 +224,9 @@ check_branch_profile_tb()
local b="$1"
local sha=
+ # unset higher level CCACHE_DIR setting
+ unset CCACHE_DIR
+
source_branch_level_config "${b?}" "tb"
if [ -z "${TB_TINDERBOX_BRANCH}" ; then
@@ -233,6 +249,16 @@ check_branch_profile_tb()
fi
fi
+ # if CCACHE_DIR is set it has been set by the branch's profile
+ # if TB_CCACHE_SIZE is set make sure the cache is as big as specified
+ # note: no need to restore the old CCACHE value
+ # since check_branches is run in a sub-shell
+ if [ -n "${CCACHE_DIR}" ] ; then
+ if [ -n "${TB_CCACHE_SIZE}" ] ; then
+ ccache -M "${TB_CCACHE_SIZE?}" > /dev/null
+ fi
+ fi
+
# if we did not die yet... we are good for this branch: print it
echo "${b?}"
}
@@ -544,7 +570,7 @@ load_profile()
local p=$1
local rc=0
local config_file=
-
+ local old_ccache_dir=
if [ -z "$p" ] ; then
die "A profile is needed to run: use -p or configure one"
@@ -553,6 +579,12 @@ load_profile()
if [ ! -d "${tb_PROFILE_DIR}" ] ; then
die "You need to configure the profile ${p} to use it"
fi
+
+ #save the current CCACHE_DIR setting
+ if [ -n "${CCACHE_DIR}" ] ; then
+ old_ccache_dir="${CCACHE_DIR?}"
+ unset CCACHE_DIR
+ fi
config_file="${tb_PROFILE_DIR?}/config"
if [ -f "${config_file?}" ] ; then
source "${config_file?}"
@@ -565,6 +597,21 @@ load_profile()
if [ -f "${tb_PROFILE_DIR?}/phases.sh" ] ; then
source "${tb_PROFILE_DIR?}/phases.sh"
fi
+
+ # if we have a CCACHE_DIR here, it has been set by
+ # the profile. if we also haev a TB_CCACHE_SIZE
+ # make sure the cache is as big as indicated
+ # if CCACHE_DIR is not set, restaure the potential
+ # previous value
+ if [ -n "${CCACHE_DIR}" ] ; then
+ if [ -n "${TB_CCACHE_SIZE}" ] ; then
+ ccache -M "${TB_CCACHE_SIZE?}" > /dev/null
+ fi
+ else
+ if [ -n "${old_ccache_dir}" ] ; then
+ CCACHE="${old_ccache_dir?}"
+ fi
+ fi
fi
}