Added new tools/build-rawtherapee Bash script
This commit is contained in:
132
tools/build-rawtherapee
Executable file
132
tools/build-rawtherapee
Executable file
@@ -0,0 +1,132 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# By Morgan Hardwood
|
||||||
|
# Version 2017-12-25
|
||||||
|
# This script gets the latest source code for the given program and compiles it.
|
||||||
|
|
||||||
|
# The name of the program, used for the folder names:
|
||||||
|
prog="rawtherapee"
|
||||||
|
|
||||||
|
# The name of the compiled executable:
|
||||||
|
exe="${prog}"
|
||||||
|
|
||||||
|
# The name of the sub-folder, if any, relative to the folder into which the
|
||||||
|
# compiled executable is placed.
|
||||||
|
# e.g. If the executable ends up in:
|
||||||
|
# ~/programs/someProgram/foo/bar/someExecutable
|
||||||
|
# then set it to:
|
||||||
|
# exeRelativePath="foo/bar"
|
||||||
|
# or if the executable ends up in
|
||||||
|
# ~/programs/someProgram/someExecutable
|
||||||
|
# then leave it empty:
|
||||||
|
# exeRelativePath=""
|
||||||
|
exeRelativePath=""
|
||||||
|
|
||||||
|
# The path to the repository:
|
||||||
|
repo="git@github.com:Beep6581/RawTherapee.git"
|
||||||
|
|
||||||
|
# No touching below this line, with the exception of the "Compile" section
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
buildOnly="false"
|
||||||
|
buildType="release"
|
||||||
|
|
||||||
|
# Removes the trailing forward-slash if one is present
|
||||||
|
exeRelativePath="${exeRelativePath/%\/}"
|
||||||
|
# Append forward-slash to exeRelativePath only if it is not empty.
|
||||||
|
exePath="${exeRelativePath:+${exeRelativePath}/}${exe}"
|
||||||
|
|
||||||
|
printf '%s\n' "" "Program name: ${prog}" "Build type: ${buildType}" "Build without updating: ${buildOnly}" ""
|
||||||
|
|
||||||
|
# Command-line arguments
|
||||||
|
OPTIND=1
|
||||||
|
while getopts "bdh?-" opt; do
|
||||||
|
case "${opt}" in
|
||||||
|
b) buildOnly="true"
|
||||||
|
;;
|
||||||
|
d) buildType="debug"
|
||||||
|
;;
|
||||||
|
h|\?|-) printf '%s\n' "This script gets the latest source code for ${prog} and compiles it." \
|
||||||
|
"" \
|
||||||
|
" -b" \
|
||||||
|
" Optional. If specified, the script only compiles the source, it does not try to update the source. If not specified, the source will be updated first." \
|
||||||
|
" -d" \
|
||||||
|
" Optional. Compile a \"debug\" build. If not specified, a \"release\" build will be made." \
|
||||||
|
""
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
[ "$1" = "--" ] && shift
|
||||||
|
|
||||||
|
# Clone if needed
|
||||||
|
cloned="false"
|
||||||
|
updates="false"
|
||||||
|
if [[ ! -d "$HOME/programs/code-${prog}" ]]; then
|
||||||
|
mkdir -p "$HOME/programs" || exit 1
|
||||||
|
git clone "$repo" "$HOME/programs/code-${prog}" || exit 1
|
||||||
|
pushd "$HOME/programs/code-${prog}" || exit 1
|
||||||
|
cloned="true"
|
||||||
|
else
|
||||||
|
pushd "$HOME/programs/code-${prog}" || exit 1
|
||||||
|
git fetch
|
||||||
|
if [[ $(git rev-parse HEAD) != $(git rev-parse '@{u}') ]]; then
|
||||||
|
updates="true"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Pull updates if necessary
|
||||||
|
if [[ "$updates" = "true" && "$buildOnly" = "false" ]]; then
|
||||||
|
git pull || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
existsExe="false"
|
||||||
|
if [[ -e "$HOME/programs/${prog}/${exePath}" ]]; then
|
||||||
|
existsExe="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Quit if no updates and build-only flag not set
|
||||||
|
if [[ "$cloned" = "false" && "$buildOnly" = "false" && "$updates" = "false" && "$existsExe" = "true" ]]; then
|
||||||
|
printf '%s\n' "No updates, nothing to do."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine CPU count
|
||||||
|
cpuCount="fail"
|
||||||
|
if command -v nproc >/dev/null 2>&1; then
|
||||||
|
cpuCount="$(nproc --all)"
|
||||||
|
fi
|
||||||
|
if [[ ! ( $cpuCount -ge 1 && $cpuCount -le 64 ) ]]; then
|
||||||
|
cpuCount=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare folders
|
||||||
|
rm -rf "$HOME/programs/${prog}" "$HOME/programs/code-${prog}/build"
|
||||||
|
mkdir -p "$HOME/programs/${prog}" "$HOME/programs/code-${prog}/build" || exit 1
|
||||||
|
cd "$HOME/programs/code-${prog}/build" || exit 1
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Compile
|
||||||
|
|
||||||
|
# See:
|
||||||
|
# http://rawpedia.rawtherapee.com/Linux#Compile_RawTherapee
|
||||||
|
|
||||||
|
cmake \
|
||||||
|
-DCMAKE_BUILD_TYPE="$buildType" \
|
||||||
|
-DCACHE_NAME_SUFFIX="5-dev" \
|
||||||
|
-DPROC_TARGET_NUMBER="2" \
|
||||||
|
-DBUILD_BUNDLE="ON" \
|
||||||
|
-DBUNDLE_BASE_INSTALL_DIR="$HOME/programs/${prog}" \
|
||||||
|
-DOPTION_OMP="ON" \
|
||||||
|
-DWITH_LTO="OFF" \
|
||||||
|
-DWITH_PROF="OFF" \
|
||||||
|
-DWITH_SAN="OFF" \
|
||||||
|
-DWITH_SYSTEM_KLT="OFF" \
|
||||||
|
"$HOME/programs/code-${prog}" || exit 1
|
||||||
|
|
||||||
|
make --jobs="$cpuCount" install || exit 1
|
||||||
|
|
||||||
|
# Finished
|
||||||
|
printf '%s\n' "" "To run ${prog} type:" "~/programs/${prog}/${exePath}" ""
|
||||||
|
|
||||||
|
popd 1>/dev/null
|
Reference in New Issue
Block a user