diff options
-rw-r--r-- | tb/tb_internals.sh | 49 |
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 } |