Skip to content

Commit

Permalink
Merge Pull Request #2330 from jpkenny/sst-elements/snippet
Browse files Browse the repository at this point in the history
Automatically Merged using SST Pull Request AutoTester
PR Title: b'Added support for source code snippetting.'
PR Author: jpkenny
  • Loading branch information
sst-autotester authored Mar 11, 2024
2 parents e8f1db4 + 542e805 commit 26b18b7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
9 changes: 9 additions & 0 deletions config/sst_core_check_install.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ AC_DEFUN([SST_CORE_CHECK_INSTALL], [
SST_CONFIG_TOOL=""
SST_REGISTER_TOOL=""
SST_SNIPPETS_TOOL=""
AS_IF( [test x"$with_sst_core" = "x/bin"],
[AC_MSG_ERROR([User undefined path while using --with-sst-core], [1])],
Expand All @@ -31,6 +32,13 @@ AC_DEFUN([SST_CORE_CHECK_INSTALL], [
[AC_MSG_RESULT([found $SST_REGISTER_TOOL])],
[AC_MSG_ERROR([Unable to find sst-register in $with_sst_core], [1])])
AC_PATH_PROG([SST_SNIPPETS_TOOL], [sst-snippets.py], [], [$with_sst_core])
AC_MSG_CHECKING([for sst-snippets.py tool available])
AS_IF([test -x "$SST_SNIPPETS_TOOL"],
[AC_MSG_RESULT([found $SST_SNIPPETS_TOOL])],
[AC_MSG_ERROR([Unable to find sst-snippets.py in $with_sst_core], [1])])
SST_CC=`$SST_CONFIG_TOOL --CC`
SST_CXX=`$SST_CONFIG_TOOL --CXX`
SST_MPICC=`$SST_CONFIG_TOOL --MPICC`
Expand Down Expand Up @@ -65,6 +73,7 @@ AC_DEFUN([SST_CORE_CHECK_INSTALL], [
AC_SUBST([SST_CONFIG_TOOL])
AC_SUBST([SST_REGISTER_TOOL])
AC_SUBST([SST_SNIPPETS_TOOL])
AC_SUBST([SST_PREFIX])
AM_CONDITIONAL([SST_ENABLE_PREVIEW_BUILD], [test "x$SST_PREVIEW_BUILD" = "xyes"])
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ AS_IF([test "x$use_picky" = "xyes"],
AM_CFLAGS="$AM_CFLAGS $WARNFLAGS"
AM_CXXFLAGS="$AM_CXXFLAGS $WARNFLAGS"

AM_EXTRA_RECURSIVE_TARGETS([snippets])

AC_MSG_CHECKING([for SST-Elements Git Branch, Head SHA and Commit Count])
if test -d ".git" ; then
SSTELEMENTS_GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
Expand Down
7 changes: 5 additions & 2 deletions src/sst/elements/simpleElementExample/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ install-exec-hook:
$(SST_REGISTER_TOOL) SST_ELEMENT_SOURCE simpleElementExample=$(abs_srcdir)
$(SST_REGISTER_TOOL) SST_ELEMENT_TESTS simpleElementExample=$(abs_srcdir)/tests

.PHONY: snippets
snippets:
$(SST_SNIPPETS_TOOL) $(abs_srcdir)/sst-snippets.json



clean-local:
-rm -rf snippets
13 changes: 12 additions & 1 deletion src/sst/elements/simpleElementExample/basicSimLifeCycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@
* - Use of printStatus() and emergencyShutdown()
*/

// SSTSnippet::component-header::start
#include <sst/core/component.h>
#include <sst/core/link.h>


// SSTSnippet::component-header::pause
namespace SST {
namespace simpleElementExample {


// Components inherit from SST::Component
// SSTSnippet::component-header::start
class basicSimLifeCycle : public SST::Component
{
public:
// SSTSnippet::component-header::pause

/*
* SST Registration macros register Components with the SST Core and
Expand Down Expand Up @@ -105,11 +108,15 @@ class basicSimLifeCycle : public SST::Component
// Class members

// Constructor. Components receive a unique ID and the set of parameters that were assigned in the Python input.
// SSTSnippet::component-header::start
basicSimLifeCycle(SST::ComponentId_t id, SST::Params& params);
// SSTSnippet::component-header::pause

// Destructor
// SSTSnippet::component-header::start
virtual ~basicSimLifeCycle();

// SSTSnippet::component-header::pause
// Called by SST during SST's init() lifecycle phase
virtual void init(unsigned phase) override;

Expand All @@ -132,10 +139,13 @@ class basicSimLifeCycle : public SST::Component
void handleEvent(SST::Event *ev);


// SSTSnippet::component-header::start
private:
// Parameters
unsigned eventsToSend;
// SSTSnippet::component-header::pause
bool verbose;
// SSTSnippet::component-header::start

// Component state
unsigned eventsReceived; // Number of events we've received
Expand All @@ -154,6 +164,7 @@ class basicSimLifeCycle : public SST::Component
SST::Link* leftLink;
SST::Link* rightLink;
};
// SSTSnippet::component-header::end

} // namespace simpleElementExample
} // namespace SST
Expand Down
6 changes: 6 additions & 0 deletions src/sst/elements/simpleElementExample/sst-snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ "snippets" : {
"component-header" : {
"file" : "basicSimLifeCycle.h"
}
}
}

0 comments on commit 26b18b7

Please sign in to comment.