From 64dc5da457213f1e84865e96ea3cb9dbd564092f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Wed, 31 Jan 2024 18:03:11 -0700 Subject: [PATCH] Sync with WRF --- cleanCMake.sh | 139 +++++++++++++++++++++++++++++----------------------------- compile_new | 11 ++++- configure_new | 34 +++++++++++--- 3 files changed, 105 insertions(+), 79 deletions(-) rewrite cleanCMake.sh (77%) diff --git a/cleanCMake.sh b/cleanCMake.sh dissimilarity index 77% index a33c54c..06c3a38 100755 --- a/cleanCMake.sh +++ b/cleanCMake.sh @@ -1,70 +1,69 @@ -#!/bin/sh -BUILD_DIR=_build -INSTALL_DIR=run -TEST_DIR=test/ - -help() -{ - echo "./cleanCMake.sh [options]" - echo " -c Basic cmake clean functionality [cmake --build ${BUILD_DIR} -j 1 --target clean]" - echo " -i Remove cmake binary installs [xargs rm < ${BUILD_DIR}/install_manifest.txt]" - # echo " -l Remove symlinks (WPS) [ find ${TEST_DIR} -type l -exec rm {} \; ]" - echo " -f Remove build & install folders (WPS) [ rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r ]" - echo " -a Remove all (WPS), equivalent to -f (more specifically -c -i -f)" -} - -CLEAN_BASIC_BUILD=FALSE -CLEAN_BASIC_INSTALL=FALSE -CLEAN_LINKS=FALSE -CLEAN_FOLDERS=FALSE -CLEAN_ALL=FALSE - -while getopts "hcilfa" opt; do - case ${opt} in - c) - CLEAN_BASIC_BUILD=TRUE - ;; - i) - CLEAN_BASIC_INSTALL=TRUE - ;; - l) - CLEAN_LINKS=TRUE - ;; - f) - CLEAN_FOLDERS=TRUE - ;; - a) - CLEAN_ALL=TRUE - ;; - h) help; exit 0 ;; - *) help; exit 1 ;; - :) help; exit 1 ;; - \?) help; exit 1 ;; - esac -done - -if [ $OPTIND -eq 1 ]; then - # Do basic clean I guess - CLEAN_BASIC_BUILD=TRUE -fi - -if [ "${CLEAN_BASIC_BUILD}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then - echo "Doing cmake make clean" - OLD_DIR=$PWD - cd ${BUILD_DIR} && make -j 1 clean; cd $OLD_DIR -fi - -if [ "${CLEAN_BASIC_INSTALL}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then - echo "Removing binary installs" - xargs rm < ${BUILD_DIR}/install_manifest.txt -fi - -# if [ "${CLEAN_LINKS}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then -# echo "Removing all symlinks in ${TEST_DIR}" -# find ${TEST_DIR} -type l -exec rm {} \; -# fi - -if [ "${CLEAN_FOLDERS}" = "TRUE" ] || [ "${CLEAN_ALL}" = "TRUE" ]; then - echo "Deleting ${BUILD_DIR} & ${INSTALL_DIR}/" - rm ${BUILD_DIR} -r; rm ${INSTALL_DIR}/ -r -fi \ No newline at end of file +#!/bin/sh +buildDirectory=_build +installDirectory=install + +help() +{ + echo "./cleanCMake.sh [options]" + echo " -c [Default if no options] Basic cmake clean functionality [make -j 1 clean]" + echo " -b Remove cmake binary installs [xargs rm < ${buildDirectory}/install_manifest.txt]" + echo " -f Remove build & install folders (WRF) [ rm ${buildDirectory} -r; rm ${installDirectory}/ -r ]" + echo " -a Remove all (WRF), equivalent to -c -b -f (more specifically -c then -b then-f)" + echo "Specific builds/installs" + echo " -d directory Specify operating on particular build directory" + echo " -i directory Specify operating on particular install directory" +} + +cleanBasicBuild=FALSE +cleanBasicInstall=FALSE +cleanLinks=FALSE +cleanFolders=FALSE +cleanAll=FALSE + +while getopts "hcbfad:i:" opt; do + case ${opt} in + c) + cleanBasicBuild=TRUE + ;; + b) + cleanBasicInstall=TRUE + ;; + f) + cleanFolders=TRUE + ;; + a) + cleanAll=TRUE + ;; + d) + buildDirectory=$OPTARG + ;; + i) + installDirectory=$OPTARG + ;; + h) help; exit 0 ;; + *) help; exit 1 ;; + :) help; exit 1 ;; + \?) help; exit 1 ;; + esac +done + +if [ $OPTIND -eq 1 ]; then + # Do basic clean I guess + cleanBasicBuild=TRUE +fi + +if [ "${cleanBasicBuild}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then + echo "Doing cmake make clean" + OLD_DIR=$PWD + cd ${buildDirectory} && make -j 1 clean > /dev/null 2>&1; cd $OLD_DIR +fi + +if [ "${cleanBasicInstall}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then + echo "Removing binary installs" + xargs rm < ${buildDirectory}/install_manifest.txt > /dev/null 2>&1 +fi + +if [ "${cleanFolders}" = "TRUE" ] || [ "${cleanAll}" = "TRUE" ]; then + echo "Deleting ${buildDirectory} & ${installDirectory}/" + rm ${buildDirectory} -r; rm ${installDirectory}/ -r > /dev/null 2>&1 +fi diff --git a/compile_new b/compile_new index 121f835..721df9d 100755 --- a/compile_new +++ b/compile_new @@ -2,5 +2,12 @@ # Meant to be run at the top level # Now run cmake -cd _build && make install $* -# cmake --build _build --target install $* \ No newline at end of file +buildDirectory=$1 +if [ ! -d "$buildDirectory" ]; then + buildDirectory=$PWD/_build + echo "Using default build directory : ${buildDirectory}" +else + shift +fi +cd $buildDirectory && make install $* +exit $? \ No newline at end of file diff --git a/configure_new b/configure_new index 914871a..16c782b 100755 --- a/configure_new +++ b/configure_new @@ -5,6 +5,8 @@ help() echo "./configure_new [options] [-- ]" echo " -p Preselect a stanza configuration with matching description" echo " -x Skip CMake options prompt, meant to be used in conjunction with direct pass-in options" + echo " -d directory Use as alternate build directory" + echo " -i directory Use as alternate install directory" echo " -- Directly pass CMake options to configuration, equivalent to cmake " echo " -h Print this message" @@ -12,7 +14,7 @@ help() preselect= skipCMake=false -while getopts p:xh opt; do +while getopts p:xd:i:h opt; do case $opt in p) preselect=$OPTARG @@ -20,6 +22,12 @@ while getopts p:xh opt; do x) skipCMake=true ;; + d) + buildDirectory=$OPTARG + ;; + i) + installDirectory=$OPTARG + ;; h) help; exit 0 ;; *) help; exit 1 ;; :) help; exit 1 ;; @@ -36,6 +44,17 @@ else extraOps="-s CMakeLists.txt" fi +if [ -z "$buildDirectory" ]; then + buildDirectory=_build + echo "Using default build directory : $buildDirectory" +fi +if [ -z "$installDirectory" ]; then + installDirectory=$PWD/install + echo "Using default install directory : $installDirectory" +fi + +mkdir -p $buildDirectory + if [ ! -z "$preselect" ]; then echo "Using preselected config ${preselect}" @@ -43,14 +62,14 @@ if [ ! -z "$preselect" ]; then ./arch/configure_reader.py \ -c arch/configure.defaults \ -t cmake/template/arch_config.cmake \ - -o wps_config.cmake \ + -o $buildDirectory/wps_config.cmake \ ${extraOps} -p "${preselect}" else # Meant to be run at the top level ./arch/configure_reader.py \ -c arch/configure.defaults \ -t cmake/template/arch_config.cmake \ - -o wps_config.cmake \ + -o $buildDirectory/wps_config.cmake \ ${extraOps} fi @@ -58,8 +77,9 @@ configureStanza=$? if [ $configureStanza -eq 0 ]; then # Now run cmake - mkdir -p _build/ - cd _build - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../run -DCMAKE_TOOLCHAIN_FILE=$PWD/../wps_config.cmake $* - # cmake -S . -B _build + cd $buildDirectory + cmake .. -DCMAKE_INSTALL_PREFIX=$installDirectory -DCMAKE_TOOLCHAIN_FILE=$buildDirectory/wps_config.cmake $* + exit $? +else + exit $configureStanza fi \ No newline at end of file -- 2.11.4.GIT