From 311a73f1160df24b3f2300fce701bb6ec6f9c416 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 26 Jan 2024 10:14:29 +0000 Subject: [PATCH 1/3] Replace `mpark.variant` with `std::variant` --- .gitmodules | 3 -- CMakeLists.txt | 5 +--- bin/bout-config.in | 1 - bout++Config.cmake.in | 11 ------- cmake/SetupBOUTThirdParty.cmake | 20 ------------- externalpackages/mpark.variant | 1 - include/bout/sys/variant.hxx | 30 ++++---------------- manual/sphinx/conf.py | 4 --- manual/sphinx/user_docs/advanced_install.rst | 20 ------------- manual/sphinx/user_docs/installing.rst | 18 ++++++------ tools/pylib/_boutpp_build/backend.py | 2 +- tools/pylib/boutconfig/__init__.py.cin | 3 -- tools/pylib/boutconfig/__init__.py.in | 1 - 13 files changed, 16 insertions(+), 103 deletions(-) delete mode 160000 externalpackages/mpark.variant diff --git a/.gitmodules b/.gitmodules index 436e03dd4d..5ac473fe8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "externalpackages/git-archive-all.sh"] path = externalpackages/git-archive-all.sh url = https://github.com/meitar/git-archive-all.sh/ -[submodule "mpark.variant"] - path = externalpackages/mpark.variant - url = https://github.com/mpark/variant.git [submodule "externalpackages/fmt"] path = externalpackages/fmt url = https://github.com/fmtlib/fmt.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 88b31e8553..ba9ead45f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -814,10 +814,7 @@ string(REPLACE "${CMAKE_BINARY_DIR}/lib" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" CONFIG_LDFLAGS "${CONFIG_LDFLAGS}") set(BOUT_LIB_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -# Update mpark.variant and fmt include paths if we're building them -if (NOT BOUT_USE_SYSTEM_MPARK_VARIANT) - set(MPARK_VARIANT_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") -endif() +# Update fmt include paths if we're building it if (NOT BOUT_USE_SYSTEM_FMT) set(FMT_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") endif() diff --git a/bin/bout-config.in b/bin/bout-config.in index a9045fff39..3a8b70352b 100755 --- a/bin/bout-config.in +++ b/bin/bout-config.in @@ -12,7 +12,6 @@ BOUT_LIB_PATH=@BOUT_LIB_PATH@ BOUT_INCLUDE_PATH=@BOUT_INCLUDE_PATH@ -MPARK_VARIANT_INCLUDE_PATH=@MPARK_VARIANT_INCLUDE_PATH@ FMT_INCLUDE_PATH=@FMT_INCLUDE_PATH@ BOUT_CONFIG_FILE=@PREFIX@/make.config diff --git a/bout++Config.cmake.in b/bout++Config.cmake.in index 3d824e455f..3604d70dae 100644 --- a/bout++Config.cmake.in +++ b/bout++Config.cmake.in @@ -37,9 +37,6 @@ if(NOT "@ISINSTALLED@") if(EXISTS "@CMAKE_BINARY_DIR@/externalpackages/fmt") list(APPEND CMAKE_PREFIX_PATH "@CMAKE_BINARY_DIR@/externalpackages/fmt") endif() - if(EXISTS "@CMAKE_BINARY_DIR@/externalpackages/mpark.variant") - list(APPEND CMAKE_PREFIX_PATH "@CMAKE_BINARY_DIR@/externalpackages/mpark.variant") - endif() if(EXISTS "@CMAKE_BINARY_DIR@/externalpackages/PVODE") list(APPEND CMAKE_PREFIX_PATH "@CMAKE_BINARY_DIR@/externalpackages/PVODE") endif() @@ -104,13 +101,6 @@ if(EXISTS "@Libuuid_ROOT@") set(Libuuid_ROOT "@Libuuid_ROOT@") endif() -if(@BOUT_USE_SYSTEM_MPARK_VARIANT@) - set(mpark_variant_ROOT "@mpark_variant_ROOT@") -else() - # mpark.variant doesn't use GNUInstallDirs, always installs to lib - set(mpark_variant_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/mpark_variant") -endif() - if(@BOUT_USE_SYSTEM_FMT@) set(fmt_ROOT "@fmt_ROOT@") endif() @@ -147,7 +137,6 @@ if (BOUT_HAS_GETTEXT) find_dependency(Gettext @Gettext_VERSION@) find_dependency(Intl @Intl_VERSION@) endif() -find_dependency(mpark_variant @mpark_variant_VERSION@) find_dependency(fmt @fmt_VERSION@) if (BOUT_HAS_SLEPC) find_dependency(SLEPc @SLEPC_VERSION@) diff --git a/cmake/SetupBOUTThirdParty.cmake b/cmake/SetupBOUTThirdParty.cmake index e1d6f00cb4..04cd090a47 100644 --- a/cmake/SetupBOUTThirdParty.cmake +++ b/cmake/SetupBOUTThirdParty.cmake @@ -90,26 +90,6 @@ endif() message(STATUS "PETSc support: ${BOUT_USE_PETSC}") set(BOUT_HAS_PETSC ${BOUT_USE_PETSC}) - -cmake_dependent_option(BOUT_USE_SYSTEM_MPARK_VARIANT "Use external installation of mpark.variant" OFF - "BOUT_UPDATE_GIT_SUBMODULE OR EXISTS ${PROJECT_SOURCE_DIR}/externalpackages/mpark.variant/CMakeLists.txt" ON) - -if(BOUT_USE_SYSTEM_MPARK_VARIANT) - message(STATUS "Using external mpark.variant") - find_package(mpark_variant REQUIRED) - get_target_property(MPARK_VARIANT_INCLUDE_PATH mpark_variant INTERFACE_INCLUDE_DIRECTORIES) -else() - message(STATUS "Using mpark.variant submodule") - bout_update_submodules() - add_subdirectory(externalpackages/mpark.variant) - if(NOT TARGET mpark_variant) - message(FATAL_ERROR "mpark_variant not found! Have you disabled the git submodules (BOUT_UPDATE_GIT_SUBMODULE)?") - endif() - set(MPARK_VARIANT_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externalpackages/mpark.variant/include") - set(CONFIG_CFLAGS "${CONFIG_CFLAGS} -I\${MPARK_VARIANT_INCLUDE_PATH}") -endif() -target_link_libraries(bout++ PUBLIC mpark_variant) - cmake_dependent_option(BOUT_USE_SYSTEM_FMT "Use external installation of fmt" OFF "BOUT_UPDATE_GIT_SUBMODULE OR EXISTS ${PROJECT_SOURCE_DIR}/externalpackages/fmt/CMakeLists.txt" ON) diff --git a/externalpackages/mpark.variant b/externalpackages/mpark.variant deleted file mode 160000 index 23cb94f027..0000000000 --- a/externalpackages/mpark.variant +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 23cb94f027d4ef33bf48133acc2695c7e5c6f1e7 diff --git a/include/bout/sys/variant.hxx b/include/bout/sys/variant.hxx index f47d67e229..e717621819 100644 --- a/include/bout/sys/variant.hxx +++ b/include/bout/sys/variant.hxx @@ -18,10 +18,7 @@ #ifndef __VARIANT_HXX__ #define __VARIANT_HXX__ -// std::variant added in C++17 -//#include - -#include "mpark/variant.hpp" +#include #include "bout/utils.hxx" @@ -30,16 +27,10 @@ namespace utils { /// Import variant, visit into bout::utils namespace -// From C++17 -// using std::variant; -// using std::visit; -// using std::holds_alternative; -// using std::get; - -using mpark::get; -using mpark::holds_alternative; -using mpark::variant; -using mpark::visit; +using std::variant; +using std::visit; +using std::holds_alternative; +using std::get; //////////////////////////////////////////////////////////// // Variant comparison @@ -73,15 +64,6 @@ struct IsEqual { } }; -/// Backport of std::disjunction -template -struct disjunction : std::false_type {}; -template -struct disjunction : B1 {}; -template -struct disjunction - : std::conditional_t> {}; - } // namespace details template @@ -90,7 +72,7 @@ struct isVariantMember; /// Is type `T` a member of variant `variant`? template struct isVariantMember> - : public details::disjunction...> {}; + : public std::disjunction...> {}; /// Return true only if the given variant \p v /// has the same type and value as \p t diff --git a/manual/sphinx/conf.py b/manual/sphinx/conf.py index 29c0985841..e8e9210f2f 100755 --- a/manual/sphinx/conf.py +++ b/manual/sphinx/conf.py @@ -76,9 +76,6 @@ def __getattr__(cls, name): pydir = "/".join(python.split("/")[:-2]) os.system("which clang-format") os.system("which clang-format-6.0") - os.system( - "git submodule update --init --recursive ../../externalpackages/mpark.variant" - ) pwd = "/".join(os.getcwd().split("/")[:-2]) os.system("git submodule update --init --recursive ../../externalpackages/fmt") cmake = ( @@ -89,7 +86,6 @@ def __getattr__(cls, name): + " -DBOUT_TESTS=OFF" + " -DBOUT_ALLOW_INSOURCE_BUILD=ON" + f" -DPython_ROOT_DIR={pydir}" - + f" -Dmpark_variant_DIR={pwd}/externalpackages/mpark.variant/" + f" -Dfmt_DIR={pwd}/externalpackages/fmt/" ) # os.system("mkdir ../../build") diff --git a/manual/sphinx/user_docs/advanced_install.rst b/manual/sphinx/user_docs/advanced_install.rst index e25be12b4b..d0fb90d1f2 100644 --- a/manual/sphinx/user_docs/advanced_install.rst +++ b/manual/sphinx/user_docs/advanced_install.rst @@ -698,26 +698,6 @@ to typedef long CVODEINT; -Compiling with IBM xlC compiler fails -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -When using the ``xlC`` compiler, an error may occur:: - - variant.hpp(1568) parameter pack "Ts" was referenced but not expanded - - -The workaround is to change line 428 of ``externalpackages/mpark.variant/include/mpark/lib.hpp`` from:: - - #ifdef MPARK_TYPE_PACK_ELEMENT - -to:: - - #ifdef CAUSES_ERROR // MPARK_TYPE_PACK_ELEMENT - -This will force an alternate implementation of type_pack_element to be defined. -See also https://software.intel.com/en-us/forums/intel-c-compiler/topic/501502 - - Compiling fails after changing branch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/manual/sphinx/user_docs/installing.rst b/manual/sphinx/user_docs/installing.rst index eb155909bf..c7c2c7ff8c 100644 --- a/manual/sphinx/user_docs/installing.rst +++ b/manual/sphinx/user_docs/installing.rst @@ -380,16 +380,14 @@ to read and write this high-performance parallel file format. Bundled Dependencies ~~~~~~~~~~~~~~~~~~~~ -BOUT++ bundles some dependencies, currently `mpark.variant -`_, `fmt `_ and -`googletest `_. If you wish to -use an existing installation of ``mpark.variant``, you can set -``-DBOUT_USE_SYSTEM_MPARK_VARIANT=ON``, and supply the installation -path using ``mpark_variant_ROOT`` via the command line or environment -variable if it is installed in a non standard loction. Similarly for -``fmt``, using ``-DBOUT_USE_SYSTEM_FMT=ON`` and ``fmt_ROOT`` -respectively. To turn off both, you can set -``-DBOUT_USE_GIT_SUBMODULE=OFF``. +BOUT++ bundles some dependencies, currently `fmt `_ +and `googletest `_. If you wish +to use an existing installation of ``fmt``, you can set +``-DBOUT_USE_SYSTEM_FMT=ON``, and supply the installation path using +``fmt_ROOT`` via the command line or environment variable if it is +installed in a non standard location. It's also possible to turn off +all bundled dependencies with ``-DBOUT_USE_GIT_SUBMODULE=OFF`` +(currently this just affects ``fmt``). The recommended way to use ``googletest`` is to compile it at the same time as your project, therefore there is no option to use an external diff --git a/tools/pylib/_boutpp_build/backend.py b/tools/pylib/_boutpp_build/backend.py index 15dbc84e31..78da6e133b 100644 --- a/tools/pylib/_boutpp_build/backend.py +++ b/tools/pylib/_boutpp_build/backend.py @@ -174,7 +174,7 @@ def build_sdist(sdist_directory, config_settings=None): print(config_settings, sdist_directory) enable_gz = True enable_xz = False - external = {"fmt", "mpark.variant"} + external = {"fmt",} if config_settings is not None: global useLocalVersion, pkgname for k, v in config_settings.items(): diff --git a/tools/pylib/boutconfig/__init__.py.cin b/tools/pylib/boutconfig/__init__.py.cin index d031d599b5..385248c6d6 100644 --- a/tools/pylib/boutconfig/__init__.py.cin +++ b/tools/pylib/boutconfig/__init__.py.cin @@ -38,9 +38,6 @@ for k, v in config.items(): v.replace( "${BOUT_INCLUDE_PATH}", "@BOUT_INCLUDE_PATH@" ) - .replace( - "${MPARK_VARIANT_INCLUDE_PATH}", "@MPARK_VARIANT_INCLUDE_PATH@" - ) .replace( "${FMT_INCLUDE_PATH}", "@FMT_INCLUDE_PATH@" ) diff --git a/tools/pylib/boutconfig/__init__.py.in b/tools/pylib/boutconfig/__init__.py.in index db8a529b20..06a57d8714 100644 --- a/tools/pylib/boutconfig/__init__.py.in +++ b/tools/pylib/boutconfig/__init__.py.in @@ -7,7 +7,6 @@ _yesno = {'"yes"': True, '"no"': False, "yes": True, "no": False} _vars = dict( BOUT_LIB_PATH="@BOUT_LIB_PATH@", BOUT_INCLUDE_PATH="@BOUT_INCLUDE_PATH@", - MPARK_VARIANT_INCLUDE_PATH="@MPARK_VARIANT_INCLUDE_PATH@", FMT_INCLUDE_PATH="@FMT_INCLUDE_PATH@", BOUT_CONFIG_FILE="@PREFIX@/make.config", ) From 7e3a33bcd7da8aac73ad6fe3aa8df83dab4cea45 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Fri, 26 Jan 2024 10:31:45 +0000 Subject: [PATCH 2/3] Apply black changes --- tests/MMS/diffusion2/runtest | 2 +- tools/pylib/_boutpp_build/backend.py | 4 +++- tools/tokamak_grids/all/grid2bout.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/MMS/diffusion2/runtest b/tests/MMS/diffusion2/runtest index d915018d8d..6039c6faa6 100755 --- a/tests/MMS/diffusion2/runtest +++ b/tests/MMS/diffusion2/runtest @@ -27,7 +27,7 @@ build_and_log("MMS diffusion test") inputs = [ ("X", ["mesh:nx"]), ("Y", ["mesh:ny"]), - ("Z", ["MZ"]) # , + ("Z", ["MZ"]), # , # ("XYZ", ["mesh:nx", "mesh:ny", "MZ"]) ] diff --git a/tools/pylib/_boutpp_build/backend.py b/tools/pylib/_boutpp_build/backend.py index 78da6e133b..2d631743a4 100644 --- a/tools/pylib/_boutpp_build/backend.py +++ b/tools/pylib/_boutpp_build/backend.py @@ -174,7 +174,9 @@ def build_sdist(sdist_directory, config_settings=None): print(config_settings, sdist_directory) enable_gz = True enable_xz = False - external = {"fmt",} + external = { + "fmt", + } if config_settings is not None: global useLocalVersion, pkgname for k, v in config_settings.items(): diff --git a/tools/tokamak_grids/all/grid2bout.py b/tools/tokamak_grids/all/grid2bout.py index da62a37aeb..6520e8f116 100644 --- a/tools/tokamak_grids/all/grid2bout.py +++ b/tools/tokamak_grids/all/grid2bout.py @@ -3,6 +3,7 @@ """ + from __future__ import print_function from numpy import max From 09e1b4c579c22919562141693e47c9d9fdbc6388 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Fri, 26 Jan 2024 10:32:28 +0000 Subject: [PATCH 3/3] Apply clang-format changes --- include/bout/sys/variant.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/bout/sys/variant.hxx b/include/bout/sys/variant.hxx index e717621819..cee8bd332c 100644 --- a/include/bout/sys/variant.hxx +++ b/include/bout/sys/variant.hxx @@ -27,10 +27,10 @@ namespace utils { /// Import variant, visit into bout::utils namespace +using std::get; +using std::holds_alternative; using std::variant; using std::visit; -using std::holds_alternative; -using std::get; //////////////////////////////////////////////////////////// // Variant comparison @@ -72,7 +72,7 @@ struct isVariantMember; /// Is type `T` a member of variant `variant`? template struct isVariantMember> - : public std::disjunction...> {}; + : public std::disjunction...> {}; /// Return true only if the given variant \p v /// has the same type and value as \p t