#!/bin/sh # # High-level script to manage the project. # Run './project --help' for a description of how to use it. # # Copyright (C) 2019-2025 Mohammad Akhlaghi # Copyright (C) 2021-2025 Raul Infante-Sainz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Basic settings # -------------- # Stop the script if there are any errors. set -e # Default option values jobs=0 # 0 is for the default for the 'configure.sh' script. group= debug= timing=0 host_cc=0 offline= operation= build_dir= input_dir= keep_going= check_config= make_targets= software_dir= clean_texdir=0 prepare_redo=0 highlightnew=0 all_highlevel=0 existing_conf=0 highlightnotes=0 scriptname="./project" # Parse the options # ----------------- # # Separate command-line arguments from options. Then put the option value # into the respective variable. # # Each option has two lines because we want to process both these formats: # '--name=value' and '--name value'. The former (with '=') is a single # command-line argument, so we just need to shift the counter by one. The # latter (without '=') is two arguments, so we'll need two shifts. # # Note on the case strings: for every option, we need three lines: one when # the option name and value are separate. Another when there is an equal # between them, and finally one where the value is immediately after the # short-format. This exact order is important. Otherwise, there will be a # conflict between them. print_help() { # Print the output. cat < /dev/null > /dev/null; then coloropt="--color=auto" elif ls -G 2> /dev/null > /dev/null; then coloropt="-G" else coloropt="" fi # Print a notice to let the user know what is happening. cat <> timing.txt; fi # Run data preparation phase (optionally build Makefiles with # special values for optimizing the main 'top-make.mk'). But note # that data preparation is only done automatically the first time # the project is built (when '.build/analysis/preparation-done.mk' # doesn't yet exist). After that, if the user wants to re-do the # preparation they have to use the '--prepare-redo' option. if ! [ -f .build/analysis/preparation-done.mk ] \ || [ x"$prepare_redo" = x1 ]; then controlled_env reproduce/analysis/make/top-prepare.mk fi # Call top-make (highest level analysis Makefile). controlled_env reproduce/analysis/make/top-make.mk # Register the time of the project's ending. if [ $timing = 1 ]; then echo "end: $(date)" >> timing.txt; fi ;; # Interactive shell of Maneage. shell) # Make sure the configure script has been completed properly # ('configuration-done.txt' exists). if ! [ -f .build/software/configuration-done.txt ]; then configuration_necessary fi # Run the project's own shell without inheriting any environment # from the host. The 'TERM' environment variable is necessary for # tools like some text editors. bdir=`.local/bin/realpath .build` instdir="$bdir"/software/installed bindir="$bdir"/software/installed/bin rcfile=$(pwd)/reproduce/software/shell/bashrc.sh .local/bin/env -i \ HOME="$bdir" \ TERM="$TERM" \ PATH="$bindir" \ CCACHE_DISABLE=1 \ PROJECT_STATUS=shell \ SHELL="$bindir"/bash \ COLORTERM="$COLORTERM" \ PROJECT_RCFILE="$rcfile" \ LDFLAGS=-L"$instdir"/lib \ CPPFLAGS=-I"$instdir"/include \ LD_LIBRARY_PATH="$instdir"/lib \ OMPI_MCA_plm_rsh_agent=/bin/false \ PYTHONPATH="$instdir"/lib/python/site-packages \ PYTHONPATH3="$instdir"/lib/python/site-packages \ PS1="[\[\033[01;35m\]maneage@\h \W\[\033[32m\]\[\033[00m\]]$ " \ "$bindir"/bash --noprofile --rcfile "$rcfile" ;; # Operation not specified. *) cat <