#! /bin/bash # ~/Dropbox/dev/scripts/cmake/clean-rebuild-qt-cmake-linux.sh set -e set -o pipefail topLevelSourceDir=$1 topLevelBuildDir=$2 configPath=$3 submoduleStr=$4 usageExample="Usage example: ~/Dropbox/dev/scripts/cmake/clean-rebuild-qt-cmake-linux.sh ~/dev/qt-dev ~/dev/qt-dev-debug ~/Dropbox/dev/configs/qt/cmake/linux-debug.txt qtbase,qtdeclarative,qtquickcontrols2,qttools" if [ -z "$1" ]; then echo "topLevelSourceDir argument not supplied" echo $usageExample exit fi if [ -z "$2" ]; then echo "topLevelBuildDir argument not supplied" echo $usageExample exit fi if [ -z "$3" ]; then echo "configPath argument not supplied" echo $usageExample exit fi if [ -z "$4" ]; then echo "submoduleStr argument not supplied" echo $usageExample exit fi if [ ! -d "$topLevelSourceDir" ]; then echo "Source directory \"$topLevelSourceDir\" doesn't exist; aborting" echo $usageExample exit fi echo === reading configure options from $configPath # https://stackoverflow.com/a/2439587/904422 configOptions=$(head -n 1 $configPath) # Check that configure options were passed. if [ "$configOptions" = "" ]; then echo "Must pass one or more configure options" exit fi echo === configure options are: $configOptions # Read the list of submodules using , as the delimiter # https://stackoverflow.com/a/15988793/904422 IFS="," read -a submodules <<<"$submoduleStr" echo === submodules are: ${submodules[*]} # Check that submodules were passed. if [ ${#submodules[@]} -eq 0 ]; then echo "Must pass one or more submodules" exit fi # Ensure that qtbase is first in the list of submodules # https://stackoverflow.com/a/15394738/904422 qtbaseToken="qtbase" if [[ ! "${submodules[0]}" =~ "${qtbaseToken}" ]]; then echo "submoduleStr argument must contain qtbase (was: \"$submoduleStr\")" exit fi echo === wiping $topLevelBuildDir rm -fr $topLevelBuildDir echo === creating $topLevelBuildDir mkdir $topLevelBuildDir # Should already be handled by "set -e", but just to be sure... if [ ! -d "$topLevelBuildDir" ]; then echo "Failed to create build directory \"$topLevelBuildDir\"; aborting" echo $usageExample exit fi echo === cding to $topLevelBuildDir cd $topLevelBuildDir # Ensure that our own, newer CMake is used. export PATH=/home/mitch/dev/cmake-build/bin:$PATH # For qdoc. export LLVM_INSTALL_DIR=/home/mitch/dev/libclang-release_110-based-linux-Ubuntu20.04-gcc9.3-x86_64/libclang # Configure and build each module within the top-level build directory. for moduleName in "${submodules[@]}" do echo === creating $topLevelBuildDir/$moduleName mkdir $moduleName echo === cding to $topLevelBuildDir/$moduleName cd $moduleName echo === configuring module $moduleName echo === value of LLVM_INSTALL_DIR is: $LLVM_INSTALL_DIR if [ "$moduleName" = "$qtbaseToken" ] then $topLevelSourceDir/qtbase/configure -- $configOptions 2>&1 | tee -a configure-output.txt else $topLevelBuildDir/qtbase/bin/qt-configure-module $topLevelSourceDir/$moduleName | tee -a configure-output.txt fi echo === building module $moduleName ninja 2>&1 | tee -a ninja-output.txt echo === cding back to $topLevelBuildDir cd $topLevelBuildDir done