diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..0a791491f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +--- +name: ci + +# yamllint disable-line rule:truthy +on: + push: + pull_request: + +concurrency: + group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} + cancel-in-progress: true + +jobs: + prechecks: + uses: ./.github/workflows/pre-commit.yml + all-prechecks: + needs: [prechecks] + runs-on: ubuntu-latest + steps: + - name: Success + run: "true" diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..795bdfe38 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,18 @@ +--- +name: pre-commit + +# yamllint disable-line rule:truthy +on: + workflow_call: + +concurrency: + group: style-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} + cancel-in-progress: true + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..931a86b19 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +--- +fail_fast: false +repos: + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.5.0" + hooks: + - id: check-case-conflict + - id: check-merge-conflict + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: "v0.6.13" + hooks: + - id: cmake-format + args: [--config-files, experimental/.cmake-format.yaml] + additional_dependencies: + - pyyaml + - id: cmake-lint + additional_dependencies: + - pyyaml + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: "v12.0.1" + hooks: + - id: clang-format + types_or: [c++, c] + exclude: | + (?x)( + build/| + src/sst/core/libltdl/| + external/ + ) + - repo: https://github.com/Mateusz-Grzelinski/actionlint-py + rev: "v1.6.26.11" + hooks: + - id: actionlint diff --git a/config/sst_check_curses.m4 b/config/sst_check_curses.m4 index 01e58433a..81eb3f423 100644 --- a/config/sst_check_curses.m4 +++ b/config/sst_check_curses.m4 @@ -3,43 +3,58 @@ AC_DEFUN([SST_CHECK_CURSES], sst_check_curses_happy="yes" AC_ARG_WITH([curses], - [AS_HELP_STRING([--with-ncurses@<:@=DIR@:>@], - [Use ncurses library found in DIR])]) + [AS_HELP_STRING([--with-ncurses@<:@=DIR or EXEC@:>@], + [Use ncurses library found in DIR or associated with the ncursesN-config utility specified by EXEC])]) AS_IF([test "$with_curses" = "no"], [sst_check_curses_happy="no"]) - CPPFLAGS_saved="$CPPFLAGS" - LDFLAGS_saved="$LDFLAGS" - - dnl Use user-defined curses library - AS_IF([test "$sst_check_curses_happy" = "yes"], [ - AS_IF([test ! -z "$with_curses" -a "$with_curses" != "yes"], - [CURSES_CPPFLAGS="-I$with_curses/include" - CPPFLAGS="$CURSES_CPPFLAGS $CPPFLAGS" - CURSES_LDFLAGS="-L$with_curses/lib" - CURSES_LIBS="-lncurses", - LDFLAGS="$CURSES_LDFLAGS $LDFLAGS"], - [CURSES_CPPFLAGS= - CURSES_CPPFLAGS_LDFLAGS= - CURSES_LIBS=])]) - -dnl Check for curses.h header - AC_LANG_PUSH([C++]) - AC_CHECK_HEADER([curses.h], [], [sst_check_curses_happy="no"]) - AC_LANG_POP([C++]) - -dnl Check that library is usable -AS_IF([test "$sst_check_curses_happy" != "no"], - [AC_CHECK_LIB([ncursesw], [wprintw], [CURSES_LIBS="-lncursesw"], - [AC_CHECK_LIB([ncurses], [wprintw], [CURSES_LIBS="-lncurses"], - [AC_CHECK_LIB([curses], [wprintw], [CURSES_LIBS="-lcurses"], [sst_check_curses_happy = "no"])])]) - ]) - - CPPFLAGS="$CPPFLAGS_saved" - LDFLAGS="$LDFLAGS_saved" + NCURSES_CONFIG_EXE="no" + + dnl check if user provided a specific ncursesN-config + AS_IF([test ! -d "$with_curses"], + [AS_IF([test -x "$with_curses"], + [NCURSES_CONFIG_EXE=$with_curses])]) + + dnl test ncursesN-config + AS_IF([test $NCURSES_CONFIG_EXE = "no"], + [AS_IF([test -n "$with_curses"], + [AC_PATH_PROGS([NCURSES_CONFIG_EXE], ["ncurses6-config" "ncurses5.4-config" "ncurses5-config"], ["no"], ["$with_curses/bin"])], + [AC_PATH_PROGS([NCURSES_CONFIG_EXE], ["ncurses6-config" "ncurses5.4-config" "ncurses5-config"], ["no"])])]) + + dnl don't continue if ncursesN-config can't be found rather than look for the + dnl specific libraries + AS_IF([test $NCURSES_CONFIG_EXE = "no"], + [ + CURSES_CPPFLAGS= + CURSES_LIBS= + sst_check_curses_happy="no" + ], + [ + dnl Older versions only have --libs, not --libs-only-l and --libs-only-L, + dnl which combines the two. Ideally, CURSES_LDFLAGS (sstinfo_x_LDFLAGS) + dnl contains --libs-only-L and CURSES_LIBS (sstinfo_x_LDADD) contains + dnl --libs-only-l, but rather than complicated logic testing the above, + dnl combining everything into LDADD seems acceptable.. + CURSES_CPPFLAGS=`$NCURSES_CONFIG_EXE --cflags` + CURSES_LIBS=`$NCURSES_CONFIG_EXE --libs` + + CPPFLAGS_saved="$CPPFLAGS" + LDFLAGS_saved="$LDFLAGS" + + CPPFLAGS="$CPPFLAGS $CURSES_CPPFLAGS" + LDFLAGS="$LDFLAGS $CURSES_LIBS" + + dnl Check for specific header + AC_LANG_PUSH([C++]) + AC_CHECK_HEADER([ncurses.h], [], [sst_check_curses_happy="no"]) + AC_LANG_POP([C++]) + + CPPFLAGS="$CPPFLAGS_saved" + LDFLAGS="$LDFLAGS_saved" + ] + ) AC_SUBST([CURSES_CPPFLAGS]) - AC_SUBST([CURSES_LDFLAGS]) AC_SUBST([CURSES_LIBS]) AS_IF([test "x$sst_check_curses_happy" = "xyes"], [AC_DEFINE([HAVE_CURSES], [1], [Defines whether we have the curses library])]) AM_CONDITIONAL([USE_CURSES], [test "x$sst_check_curses_happy" = "xyes"]) diff --git a/configure.ac b/configure.ac index 496d957b3..4d2264ceb 100644 --- a/configure.ac +++ b/configure.ac @@ -65,7 +65,6 @@ SST_CHECK_MPI([], [AC_MSG_ERROR([Could not find MPI package])]) SST_CHECK_PYTHON([], [AC_MSG_ERROR([Could not find Python, this is required for SST to build])]) SST_CHECK_LIBZ([have_zlib="yes"],[have_zlib="no"],[AC_MSG_ERROR([zlib was requested but could not be found.])]) SST_CHECK_CURSES() -dnl AC_MSG_ERROR([Could not find curses, this is required for utility sst-info to build])]) SST_CHECK_BACKTRACE() SST_CHECK_HDF5() SST_CHECK_MEM_POOL() @@ -228,6 +227,7 @@ echo "Configuration Information (Dependencies):" echo "" printf "%38s : %s (%s)\n" "Found Python" "$PYTHON_EXE" "$PYTHON_VERSION" + if test "x$sst_check_hdf5_happy" = "xyes" ; then printf "%38s : Yes\n" "HDF5 Support" else @@ -240,9 +240,9 @@ else fi if test "x$sst_check_curses_happy" = "xyes" ; then - printf "%38s : Yes\n" "curses library" + printf "%38s : %s %s\n" "curses library" "$CURSES_LIBS" else - printf "%38s : No\n" "curses library" + printf "%38s : Not found\n" "curses library" fi echo "-------------------------------------------------------" diff --git a/experimental/CMakeLists.txt b/experimental/CMakeLists.txt index 3a99d7dad..46b7e6b30 100644 --- a/experimental/CMakeLists.txt +++ b/experimental/CMakeLists.txt @@ -55,6 +55,19 @@ if(NOT SST_DISABLE_ZLIB) find_package(ZLIB) endif() +option(SST_DISABLE_CURSES + "Use curses library (needed for interactive sst-info)" OFF) +if(NOT SST_DISABLE_CURSES) + # https://gitlab.kitware.com/cmake/cmake/-/issues/23236 + set(CURSES_NEED_NCURSES 1) + find_package(Curses) + if(NOT CURSES_HAVE_NCURSES_H) + message( + FATAL_ERROR + "Curses was found, but the specific header was not") + endif() +endif() + option(SST_ENABLE_HDF5 "Use HDF5 library" OFF) if(SST_ENABLE_HDF5) find_package(HDF5 REQUIRED) diff --git a/experimental/cmake/sst.cmake b/experimental/cmake/sst.cmake index 4e288e2d7..81a964a7c 100644 --- a/experimental/cmake/sst.cmake +++ b/experimental/cmake/sst.cmake @@ -42,6 +42,10 @@ if(ZLIB_FOUND) set(HAVE_LIBZ ON) endif(ZLIB_FOUND) +if(CURSES_FOUND) + set(HAVE_CURSES ON) +endif(CURSES_FOUND) + check_include_file(execinfo.h HAVE_EXECINFO_H) check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) check_include_file(mach/mach_time.h HAVE_MACH_MACH_TIME_H) diff --git a/experimental/cmake_configure_files/sst_config.h.in b/experimental/cmake_configure_files/sst_config.h.in index e9d2804c4..5ffd2c896 100644 --- a/experimental/cmake_configure_files/sst_config.h.in +++ b/experimental/cmake_configure_files/sst_config.h.in @@ -35,6 +35,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_C_ASM_H 1 +/* Defines whether we have the curses library */ +#cmakedefine HAVE_CURSES 1 + /* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if you don't. */ #cmakedefine HAVE_DECL_CYGWIN_CONV_PATH 1 diff --git a/src/sst/core/CMakeLists.txt b/src/sst/core/CMakeLists.txt index 8334557f3..ebda624d7 100644 --- a/src/sst/core/CMakeLists.txt +++ b/src/sst/core/CMakeLists.txt @@ -243,6 +243,13 @@ if(Threads_FOUND) target_link_libraries(sstsim.x PRIVATE Threads::Threads) endif() +if(CURSES_FOUND) + target_link_libraries(sstinfo.x PRIVATE ${CURSES_LIBRARIES}) + # Before means no chance of interfering with a system curses if a + # user-provided one was specified. + target_include_directories(sstinfo.x BEFORE PRIVATE ${CURSES_INCLUDE_DIRS}) +endif() + add_executable(sst bootsst.cc) target_link_libraries(sst PRIVATE sst-boot-lib sst-env-lib sst-config-lib) diff --git a/src/sst/core/Makefile.am b/src/sst/core/Makefile.am index 5e89af571..e914b2130 100644 --- a/src/sst/core/Makefile.am +++ b/src/sst/core/Makefile.am @@ -342,9 +342,8 @@ sstinfo_x_LDADD += $(LIBZ_LIBS) endif if USE_CURSES -AM_CPPFLAGS += $(CURSES_CFPPLAGS) +AM_CPPFLAGS += $(CURSES_CPPFLAGS) sstinfo_x_LDADD += $(CURSES_LIBS) -sstinfo_x_LDFLAGS += $(CURSES_LDFLAGS) endif if USE_HDF5 diff --git a/src/sst/core/main.cc b/src/sst/core/main.cc index 9c4d14b31..a2d85877d 100644 --- a/src/sst/core/main.cc +++ b/src/sst/core/main.cc @@ -14,6 +14,11 @@ #include "sst/core/warnmacros.h" DISABLE_WARN_DEPRECATED_REGISTER +// The Python header already defines this and should override one from the +// command line. +#ifdef _XOPEN_SOURCE +#undef _XOPEN_SOURCE +#endif #include REENABLE_WARNING