Updated buildRT to make out-of-source builds

This commit is contained in:
DrSlony
2012-06-26 19:58:06 +01:00
parent 93dc63f542
commit da30c71152

View File

@@ -58,15 +58,19 @@ compile () {
read _ _ branch _ buildType < <( echo ${list[$choiceNumber]} )
echo
printf "%-15b %b\n" "About to compile:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" "" ""
rev="`hg parents --template {rev}`"
[[ -d "${repo}/${buildType}" ]] && { printf "%s\n" "Found old build directory \"$buildType\" in your repository. Removing it."; rm -rf "${repo}/${buildType}"; }
[[ -d "${repo}/rawtherapee" ]] && { printf "%s\n" "Found old build directory \"rawtherapee\" in your repository. Removing it."; rm -rf "${repo}/rawtherapee"; }
# Clean up leftovers from previous successful and failed builds
[[ -d "${repo}/${buildType}" ]] && { printf "%s\n" "Found old build directory \"${repo}/$buildType\". Removing it."; rm -rf "${repo}/${buildType}"; }
[[ -d "${repo}/rawtherapee" ]] && { printf "%s\n" "Found old build directory \"${repo}/rawtherapee\". Removing it."; rm -rf "${repo}/rawtherapee"; }
[[ -d "${repo}/build" ]] && { printf "%s\n" "Found old build directory \"${repo}/build\". Removing it."; rm -rf "${repo}/build"; }
[[ -d "${HOME}/rt_${branch}_${buildType}" ]] && {
printf "%s\n" "Found old build directory ${HOME}/rt_${branch}_${buildType}" "It must be removed to proceed."
read -p "Do you want to remove it and proceed? y/n: " YN
[[ "$YN" = y ]] && rm -rf "${HOME}/rt_${branch}_${buildType}" || exit 1
}
# Clean up old CMake junk
cd "$repo" || exit 1
echo
printf "%s\n" "Cleaning out old CMake files"
@@ -91,30 +95,49 @@ compile () {
verLatesttagdistance="`hg parents --template '{latesttagdistance}'`"
verMajor=${verLatesttag%%.*}
cmake -DCMAKE_BUILD_TYPE="$buildType" -DPROC_TARGET_NUMBER="$procTarget" -DCMAKE_C_FLAGS="-pipe" -DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS" "$noomp" -DCMAKE_INSTALL_PREFIX="rawtherapee" -DBUILD_BUNDLE="ON" -DBINDIR="." -DDATADIR="." -DCACHE_NAME_SUFFIX="$verMajor" || { echo "Error during cmake, exiting." >&2; exit 1; }
mkdir "${repo}/build" || exit 1
# As of changeset 1930:067e362c6f28 on Mon Jun 25 2012, revision number 1930, RT supports and encourages out-of-source builds.
if ((${rev} < 1930 )); then
cmake -DCMAKE_BUILD_TYPE="$buildType" -DPROC_TARGET_NUMBER="$procTarget" -DCMAKE_C_FLAGS="-pipe" -DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS" "$noomp" -DCMAKE_INSTALL_PREFIX="build" -DBUILD_BUNDLE="ON" -DBINDIR="." -DDATADIR="." -DCACHE_NAME_SUFFIX="$verMajor" || { echo "Error during cmake, exiting." >&2; exit 1; }
else
cd "${repo}/build" || exit 1
cmake -DCMAKE_BUILD_TYPE="$buildType" -DPROC_TARGET_NUMBER="$procTarget" -DCMAKE_C_FLAGS="-pipe" -DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS" "$noomp" -DCMAKE_INSTALL_PREFIX="build" -DBUILD_BUNDLE="ON" -DBINDIR="." -DDATADIR="." -DCACHE_NAME_SUFFIX="$verMajor" ../ || { echo "Error during cmake, exiting." >&2; exit 1; }
fi
time { make -j${cpuCount} install; } || { printf "%s\n" "" "Error during make, exiting."; exit 1; }
printf "%-15b %b\n" "" "" "Rawtherapee compiled:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" "" ""
# RT used to build into various places over the years.
# We want to end up with the build in a folder called "<repo>/build/rawtherapee" regardless of which old version you compile, and then to zip it, so we move dirs around:
if ((${rev} < 1930 )); then
if [[ -d "${repo}/${buildType}" ]]; then
printf "%s\n" "Moving \"${repo}/${buildType}\" to \"${repo}/rawtherapee\""
mv "${repo}/${buildType}" "${repo}/rawtherapee"
elif [[ ! -d "${repo}/rawtherapee" ]]; then
{ printf "%s\n" "Could not find the directory containing the compiled RawTherapee in ${repo}" "Please notify DrSlony in the forum:" "http://rawtherapee.com/forum/viewtopic.php?f=10&t=3001#p22213" "" "Exiting"; exit 1; }
printf "%s\n" "Moving \"${repo}/${buildType}\" to \"${repo}/build/rawtherapee\""
mv "${repo}/${buildType}" "${repo}/build/rawtherapee"
elif [[ -d "${repo}/rawtherapee" ]]; then
printf "%s\n" "Moving \"${repo}/rawtherapee\" to \"${repo}/build/rawtherapee\""
mv "${repo}/rawtherapee" "${repo}/build/rawtherapee"
elif [[ ! -d "${repo}/build" ]]; then
{ printf "%s\n" "Could not find the \"build\" directory containing the compiled RawTherapee in ${repo}" "Please notify DrSlony in the forum:" "http://rawtherapee.com/forum/viewtopic.php?f=10&t=3001#p22213" "" "Exiting"; exit 1; }
fi
elif [[ -d "${repo}/build/${buildType}" ]]; then
printf "%s\n" "Moving \"${repo}/build/${buildType}\" to \"${repo}/build/rawtherapee\""
mv "${repo}/build/${buildType}" "${repo}/build/rawtherapee"
fi
echo
cat AboutThisBuild.txt || { printf "%s\n" "${repo}/AboutThisBuild.txt not found, exiting."; exit 1; }
# AboutThisBuild.txt has a blank line at the end - 4.0.7
cd "${repo}/build"
# not sure if ${repo}/build/AboutThisBuild.txt is the same as ${repo}/build/rawtherapee/AboutThisBuild.txt
cat AboutThisBuild.txt || { printf "%s\n" "${repo}/build/AboutThisBuild.txt not found, exiting."; exit 1; }
if [[ ! $patched = b ]]; then
printf "%s\n" "Zipping the compiled RawTherapee dir \"${repo}/rawtherapee\" and putting it in \"/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip\""
printf "%s\n" "Zipping the compiled RawTherapee dir \"${repo}/build/rawtherapee\" and putting it in \"/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip\""
[[ -e "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" ]] && { rm "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" || exit 1; }
zip -Xrq "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" AboutThisBuild.txt rawtherapee
fi
printf "%s\n" "" "Moving \"${repo}/rawtherapee\" to \"${HOME}/rt_${branch}_${buildType}\""
mv "${repo}/rawtherapee" "${HOME}/rt_${branch}_${buildType}" || { printf "%s\n" "" "Could not move \"${repo}/rawtherapee\" to \"${HOME}/rt_${branch}_${buildType}\", exiting."; exit 1; }
# Now that the zip is ready, the build can be moved to ~/rt_<branch>_<buildType>
printf "%s\n" "" "Moving \"${repo}/build/rawtherapee\" to \"${HOME}/rt_${branch}_${buildType}\""
mv "${repo}/build/rawtherapee" "${HOME}/rt_${branch}_${buildType}" || { printf "%s\n" "" "Could not move \"${repo}/build/rawtherapee\" to \"${HOME}/rt_${branch}_${buildType}\", exiting."; exit 1; }
printf "%-15b %b\n" "" "" "Build ready:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget"
printf "%s\n" "" "To run RawTherapee, fire up a terminal and type:" "~/rt_${branch}_${buildType}/rawtherapee" "" "------------------------------------------"