Skip to content
Snippets Groups Projects
Commit a7d3853b authored by Sebastien Masson's avatar Sebastien Masson
Browse files

make clean working again in makenemo, #68

parent 27575d30
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,7 @@ set -o posix ...@@ -86,6 +86,7 @@ set -o posix
x_d=''; x_h=''; x_n=''; x_r=''; x_c=''; x_d=''; x_h=''; x_n=''; x_r=''; x_c='';
x_u=''; x_a=''; x_m=''; x_t=''; x_b=''; x_u=''; x_a=''; x_m=''; x_t=''; x_b='';
x_j='1'; x_e='none'; x_s='src'; x_v='1' x_j='1'; x_e='none'; x_s='src'; x_v='1'
x_c_cfg=0
x_nocdf=0 x_nocdf=0
x_name='' x_name=''
...@@ -115,34 +116,42 @@ export PATH=${MAIN_DIR}/ext/FCM/bin:$PATH ...@@ -115,34 +116,42 @@ export PATH=${MAIN_DIR}/ext/FCM/bin:$PATH
#- #-
#- Choice of the options --- #- Choice of the options ---
## Get clean, clean_config options
while [ ${#1} -gt 0 ]; do while [ ${#1} -gt 0 ]; do
case "$1" in case "$1" in
-h|--help) cat <<EOF -h|--help) cat <<EOF
Usage: Usage:
------ ------
./makenemo -[arn] CONFIG -m ARCH [-[...] ...] [{list_key,clean,clean_config}] ./makenemo -[arn] CONFIG -m ARCH [-[...] ...]
Mandatory Mandatory
-m, --mach, --machine, --arch <machine_name> -m, --mach, --machine, --arch <machine_name>
Computing architecture, will use the file arch_<machine_name>.fcm located in ./arch (sub)directory(ies) Computing architecture, will use the file arch_<machine_name>.fcm located
in ./arch (sub)directory(ies)
-n, --name <config_name> -n, --name <config_name>
Name of the configuration to compile Name of the configuration to compile
and, if -n defines a new configuration, one of the following option (use 'all' arg to list available items): and, if -n defines a new configuration, one of the following option (use 'all' arg to
list available items):
-r, --ref <ref_config_name> -r, --ref <ref_config_name>
To specify which reference configuration (./cfgs) must be used to buit the new configuration To specify which reference configuration (./cfgs) must be used to buit the
new configuration
-a, --test <test_config_name> -a, --test <test_config_name>
To specify which academic test case (./tests) must be used to buit the new configuration To specify which academic test case (./tests) must be used to buit the new
configuration
Optional Optional
--add_key, key_add, add_key "<list of keys>" --add_key, key_add, add_key "<list of keys>"
list of cpp keys to be added in cpp_<config_name>.fcm file list of cpp keys to be added in cpp_<config_name>.fcm file
-b, --dbg, --debug -b, --dbg, --debug
add it to compile in debug mode add it to compile in debug mode
--clean, --clean_compil, clean
Clean all files and directories used for compilation + the REPRO_* and
the SHORT directories
--clean_config, clean_config
Completly delete a configuration
-d, --dirs, --comp <sub-components> -d, --dirs, --comp <sub-components>
New set of sub-components (subfolders from ./src directory) to be used New set of sub-components (subfolders from ./src directory) to be used
--def_key, key_def, def_key "<list of keys>" --def_key, key_def, def_key "<list of keys>"
...@@ -156,8 +165,10 @@ Optional ...@@ -156,8 +165,10 @@ Optional
-j, --jobs <nb_job> -j, --jobs <nb_job>
Number of processes to compile (0: dry run with no build) Number of processes to compile (0: dry run with no build)
-k, --chkkey <O/1> -k, --chkkey <O/1>
Set to 0 to bypass the check of the cpp keys (takes time at the beginning of makenemo). Set to 0 to bypass the check of the cpp keys (takes time at the beginning
Default is 1 of makenemo). Default is 1
--list_key, --key_list, list_key
List all existing cpp keys in the configuration and exit without compiling
--nonc, --nocdf, --nonetcdf, --no_nc, --no_cdf, --no_netcdf --nonc, --nocdf, --nonetcdf, --no_nc, --no_cdf, --no_netcdf
Compile without the NetCDF Library Compile without the NetCDF Library
-s, --srcpath, --src_path <path> -s, --srcpath, --src_path <path>
...@@ -173,9 +184,9 @@ Examples ...@@ -173,9 +184,9 @@ Examples
Copy : ./makenemo -n ... -[ar] ... [...] Copy : ./makenemo -n ... -[ar] ... [...]
¤ Configuration management ¤ Configuration management
List CPP keys : ./makenemo -n ... list_key List CPP keys : ./makenemo -n ... list_key
Add-Remove keys: ./makenemo -n ... add_key '...' del_key '...' Add-Remove keys: ./makenemo -n ... --add_key '...' --del_key '...'
Fresh start : ./makenemo -n ... clean Fresh start : ./makenemo -n ... --clean
Removal : ./makenemo -n ... clean_config Removal : ./makenemo -n ... --clean_config
EOF EOF
exit 0 ;; exit 0 ;;
...@@ -204,18 +215,15 @@ EOF ...@@ -204,18 +215,15 @@ EOF
chk_key=${2} ; shift ;; chk_key=${2} ; shift ;;
--nonc|--nocdf|--nonetcdf|--no_nc|--no_cdf|--no_netcdf) --nonc|--nocdf|--nonetcdf|--no_nc|--no_cdf|--no_netcdf)
x_nocdf=1 ;; x_nocdf=1 ;;
--clean|clean) --clean|--clean_compil|clean)
x_c="--$1" ;; x_c="--clean" ;;
--clean_config|clean_config) --clean_config|clean_config)
. ${COMPIL_DIR}/Fclean_config.sh; exit ;; x_c_cfg=1 ;;
## Checking if argument has anything other than whitespace
--add_key|--key_add|add_key ) [[ ! "$2" =~ ^\ +$ ]] && list_add_key=$2; shift;; --add_key|--key_add|add_key ) [[ ! "$2" =~ ^\ +$ ]] && list_add_key=$2; shift;;
--def_key|--key_def|def_key ) [[ ! "$2" =~ ^\ +$ ]] && list_def_key=$2; shift;; --def_key|--key_def|def_key ) [[ ! "$2" =~ ^\ +$ ]] && list_def_key=$2; shift;;
--del_key|--key_del|del_key ) [[ ! "$2" =~ ^\ +$ ]] && list_del_key=$2; shift;; --del_key|--key_del|del_key ) [[ ! "$2" =~ ^\ +$ ]] && list_del_key=$2; shift;;
--list_key|list_key ) list_key='1' ;; --list_key|--key_list|list_key) list_key='1' ;;
'*' ) echo " \"$1\" BAD OPTION"; exit 2 ;; *) echo -e "\033[0;31m\n \"$1\" BAD OPTION\033[0m\n"; exit 2 ;;
':') echo ${b_n}" : -"${1}" option : missing value" 1>&2; exit 2 ;;
'?') echo ${b_n}" : -"${1}" option : not supported" 1>&2; exit 2 ;;
esac esac
shift shift
...@@ -230,6 +238,11 @@ then ...@@ -230,6 +238,11 @@ then
exit 4 exit 4
fi fi
if [ $(( $incfg + $intst )) -gt 0 ] ; then if [ $(( $incfg + $intst )) -gt 0 ] ; then
if [ $x_c_cfg -eq 1 ] ; then # if we just want to clean the config (do it here as it must exist)
x_n=$x_name # must define x_n as it is used in Fclean_config.sh
. ${COMPIL_DIR}/Fclean_config.sh
exit 0
fi
[ -n "$x_r" ] && echo -e "\nWARNING: $x_name configuration is already existing, we ignore \"-r $x_r\"\n" [ -n "$x_r" ] && echo -e "\nWARNING: $x_name configuration is already existing, we ignore \"-r $x_r\"\n"
[ -n "$x_a" ] && echo -e "\nWARNING: $x_name configuration is already existing, we ignore \"-a $x_a\"\n" [ -n "$x_a" ] && echo -e "\nWARNING: $x_name configuration is already existing, we ignore \"-a $x_a\"\n"
fi fi
...@@ -238,6 +251,8 @@ then ...@@ -238,6 +251,8 @@ then
elif [ $intst -eq 1 ] ; then elif [ $intst -eq 1 ] ; then
x_a=$x_name ; x_r='' # test configuration existing -> define/overwrite x_a x_a=$x_name ; x_r='' # test configuration existing -> define/overwrite x_a
else else
[ ${#x_c} -ne 0 ] && echo -e "\nWARNING: Compilation cleaning of a non-existing configuration, we ignore\n" && exit 0
[ $x_c_cfg -eq 1 ] && echo -e "\nWARNING: Configuration cleaning of a non-existing configuration, we ignore\n" && exit 0
x_n=$x_name # this is a new configuration -> define x_n=$x_name # this is a new configuration -> define
fi fi
fi fi
...@@ -256,19 +271,10 @@ NEMO_DBG=${x_b} ...@@ -256,19 +271,10 @@ NEMO_DBG=${x_b}
## No ref. cfg or demo selected ## No ref. cfg or demo selected
if [[ -z "${REF_CONF}" && -z "${DEMO_CONF}" ]]; then if [[ -z "${REF_CONF}" && -z "${DEMO_CONF}" ]]; then
echo -e "\033[0;31m\nAt least a reference configuration ('-r'), a test case ('-a'), "
## Reuse last configuration compiled if any (existing 'work_cfgs.txt') echo -e "a remote configuration ('-u') has to be choosen to build a new configuration!!!\033[0m"
# if [[ $( find ./cfgs ./tests -name work_cfgs.txt ) ]]; then ${COMPIL_DIR}/Flist_cfgs.sh
# CFGS_DIR=${MAIN_DIR}/$( ls -rt */work_cfgs.txt | awk -F/ 'END{ print $1}' ) exit 2
# TML_CONF=$( tail -1 ${CFGS_DIR}/work_cfgs.txt | awk '{ print $1 }' )
# else
## No ${REF_CONF}, ${DEMO_CONF} nor ${NEM_SUBDIR} and 1st compilation => exit
# echo -e "\033[0;33m\nNo previous build found!"
echo -e "\033[0;31m\nAt least a reference configuration ('-r'), a test case ('-a'), "
echo -e "a remote configuration ('-u') has to be choosen!!!\033[0m"
${COMPIL_DIR}/Flist_cfgs.sh
exit 2
# fi
fi fi
## At least one config has been requested ## At least one config has been requested
...@@ -339,15 +345,13 @@ ${COMPIL_DIR}/Fmake_config.sh ${NEW_CONF} ${TML_CONF} ...@@ -339,15 +345,13 @@ ${COMPIL_DIR}/Fmake_config.sh ${NEW_CONF} ${TML_CONF}
. ${COMPIL_DIR}/Fmake_bld.sh ${CONFIG_DIR} ${NEW_CONF} ${NEMO_TDIR} || exit 3 . ${COMPIL_DIR}/Fmake_bld.sh ${CONFIG_DIR} ${NEW_CONF} ${NEMO_TDIR} || exit 3
# build the complete list of the cpp keys of this configuration # build the complete list of the cpp keys of this configuration
if [ ${chk_key} -eq 1 ] ; then if [[ ${chk_key} -eq 1 || ${list_key} -eq 1 ]] ; then
for i in $( grep "^ *#.* key_" ${NEW_CONF}/WORK/* ); do
for i in $( grep "^ *#.* key_" ${NEW_CONF}/WORK/* ); do echo $i | grep key_ | sed -e "s/=.*//"
echo $i | grep key_ | sed -e "s/=.*//" done \
done \
| sort -d | uniq > ${COMPIL_DIR}/full_key_list.txt | sort -d | uniq > ${COMPIL_DIR}/full_key_list.txt
[ ${list_key} -eq 1 ] && cat ${COMPIL_DIR}/full_key_list.txt && exit 0 [ ${list_key} -eq 1 ] && echo && cat ${COMPIL_DIR}/full_key_list.txt && exit 0
fi fi
#- At this stage new configuration has been added, we add or remove keys #- At this stage new configuration has been added, we add or remove keys
...@@ -357,24 +361,18 @@ fi ...@@ -357,24 +361,18 @@ fi
#- check that all keys are really existing... #- check that all keys are really existing...
if [ $chk_key -eq 1 ] ; then if [ $chk_key -eq 1 ] ; then
for kk in $( cat ${NEW_CONF}/cpp_${NEW_CONF}.fcm ); do
for kk in $( cat ${NEW_CONF}/cpp_${NEW_CONF}.fcm ); do if [ "$( echo $kk | cut -c 1-4 )" == "key_" ]; then
kk=${kk/=*/}
if [ "$( echo $kk | cut -c 1-4 )" == "key_" ]; then if [ ! $( grep -w $kk ${COMPIL_DIR}/full_key_list.txt ) ]; then
kk=${kk/=*/} echo
echo "E R R O R : key "$kk" is not found in ${NEW_CONF}/WORK routines..."
if [ ! $( grep -w $kk ${COMPIL_DIR}/full_key_list.txt ) ]; then echo "we stop..."
echo echo
echo "E R R O R : key "$kk" is not found in ${NEW_CONF}/WORK routines..." exit 1
echo "we stop..." fi
echo fi
exit 1 done
fi
fi
done
fi fi
#- At this stage cpp keys have been updated. we can check the arch file #- At this stage cpp keys have been updated. we can check the arch file
...@@ -397,39 +395,35 @@ grep key_agrif ${COMPIL_DIR}/cpp.fcm && export AGRIFUSE=1 && export USEBLD=${USE ...@@ -397,39 +395,35 @@ grep key_agrif ${COMPIL_DIR}/cpp.fcm && export AGRIFUSE=1 && export USEBLD=${USE
#- Compile --- #- Compile ---
if [ "${NBR_PRC}" -gt 0 ]; then if [ "${NBR_PRC}" -gt 0 ]; then
cd ${NEMO_TDIR}/${NEW_CONF} || cd - cd ${NEMO_TDIR}/${NEW_CONF} || cd -
## if AGRIF we do a first preprocessing ## if AGRIF we do a first preprocessing
if [[ ${#x_c} -eq 0 && "$AGRIFUSE" -eq 1 ]]; then if [[ ${#x_c} -eq 0 && "$AGRIFUSE" -eq 1 ]]; then
fcm build --ignore-lock -j 1 ${COMPIL_DIR}/bld_preproagr.cfg ||{ cd - ; exit 1 ;} fcm build --ignore-lock -j 1 ${COMPIL_DIR}/bld_preproagr.cfg ||{ cd - ; exit 1 ;}
echo '' echo ''
echo "---------------------------------" echo "---------------------------------"
echo "CONV preprocessing successfull !!" echo "CONV preprocessing successfull !!"
echo "---------------------------------" echo "---------------------------------"
echo '' echo ''
fi fi
fcm build ${x_c} --ignore-lock -v ${x_v} -j ${NBR_PRC} ${COMPIL_DIR}/$USEBLD ||{ cd - ; exit 1 ;} fcm build ${x_c} --ignore-lock -v ${x_v} -j ${NBR_PRC} ${COMPIL_DIR}/$USEBLD ||{ cd - ; exit 1 ;}
if [ -f ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/nemo.exe ]; then
ln -sf ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/nemo.exe ${CONFIG_DIR}/${NEW_CONF}/EXP00/nemo
fi
## add remove for clean option
if [ ${#x_c} -ne 0 ]; then
echo 'Cleaning in '${NEW_CONF}' the building folders'
for dir in AGRIFLIB BLD LONG NEMOFILES REPRO_* SHORT WORK; do
rm -rf ${NEMO_TDIR}/${NEW_CONF}/$dir
done
for file in cpp.history cpp.fcm full_key_list.txt; do
rm -f ${COMPIL_DIR}/$file
done
fi if [ -f ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/nemo.exe ]; then
ln -sf ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/nemo.exe ${CONFIG_DIR}/${NEW_CONF}/EXP00/nemo
fi
## add remove for clean option
if [ ${#x_c} -ne 0 ]; then
echo -e '\nCleaning '${NEW_CONF}' building directories and variables\n'
for dir in AGRIFLIB BLD LONG NEMOFILES REPRO_* SHORT WORK; do
rm -rf ${NEMO_TDIR}/${NEW_CONF}/$dir
done
for file in cpp.history cpp.fcm full_key_list.txt; do
rm -f ${COMPIL_DIR}/$file
done
fi
fi fi
#- Come back to original directory --- #- Come back to original directory ---
......
...@@ -69,6 +69,7 @@ if [ ${#NEW_CONF} -eq 0 ] ; then ...@@ -69,6 +69,7 @@ if [ ${#NEW_CONF} -eq 0 ] ; then
echo " " echo " "
echo "No configuration specified, please use makenemo -n CONFIG clean_config " echo "No configuration specified, please use makenemo -n CONFIG clean_config "
else else
echo " "
echo "Are you sure that you want to remove this directory $NEW_CONF? [y/n] " echo "Are you sure that you want to remove this directory $NEW_CONF? [y/n] "
read answer read answer
answer=`echo $answer | sed 's/^[y].*$/y/'` answer=`echo $answer | sed 's/^[y].*$/y/'`
......
#!/bin/bash
######################################################
# Author :
# Contact :
#
# Some functions called from makenemo
# Fdef_keys : define keys in cpp.fcm file
######################################################
#set -x
set -o posix
#set -u
#set -e
#+
#
# ================
# Fdef_keys.sh
# ================
#
# --------------------------
# Add compilation keys
# --------------------------
#
# SYNOPSIS
# ========
#
# ::
#
# $ Fdef_keys.sh CONFIG_NAME def_key "LIST_KEYS"
#
#
# DESCRIPTION
# ===========
#
#
# define cpp keys when compiling a configuration, key list has to be enclosed with " ".
#
# EXAMPLES
# ========
#
# ::
#
# $ ./Fdef_keys.sh CONFIG_NAME def_key "key_agrif"
#
#
# TODO
# ====
#
# option debug
#
#
# EVOLUTIONS
# ==========
#
#
# * creation
#
#-
echo "Defining keys in : ${NEW_CONF}"
echo " bld::tool::fppkeys ${list_def_key}" > ${CONFIG_DIR}/${NEW_CONF}/cpp_${NEW_CONF}.fcm
unset -v list_def_key
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment