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,18 +25,17 @@ 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"
@@ -46,6 +45,10 @@ while getopts "bc:np:uvh?-" opt; do
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]/}"
printf "%s\n" "Suffix of destination build dir: ${movetoPatched}" ;;
t) titleSuffix="${OPTARG//[^\.\-\ \+_a-zA-Z0-9]/}"
printf "%s\n" "Titlebar version suffix: ${titleSuffix}" ;;
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; } 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; }
gcVer="${gcVer##*[[:alpha:]] }" gcVer="${gcVer##*[[:alpha:]] }"
gcVer="${gcVer%%,*}" gcVer="${gcVer%%,*}"
@@ -60,7 +63,7 @@ while getopts "bc:np:uvh?-" opt; do
v) verbose=yes v) verbose=yes
printf "%s\n" "Verbose mode, I will spam your screen with warnings" ;; printf "%s\n" "Verbose mode, I will spam your screen with warnings" ;;
h|\?|-) printf "%s\n" "Usage:" "" \ h|\?|-) printf "%s\n" "Usage:" "" \
" $0 [-b] [-c <string>] [-n] [-p <1-9>] [-v]" "" \ " $0 [-b] [-c <string>] [-n] [-p <1-9>] [-s <string>] [-v]" "" \
" -b" \ " -b" \
"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\"" "" \ "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\"" "" \
" -c <string>" \ " -c <string>" \
@@ -69,12 +72,16 @@ while getopts "bc:np:uvh?-" opt; do
"Disable OpenMP." "" \ "Disable OpenMP." "" \
" -p <1-9>" \ " -p <1-9>" \
"Set which processor target to use. Takes a single digit from 1 to 9. The default is 2. See ProcessorTargets.cmake" "" \ "Set which processor target to use. Takes a single digit from 1 to 9. The default is 2. See ProcessorTargets.cmake" "" \
" -s <string>" \
"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)." "" \
" -t <string>" \
"Suffix displayed next to the RawTherapee version in the window titlebar, e.g.: -t \"+ dustremoval-1.patch + mustafa ibrahim\"" "" \
" -u" \ " -u" \
"Check for an update of buildRT on Google Code." "" \ "Check for an update of buildRT on Google Code." "" \
" -v" \ " -v" \
"Make compilation verbose, so you see all compiler warnings." | fold -s "Make compilation verbose, so you see all compiler warnings." | fold -s
exit 0 ;; exit 0 ;;
esac 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." ""
if [[ -z $movetoPatched ]]; then
movetoPatched="_patched" 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