diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index f2ff936..cdcdb66 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -79,7 +79,7 @@ pbuild::add_to_group() { # $@: dependencies # pbuild::set_build_dependencies() { - MODULE_BUILD_DEPENDENCIES=("$@") + MODULE_BUILD_DEPENDENCIES+=("$@") } pbuild::set_runtime_dependencies() { @@ -164,7 +164,19 @@ pbuild::configure() { } pbuild::build() { - make -j${JOBS} + # :FIXME: + # the clang based assembler in Xcode 7 is broken: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66509 + # for the time being we have to use some bin's from MacPorts + case ${OS} in + Darwin ) + #PATH="/opt/local/bin:$PATH" + make -j${JOBS} + ;; + * ) + make -j${JOBS} + ;; + esac } pbuild::install() { @@ -247,17 +259,28 @@ pbuild::make_all() { ############################################################################## # + # build dependencies can be defined + # - on the command line via '--with=MODULE/VERSION' + # - in a 'variants' file + # - in the build block + # load_build_dependencies() { - for m in "${MODULE_BUILD_DEPENDENCIES[@]}"; do + + declare variants='' + if [[ -r "${BUILD_BLOCK_DIR}/${V}/variants" ]]; then + variants="${BUILD_BLOCK_DIR}/${V}/variants" + elif [[ -r "${BUILD_BLOCK_DIR}/${V%.*}/variants" ]]; then + variants="${BUILD_BLOCK_DIR}/${V%.*}/variants" + elif [[ -r "${BUILD_BLOCK_DIR}/${V%.*.*}/variants" ]]; then + variants="${BUILD_BLOCK_DIR}/${V%.*.*}/variants" + fi + if [[ -n "${variants}" ]]; then + with_modules+=( $(egrep "$V\s.*${OS}" "${variants}" | tail -1 | + awk "${with_modules_awk_pattern} {for (i=4; i<=NF; i++) printf \$i \" \"}") ) + fi + + for m in "${with_modules[@]}" "${MODULE_BUILD_DEPENDENCIES[@]}"; do [[ -z $m ]] && continue - if [[ ! $m =~ "*/*" ]]; then - local _V=$(echo -n $m | tr [:lower:] [:upper:] )_VERSION - if [[ -n ${!_V} ]]; then - m=$m/${!_V} - else - echo "$m: warning: No version set, loading default ..." - fi - fi is_loaded "$m" && continue if ! pbuild::module_is_available "$m"; then std::debug "${m}: module not available" @@ -305,22 +328,20 @@ pbuild::make_all() { std::die 1 "$m: oops: build failed..." fi fi - # :FIXME: this doesn't work any more! - local modulepath_root="${PMODULES_ROOT}/${PMODULES_MODULEFILES_DIR}" - local tmp=$( module display "${m}" 2>&1 | grep -m1 -- "${modulepath_root}" ) - tmp=${tmp/${modulepath_root}\/} - tmp=${tmp%%/*} - local _family=( ${tmp//./ } ) - if [[ ${_family[1]} == deprecated ]]; then + + local mod_name='' + local mod_release='' + read mod_name mod_release < <("${MODULECMD}" bash avail -a -m $m 2>&1 1>/dev/null | tail -1) + + if [[ ${mod_release} == deprecated ]]; then # set module release to 'deprecated' if a build dependency # is deprecated DEPEND_RELEASE='deprecated' - elif [[ ${_family[1]} == unstable ]] && [[ -z ${DEPEND_RELEASE} ]]; then + elif [[ ${mod_release} == unstable ]] && [[ -z ${DEPEND_RELEASE} ]]; then # set module release to 'unstable' if a build dependency is # unstable and release not yet set DEPEND_RELEASE='unstable' fi - echo "Loading module: ${m}" module load "${m}" @@ -476,7 +497,7 @@ pbuild::make_all() { # set PREFIX of module PREFIX="${PMODULES_ROOT}/${MODULE_GROUP}/${MODULE_RPREFIX}" - # get module release if already installed + # get module release if already available local saved_modulepath=${MODULEPATH} rels=( ${releases//:/ } ) for rel in "${rels[@]}"; do @@ -497,7 +518,7 @@ pbuild::make_all() { # - if a build-dependency is deprecated or # - the module already exists and is deprecated or # - is forced to be deprecated by setting this on the command line - if [[ "${depend_release}" == 'deprecated' ]] || \ + if [[ "${DEPEND_RELEASE}" == 'deprecated' ]] || \ [[ "${cur_module_release}" == 'deprecated' ]] \ || [[ "${MODULE_RELEASE}" == 'deprecated' ]]; then MODULE_RELEASE='deprecated' @@ -508,7 +529,7 @@ pbuild::make_all() { # - the module already exists and is stable # - an unstable release of the module exists and the release is # changed to stable on the command line - elif [[ "${depend_release}" == 'stable' ]] \ + elif [[ "${DEPEND_RELEASE}" == 'stable' ]] \ || [[ "${cur_module_release}" == 'stable' ]] \ || [[ "${MODULE_RELEASE}" == 'stable' ]]; then MODULE_RELEASE='stable' diff --git a/Pmodules/modbuild b/Pmodules/modbuild index 1185baa..373e22b 100755 --- a/Pmodules/modbuild +++ b/Pmodules/modbuild @@ -154,9 +154,6 @@ if (( ok != 0 )); then exit 1 fi -# :FIXME: move to library? -declare -r OS=$(uname -s) - ############################################################################## # # parse arguments @@ -284,6 +281,15 @@ fi [[ -n ${BUILD_BLOCK} ]] || std::die 1 "No build-block specified!" [[ -r ${BUILD_BLOCK} ]] || std::die 1 "${BUILD_BLOCK}: no such file!" +# :FIXME: move to library? +declare -r OS=$(uname -s) +case ${OS} in +Darwin ) + declare -rx MACOSX_DEPLOYMENT_TARGET='10.9' + #declare -rx SDKROOT='macosx10.9' + ;; +esac + # source Pmodule environment configuration if [[ "${bootstrap}" == "yes" ]]; then @@ -321,38 +327,21 @@ for dir in "${bash_libpath[@]}"; do done (( ok == 0 )) || std::die 3 "Oops: required BASH library '${libpbuild}' not found" -# load all modules passed via the '--with' argument or specified in a -# configuration file. -# :FIXME: -# It should be possible to overwrite dependencies given in the -# configuration file(s) via the '--with=something' argument. For -# the time being we do not check anything - we just try to load -# everything, even if a module of different version has already -# been load. -# :FIXME: -# Specifying dependencies via 'with_modules' is deprecated and -# should be removed. if [[ ${bootstrap} == no ]]; then # we aren't bootstraping - declare variants='' - if [[ -r "${BUILD_BLOCK_DIR}/${V}/variants" ]]; then - variants="${BUILD_BLOCK_DIR}/${V}/variants" - elif [[ -r "${BUILD_BLOCK_DIR}/${V%.*}/variants" ]]; then - variants="${BUILD_BLOCK_DIR}/${V%.*}/variants" - elif [[ -r "${BUILD_BLOCK_DIR}/${V%.*.*}/variants" ]]; then - variants="${BUILD_BLOCK_DIR}/${V%.*.*}/variants" - fi - if [[ -n "${variants}" ]]; then - with_modules+=( $(egrep "$V\s.*${OS}" "${variants}" | - awk "${with_modules_awk_pattern} {for (i=4; i<=NF; i++) printf \$i \" \"}" | tail -1) ) - else - if [[ -r "${BUILD_BLOCK_DIR}/with_modules-$V" ]]; then - with_modules+=( $(cat "${BUILD_BLOCK_DIR}/with_modules-$V") ) - elif [[ -r "${BUILD_BLOCK_DIR}/with_modules" ]]; then - with_modules+=( $(cat "${BUILD_BLOCK_DIR}/with_modules") ) - fi - fi + #declare variants='' + #if [[ -r "${BUILD_BLOCK_DIR}/${V}/variants" ]]; then + # variants="${BUILD_BLOCK_DIR}/${V}/variants" + #elif [[ -r "${BUILD_BLOCK_DIR}/${V%.*}/variants" ]]; then + # variants="${BUILD_BLOCK_DIR}/${V%.*}/variants" + #elif [[ -r "${BUILD_BLOCK_DIR}/${V%.*.*}/variants" ]]; then + # variants="${BUILD_BLOCK_DIR}/${V%.*.*}/variants" + #fi + #if [[ -n "${variants}" ]]; then + # with_modules+=( $(egrep "$V\s.*${OS}" "${variants}" | tail -1 | + # awk "${with_modules_awk_pattern} {for (i=4; i<=NF; i++) printf \$i \" \"}") ) + #fi source "${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/profile.bash" MODULECMD="${PMODULES_HOME}/bin/modulecmd" @@ -369,14 +358,6 @@ if [[ ${bootstrap} == no ]]; then eval $( "${MODULECMD}" bash use unstable ) eval $( "${MODULECMD}" bash use deprecated ) eval $( "${MODULECMD}" bash use Libraries ) - for m in "${with_modules[@]}"; do - if pbuild::module_is_available "$m"; then - echo "Loading module: ${m}" - module load "${m}" - else - std::die 44 "$m: module not available!" - fi - done else # the module command is not yet available... pbuild::cleanup_env diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 6968005..56f3bcf 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -200,7 +200,7 @@ subcommand_help_keyword() { subcommand_help_avail() { echo " USAGE: - module avail string + module avail [switches] string List all available modulefiles in the current MODULEPATH. If an argument is given, then each directory in the MODULEPATH is searched for modulefiles whose pathname match the argument. @@ -209,6 +209,21 @@ USAGE: system. Only *loadable* modules are listed. The list of available modules may change either by loading other modules, e.g. a compiler, or with the sub-command 'use'. + +SWITCHES: + -a|--all||--all-releases + List all available modules independend of the release. + + -t|--terse + Output in short format. + + -l|--long + Output in long format. + + -h|--human + Output in human readable format. + -m|--machine + Output in machine readable format " 1>&2 std::die 1 } @@ -971,6 +986,12 @@ subcommand_avail() { std::info "" } + machine_output() { + for (( i=0; i<${#mods[@]}; i+=2 )); do + printf "%-20s\t%s\n" "${mods[i]}" "${mods[i+1]}" 1>&2 + done + } + # # :FIXME: for the time being, this is the same as terse_output! long_output() { @@ -1028,13 +1049,19 @@ subcommand_avail() { printf -- "\n\n" 1>&2 } local opts='' - opts=$(pmodules::get_options -o hlt -l human -l long -l terse -- "$@") || subcommand_help_avail + opts=$(pmodules::get_options -o ahlmt \ + -l all -l all-releases \ + -l human -l long -l machine -l terse -- "$@") || subcommand_help_avail eval set -- "${opts}" local pattern=() local output_function='' local opts='' + local use_releases="${UsedReleases}" while (($# > 0)); do case $1 in + -a | --all | --all-releases ) + use_releases="${PMODULES_DEFINED_RELEASES}" + ;; -h | --human ) [[ -z ${opts} ]] || \ std::die 1 "${CMD} list: you cannot set both options: '$1' and '${opts}'." @@ -1053,6 +1080,12 @@ subcommand_avail() { opts=$1 output_function='terse_output' ;; + -m | --machine ) + [[ -z ${opts} ]] || \ + std::die 1 "${CMD} list: you cannot set both options: '$1' and '${opts}'." + opts=$1 + output_function='machine_output' + ;; -- ) ;; * ) @@ -1071,7 +1104,7 @@ subcommand_avail() { IFS=${saved_IFS} for string in "${pattern[@]}"; do for dir in "${modulepath[@]}"; do - mods=( $( get_available_modules "${dir}" "${string}" ) ) + mods=( $( get_available_modules "${dir}" "${string}" "${use_releases}" ) ) [[ ${#mods[@]} == 0 ]] && continue ${output_function}