From e2332d6bd2d76aba18b3559e3408f7cb1f473870 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 31 Jan 2018 08:35:56 +0100 Subject: [PATCH 1/7] COMP: better handling of versioned cmake libraries - sentinel was not working properly when building user-space routines --- .../graphics/PVReaders/Allwmake | 14 +++------ bin/foamTags | 31 +++++++++++++------ .../graphics/runTimePostProcessing/Allwmake | 8 ++--- wmake/scripts/cmakeFunctions | 10 +++--- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake index cb085fd8c0..c24b4e652f 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake @@ -1,14 +1,8 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Optional unit: continue-on-error -export WM_CONTINUE_ON_ERROR=true - -# Parse arguments for library compilation -. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments - -# Source CMake functions -. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions +cd ${0%/*} || exit 1 # Run from this directory +export WM_CONTINUE_ON_ERROR=true # Optional unit +. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # Parse arguments +. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # The CMake functions # ----------------------------------------------------------------------------- diff --git a/bin/foamTags b/bin/foamTags index ec881c5eb5..973363a633 100755 --- a/bin/foamTags +++ b/bin/foamTags @@ -46,21 +46,34 @@ then exit 1 fi -for cmd in etags ctags-exuberant +unset etags +for cmd in ctags-exuberant etags do - type $cmd >/dev/null 2>&1 || { - echo "${0##*/} cannot build tag files: '$cmd' command not found" - exit 1 - } + command -v $cmd >/dev/null 2>&1 && { etags=$cmd; break; } done +[ -n "$etags" ] || { + exec 1>&2 + echo "${0##*/} cannot build tag files: no suitable command found" + echo " No ctags-exuberant" + echo " No etags" + exit 1 +} + +case "$etags" in +ctags-exuberant) + etags="$etags -e --extra=+fq --file-scope=no --c-kinds=+p -o .tags/etags -L -" + ;; +etags) + etags="$etags --declarations -l c++ -o .tags/etags -" + ;; +esac + cd $WM_PROJECT_DIR || exit 1 mkdir .tags 2>/dev/null -#etagsCmd="etags --declarations -l c++ -o .tags/etags -" -etagsCmd="ctags-exuberant -e --extra=+fq --file-scope=no --c-kinds=+p -o .tags/etags -L -" - -find -H $WM_PROJECT_DIR \( -name "*.[HC]" -o -name lnInclude -prune -o -name Doxygen -prune \) | $etagsCmd +echo "building tags..." 1>&2 +find -H $WM_PROJECT_DIR \( -name "*.[HC]" -o -name lnInclude -prune -o -name Doxygen -prune \) | $etags #gtags -i --gtagsconf bin/tools/gtagsrc .tags diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwmake b/src/functionObjects/graphics/runTimePostProcessing/Allwmake index d7d73741dc..5d1376aa35 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwmake +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwmake @@ -1,8 +1,6 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source CMake functions -. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # The CMake functions # ----------------------------------------------------------------------------- @@ -23,7 +21,7 @@ if [ -n "$depend" ] then if [ "$targetType" != objects ] then - if type cmake > /dev/null 2>&1 + if command -v cmake > /dev/null 2>&1 then cmakeVersioned "$depend" $PWD || { echo diff --git a/wmake/scripts/cmakeFunctions b/wmake/scripts/cmakeFunctions index f3fb0abb39..4c77d3d944 100644 --- a/wmake/scripts/cmakeFunctions +++ b/wmake/scripts/cmakeFunctions @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -100,11 +100,9 @@ cmakeVersioned() sentinel=$(sameDependency "$depend" "$sourceDir") || \ rm -rf "$objectsDir" > /dev/null 2>&1 - mkdir -p $objectsDir && \ - ( - cd $objectsDir && _cmake $sourceDir && make \ - && echo "$depend" > ${sentinel:-/dev/null} - ) + mkdir -p $objectsDir \ + && (cd $objectsDir && _cmake $sourceDir && make) \ + && echo "$depend" >| "${sentinel:-/dev/null}" } From e42c2281554ed6a2a54de611d86d6a0349516bbf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 8 Feb 2018 08:53:14 +0100 Subject: [PATCH 2/7] ENH: cleanup List constructors (issue #725) - add copy construct from UList - remove copy construct from dissimilar types. This templated constructor was too generous in what it accepted. For the special cases where a copy constructor is required with a change in the data type, now use the createList factory method, which accepts a unary operator. Eg, auto scalars = scalarList::createList ( labels, [](const label& val){ return 1.5*val; } ); --- applications/test/List/Test-List.C | 107 +++++++++ .../manipulation/checkMesh/checkGeometry.C | 12 +- .../moveDynamicMesh/moveDynamicMesh.C | 6 +- .../foamFormatConvert/foamFormatConvert.C | 30 ++- src/OpenFOAM/containers/Lists/List/List.C | 216 +++++++++++++----- src/OpenFOAM/containers/Lists/List/List.H | 76 ++++-- src/OpenFOAM/containers/Lists/List/ListI.H | 39 ++-- .../containers/Lists/ListOps/ListOps.C | 1 - src/OpenFOAM/db/Time/TimeIO.C | 4 +- src/OpenFOAM/primitives/ints/label/label.H | 36 ++- 10 files changed, 398 insertions(+), 129 deletions(-) diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index ec4ec9e5a1..945b0e9998 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -48,6 +48,23 @@ See also #include #include +#include + +namespace Foam +{ + +// Verify inheritance +class MyStrings +: + public List +{ +public: + + using List::List; +}; + +} // end namespace Foam + using namespace Foam; @@ -66,6 +83,14 @@ void testFind(const T& val, const ListType& lst) } +void printMyString(const UList& lst) +{ + MyStrings slist2(lst); + + Info<::createList + ( + labels, + [](const label& val){ return scalar(1.5*val); } + ); + Info<< "scalars: " << flatOutput(scalars) << endl; + } + + { + auto vectors = List::createList + ( + labels, + [](const label& val){ return vector(1.2*val, -1.2*val, 0); } + ); + Info<< "vectors: " << flatOutput(vectors) << endl; + } + + { + auto longs = List::createList + ( + labels, + [](const label& val){ return val; } + ); + Info<< "longs: " << flatOutput(longs) << endl; + } + { + auto negs = List