buildRT: Added -s option to define a suffix of the destination build dir, and -t to add a suffix to the version string which is shown in the window titlebar (issue 2274)

This commit is contained in:
DrSlony
2014-03-06 14:03:35 +01:00
parent 5d91a8850b
commit d5d51626a5

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Written by DrSlony # Written by DrSlony
# buildRT version 3.8, 2014-01-23 # buildRT version 4.0, 2014-03-06
# Please report bugs or enhancements to http://code.google.com/p/rawtherapee/issues/list # Please report bugs or enhancements to http://code.google.com/p/rawtherapee/issues/list
# www.rawtherapee.com # www.rawtherapee.com
# www.londonlight.org # www.londonlight.org
@@ -25,56 +25,63 @@ esac
#--- Set some variables #--- Set some variables
unset choiceNumber choiceNumbers buildType buildTypes list branch branches repo unset choiceNumber choiceNumbers buildType buildTypes list branch branches repo
version="3.8" version="4.0"
movetoPatched="" movetoPatched=""
repo="${HOME}/rawtherapee" repo="${HOME}/rawtherapee"
procTarget=2 procTarget=2
while getopts "bc:np:uvh?-" opt; do while getopts "bc:np:s:t:uvh?-" opt; do
case "${opt}" in case "${opt}" in
b) patched="yes" b) patched="yes"
movetoPatched="_patched" movetoPatched="_patched"
printf "%s\n" "Buildonly flag detected, will not hg pull or update" ;; printf "%s\n" "Buildonly flag detected, will not hg pull or update" ;;
c) dCacheNameSuffix="$OPTARG" c) dCacheNameSuffix="$OPTARG"
#sanitize dCacheNameSuffix=${dCacheNameSuffix//[^\.\-_a-zA-Z0-9]/};
dCacheNameSuffix=${dCacheNameSuffix//[^\.\-_a-zA-Z0-9]/}; printf "%s\n" "Cache and config name suffix: $dCacheNameSuffix" ;;
printf "%s\n" "Cache and config name suffix: $dCacheNameSuffix" ;; n) noomp="-DOPTION_OMP=OFF"
n) noomp="-DOPTION_OMP=OFF" printf "%s\n" "OpenMP disabled" ;;
printf "%s\n" "OpenMP disabled" ;; p) procTarget="$OPTARG"
p) procTarget="$OPTARG" if [[ $procTarget -lt 1 || $procTarget -gt 9 ]]; then
if [[ $procTarget -lt 1 || $procTarget -gt 9 ]]; then printf "%s\n" "Invalid processor target value." "Use a value from 1 to 9, e.g." "./buildRT -p 1" "See ProcessorTargets.cmake" "Aborting"
printf "%s\n" "Invalid processor target value." "Use a value from 1 to 9, e.g." "./buildRT -p 1" "See ProcessorTargets.cmake" "Aborting" exit 1
exit 1 fi ;;
fi ;; s) movetoPatched="_${OPTARG//[^\.\-_a-zA-Z0-9]/}"
u) gcVer="$(curl "http://rawtherapee.googlecode.com/hg/tools/buildRT" 2>/dev/null | grep "^#.*[vV]ersion.*")" || { echo "\"curl\" program not found, please install it first."; exit 1; } printf "%s\n" "Suffix of destination build dir: ${movetoPatched}" ;;
gcVer="${gcVer##*[[:alpha:]] }" t) titleSuffix="${OPTARG//[^\.\-\ \+_a-zA-Z0-9]/}"
gcVer="${gcVer%%,*}" printf "%s\n" "Titlebar version suffix: ${titleSuffix}" ;;
latestVer="$(printf "%s\n" "$version" "$gcVer" | sort -rV | head -n 1)" u) gcVer="$(curl "http://rawtherapee.googlecode.com/hg/tools/buildRT" 2>/dev/null | grep "^#.*[vV]ersion.*")" || { echo "\"curl\" program not found, please install it first."; exit 1; }
if [[ $version = $latestVer ]]; then gcVer="${gcVer##*[[:alpha:]] }"
printf "%s\n" "You are using the latest version of buildRT, $version" gcVer="${gcVer%%,*}"
exit 0 latestVer="$(printf "%s\n" "$version" "$gcVer" | sort -rV | head -n 1)"
else if [[ $version = $latestVer ]]; then
printf "%s\n" "You are using version $version but version $gcVer is available on Google Code." "You can download the Google Code version from this URL:" " https://rawtherapee.googlecode.com/hg/tools/buildRT" "Replace it with this script, and remember to run \"chmod +x buildRT\"" printf "%s\n" "You are using the latest version of buildRT, $version"
exit 0 exit 0
fi ;; else
v) verbose=yes printf "%s\n" "You are using version $version but version $gcVer is available on Google Code." "You can download the Google Code version from this URL:" " https://rawtherapee.googlecode.com/hg/tools/buildRT" "Replace it with this script, and remember to run \"chmod +x buildRT\""
printf "%s\n" "Verbose mode, I will spam your screen with warnings" ;; exit 0
h|\?|-) printf "%s\n" "Usage:" "" \ fi ;;
" $0 [-b] [-c <string>] [-n] [-p <1-9>] [-v]" "" \ v) verbose=yes
" -b" \ printf "%s\n" "Verbose mode, I will spam your screen with warnings" ;;
"Build-only mode. buildRT uses \"hg update -C default\" to update your source code repository to the newest revision, however doing so might destroy any uncommitted or unpushed changes you made or any patches you applied. With the -b flag the script will not update the source code, so that you can easily compile RawTherapee with whatever patches you manually applied. buildRT should automatically detect if you modified the source code, but you can use this flag to force build-only mode." "Generally when compiling patched RT versions you want to keep the cache and config folders separate, so consider using \"-b -c _testing\"" "" \ h|\?|-) printf "%s\n" "Usage:" "" \
" -c <string>" \ " $0 [-b] [-c <string>] [-n] [-p <1-9>] [-s <string>] [-v]" "" \
"Specify a suffix to the cache and config directory names. Only alphanumerics, periods, dashes and underscores are valid. The default value is \"4\", which will result in your build of RawTherapee storing the cache in \"${HOME}/.cache/RawTherapee4\" and config in \"${HOME}/.config/RawTherapee4\". For example, use \"-c _testing\" if you want to test older or patched versions of RawTherapee without potentially damaging your \"real\" cache and config files." "" \ " -b" \
" -n" \ "Build-only mode. buildRT uses \"hg update -C default\" to update your source code repository to the newest revision, however doing so might destroy any uncommitted or unpushed changes you made or any patches you applied. With the -b flag the script will not update the source code, so that you can easily compile RawTherapee with whatever patches you manually applied. buildRT should automatically detect if you modified the source code, but you can use this flag to force build-only mode." "Generally when compiling patched RT versions you want to keep the cache and config folders separate, so consider using \"-b -c _testing\"" "" \
"Disable OpenMP." "" \ " -c <string>" \
" -p <1-9>" \ "Specify a suffix to the cache and config directory names. Only alphanumerics, periods, dashes and underscores are valid. The default value is \"4\", which will result in your build of RawTherapee storing the cache in \"${HOME}/.cache/RawTherapee4\" and config in \"${HOME}/.config/RawTherapee4\". For example, use \"-c _testing\" if you want to test older or patched versions of RawTherapee without potentially damaging your \"real\" cache and config files." "" \
"Set which processor target to use. Takes a single digit from 1 to 9. The default is 2. See ProcessorTargets.cmake" "" \ " -n" \
" -u" \ "Disable OpenMP." "" \
"Check for an update of buildRT on Google Code." "" \ " -p <1-9>" \
" -v" \ "Set which processor target to use. Takes a single digit from 1 to 9. The default is 2. See ProcessorTargets.cmake" "" \
"Make compilation verbose, so you see all compiler warnings." | fold -s " -s <string>" \
exit 0 ;; "Suffix of destination build directory, so that if you have applied a patch, say \"dustremoval-1.patch\", and want to have RawTherapee compiled to a folder whose name ends with \"_dustremoval1\", you would set \"-s dustremoval1\" (the underscore is automated)." "" \
esac " -t <string>" \
"Suffix displayed next to the RawTherapee version in the window titlebar, e.g.: -t \"+ dustremoval-1.patch + mustafa ibrahim\"" "" \
" -u" \
"Check for an update of buildRT on Google Code." "" \
" -v" \
"Make compilation verbose, so you see all compiler warnings." | fold -s
exit 0 ;;
esac
done done
shift $((OPTIND-1)) shift $((OPTIND-1))
[ "$1" = "--" ] && shift [ "$1" = "--" ] && shift
@@ -201,13 +208,17 @@ elif [[ -z $patched ]]; then
echo ;; echo ;;
c|C) printf "%s\n" "Retaining edited source code and compiling RT as-is." "" c|C) printf "%s\n" "Retaining edited source code and compiling RT as-is." ""
patched="yes" patched="yes"
movetoPatched="_patched" ;; if [[ -z $movetoPatched ]]; then
movetoPatched="_patched"
fi ;;
*) printf "%s\n" "User aborted" "" *) printf "%s\n" "User aborted" ""
exit 0 ;; exit 0 ;;
esac esac
else else
printf "%s\n" "Retaining edited source code and compiling RT as-is." "" printf "%s\n" "Retaining edited source code and compiling RT as-is." ""
movetoPatched="_patched" if [[ -z $movetoPatched ]]; then
movetoPatched="_patched"
fi
fi fi
hg parents --template 'Repository state:\n Branch: {branch}\n RawTherapee-{latesttag}.{latesttagdistance}\n Changeset: {rev}:{node|short}\n Latest tag: {latesttag}\n\n' hg parents --template 'Repository state:\n Branch: {branch}\n RawTherapee-{latesttag}.{latesttagdistance}\n Changeset: {rev}:{node|short}\n Latest tag: {latesttag}\n\n'
@@ -272,9 +283,9 @@ for choiceNumber in "${choiceNumbers[@]}"; do
echo echo
case $REPLY in case $REPLY in
d|D) rm -rf "${HOME}/rt_${branch}_${buildType}${movetoPatched}" || exit 1 ;; d|D) rm -rf "${HOME}/rt_${branch}_${buildType}${movetoPatched}" || exit 1 ;;
r|R) printf "%s\n" "The build will be saved to \"${HOME}/rt_${branch}_${buildType}${movetoPatched}X\" where \"X\" will be replaced with whatever suffix you choose next. Only alphanumerics, dashes and underscores are valid." | fold -s r|R) printf "%s\n" "The build will be saved to \"${HOME}/rt_${branch}_${buildType}_X\" where \"X\" will be replaced with whatever suffix you choose next. Only alphanumerics, dashes, underscores and periods are valid." | fold -s
read -r -p "Suffix: " read -r -p "Suffix: "
movetoPatched="${REPLY//[^\.\-_a-zA-Z0-9]/}" movetoPatched="_${REPLY//[^\.\-_a-zA-Z0-9]/}"
printf "%s\n" "Build will be compiled to \"${HOME}/rt_${branch}_${buildType}${movetoPatched}\"" ;; printf "%s\n" "Build will be compiled to \"${HOME}/rt_${branch}_${buildType}${movetoPatched}\"" ;;
a|A) printf "%s\n" "Cannot proceed if old build directory exists." "Remove it or rename it, then re-run this script." "Aborting" a|A) printf "%s\n" "Cannot proceed if old build directory exists." "Remove it or rename it, then re-run this script." "Aborting"
exit 0 ;; exit 0 ;;
@@ -320,7 +331,9 @@ for choiceNumber in "${choiceNumbers[@]}"; do
-DBUILD_BUNDLE="ON" \ -DBUILD_BUNDLE="ON" \
-DBINDIR="." \ -DBINDIR="." \
-DDATADIR="." \ -DDATADIR="." \
-DCACHE_NAME_SUFFIX="$dCacheNameSuffix" ../ \ -DCACHE_NAME_SUFFIX="$dCacheNameSuffix" \
-DVERSION_SUFFIX="$titleSuffix" \
../ \
|| { echo "Error during cmake, exiting."; exit 1; } || { echo "Error during cmake, exiting."; exit 1; }
fi fi
echo echo