From 564f06439256010b22ec7f4afa64c575f856f147 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 19 Sep 2018 11:40:20 +0200 Subject: [PATCH 1/2] added: cmake glue for adding bash tab completion for an installed product --- CMakeLists.txt | 3 ++ cmake/Modules/OpmBashCompletion.cmake | 6 +++ etc/opm_bash_completion.sh.in | 60 +++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 cmake/Modules/OpmBashCompletion.cmake create mode 100644 etc/opm_bash_completion.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f26d8d4b3..f579f9cfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,3 +161,6 @@ endif() # Install build system files install(DIRECTORY cmake DESTINATION share/opm) + +# Install tab completion skeleton +install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc) diff --git a/cmake/Modules/OpmBashCompletion.cmake b/cmake/Modules/OpmBashCompletion.cmake new file mode 100644 index 000000000..e1b86e2e6 --- /dev/null +++ b/cmake/Modules/OpmBashCompletion.cmake @@ -0,0 +1,6 @@ +# Installs bash tab completion for a product +macro(opm_add_bash_completion binary) + set(PRODUCT ${binary}) + configure_file(${OPM_MACROS_ROOT}/etc/opm_bash_completion.sh.in ${binary}_bash_completion.sh @ONLY) + install(FILES ${PROJECT_BINARY_DIR}/${binary}_bash_completion.sh DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d) +endmacro() diff --git a/etc/opm_bash_completion.sh.in b/etc/opm_bash_completion.sh.in new file mode 100644 index 000000000..6b5c67fa4 --- /dev/null +++ b/etc/opm_bash_completion.sh.in @@ -0,0 +1,60 @@ +# this snippet enables parameter completion via the tabulator key +# for bash for opm products. + +# this is a bash readline completer for the case where a binary is +# already known to be an eWoms simulator. +_ewoms_parameter_completor() +{ + if test "$COMP_WORDS" == ""; then + return 0 + fi + + cmd="${COMP_WORDS[0]}" + cur="${COMP_WORDS[COMP_CWORD]}" + fullcmd="$(which "$cmd")" + ALL_OPTS=$("$fullcmd" --help 2> /dev/null | grep '^ *--' | sed 's/ *\(--[a-zA-Z0-9\-]*\)=.*/\1=/') + ALL_OPTS=$(echo "$ALL_OPTS" | sed 's/^ *--help.*/--help/') + COMPREPLY=( $(compgen -A file -W "$ALL_OPTS" -- "${cur}") ) +} + +# this is a bash readline default completer which attempts to find out +# if a given binary is an eWoms simulation. this needs to be set as a +# default completer because the name of eWoms binaries cannot be known +# a-priori. +_ewoms_generic_parameter_completor() +{ + if test "$COMP_WORDS" == ""; then + return 0 + fi + + COMPREPLY=() + local cmd cur ALL_OPTS + cmd="${COMP_WORDS[0]}" + cur="${COMP_WORDS[COMP_CWORD]}" + + fullcmd="$(which "$cmd")" + if test -z "$fullcmd" || \ + ! test -x "$fullcmd" || \ + (! test -f "$fullcmd" && ! test -h "$fullcmd" ) || \ + ! test -r "$fullcmd" || \ + ! grep -q "Ewoms[a-zA-Z0-9]*Simulator[a-zA-Z0-0]" "$fullcmd" + then + if test -n "$DEFAULT_COMPLETION_LOADER"; then + "$DEFAULT_COMPLETION_LOADER" $@ + elif type -t _completion_loader 2>&1 > /dev/null; then + # the default DEFAULT_COMPLETION_LOADER variable has not + # been set and the _completion_loader function exists, so + # we use _completion_loader as the default completer. + _completion_loader $@ + else + return 1 + fi + + return $? + fi + + _ewoms_parameter_completor $@ + return 0 +} + +complete -o nospace -F _ewoms_parameter_completor @PRODUCT@ From e3bc8a6ad7a090da4819aeaaf1439c9df969732b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 19 Sep 2018 12:26:15 +0200 Subject: [PATCH 2/2] fixed: fail build in jenkins scripts if installation target fails --- jenkins/build-opm-module.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jenkins/build-opm-module.sh b/jenkins/build-opm-module.sh index 32fdb0d34..124b11cca 100755 --- a/jenkins/build-opm-module.sh +++ b/jenkins/build-opm-module.sh @@ -112,6 +112,7 @@ function build_module { else cmake --build . --target install fi + test $? -eq 0 || exit 3 fi }