diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4933aa6..008b742 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -98,8 +98,6 @@ jobs: cmake -DPYBIND11_TEST=FALSE .. make -j${{ env.NARG }} install - - - name: Linux Dependencies if: startsWith(matrix.os, 'ubuntu') # Linux only run: | @@ -118,7 +116,6 @@ jobs: cd ../.. pip install "pybind11[global]" - - name: Configure CMake run: | mkdir -p build @@ -141,6 +138,14 @@ jobs: cd build Testing/RunTests + - name: Build CppRepo Example + env: + Nymph_ENABLE_TESTING: OFF + Nymph_TAG: nymph2_2/cppexample + run: | + cd Examples/CppRepo + ./BUILD_ME.sh + build_python: name: Build and Test Python @@ -190,8 +195,6 @@ jobs: cmake -DPYBIND11_TEST=FALSE .. make -j${{ env.NARG }} install - python -m pip install build - - name: Linux Dependencies if: startsWith(matrix.os, 'ubuntu') # Linux only run: | @@ -207,20 +210,48 @@ jobs: cd build sudo cmake -DPYBIND11_TEST=FALSE .. sudo make -j${{ env.NARG }} install - cd ../.. - - pip install "pybind11[global]" - - python -m pip install build - - - name: Install nymph + - name: Build Nymph/Cpp run: | - pip -v install . + mkdir -p build + cd build + cmake -DCMAKE_BUILD_TYPE=${Nymph_BUILD_TYPE} \ + -DNymph_BUILD_NYMPH_EXE=${Nymph_BUILD_NYMPH_EXE} \ + -DNymph_ENABLE_EXECUTABLES=${Nymph_ENABLE_EXECUTABLES} \ + -DNymph_ENABLE_PYTHON=${Nymph_ENABLE_PYTHON} \ + -DNymph_ENABLE_TESTING=${Nymph_ENABLE_TESTING} \ + -DNymph_SINGLETHREADED=${Nymph_SINGLETHREADED} \ + -DPBUILDER_PY_INSTALL_IN_SITELIB=TRUE \ + .. + make -j${{ env.NARG }} install + + - name: Install Nymph/Python + run: | + env + pip -v install -e . - name: Run Tests - continue-on-error: true run: | - cd Testing/Python + cd Testing/Python/Bindings python -m unittest discover -v +# eventually include these tests +# cd ../nymph +# python -m unittest discover -v + + - name: Build PyRepo Example + env: + Nymph_ENABLE_TESTING: OFF + Nymph_ENABLE_PYTHON: ON + Nymph_TAG: nymph2_2/cppexample + run: | + cd Examples/PyRepo + ./BUILD_ME.sh + hello-world + + +# For debugging + - name: Setup tmate session + if: ${{ ! success() }} + uses: mxschmitt/action-tmate@v3 + diff --git a/.gitignore b/.gitignore index df5fd5c..b0dd6e7 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,5 @@ build*/ # Python Package dist*/ Python/*.egg-info +Examples/PyRepo/*.egg-info __pycache__ diff --git a/CMakeLists.txt b/CMakeLists.txt index 91001eb..278befa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ set( PRIVATE_EXT_LIBS ) ####### # Boost (1.46 required for filesystem version 3) -list( APPEND BOOST_COMPONENTS chrono date_time filesystem system thread ) +list( APPEND BOOST_COMPONENTS chrono date_time filesystem thread ) find_package( Boost 1.46.0 REQUIRED COMPONENTS ${BOOST_COMPONENTS} ) list( APPEND PUBLIC_EXT_LIBS Boost::boost Boost::chrono Boost::date_time Boost::thread Boost::filesystem ) # make sure dynamic linking is assumed for all boost libraries diff --git a/Dockerfile b/Dockerfile index 97d12a5..54a0424 100644 --- a/Dockerfile +++ b/Dockerfile @@ -93,6 +93,7 @@ COPY Testing /tmp_source/Testing COPY CMakeLists.txt /tmp_source/CMakeLists.txt COPY NymphConfig.cmake.in /tmp_source/NymphConfig.cmake.in COPY pyproject.toml /tmp_source/pyproject.toml +COPY VERSION /tmp_source/VERSION #COPY .git /tmp_source/.git # repeat the cmake command to get the change of install prefix to set correctly (a package_builder known issue) diff --git a/Examples/CppRepo/BUILD_ME.sh b/Examples/CppRepo/BUILD_ME.sh new file mode 100755 index 0000000..eae3109 --- /dev/null +++ b/Examples/CppRepo/BUILD_ME.sh @@ -0,0 +1,20 @@ +#! /bin/bash + +# This script builds the CppRepo example of a Nymph-based C++-only package. +# The CMake-based build downloads Nymph using CMake's FetchContent module, +# rather than including it as a submodule. Nymph is built using +# the Scarab/PackageBuilder framework included with Nymph. + +mkdir build +cd build + +cmake -DCMAKE_BUILD_TYPE=${Nymph_BUILD_TYPE:=Debug} \ + -DNymph_BUILD_NYMPH_EXE=${Nymph_BUILD_NYMPH_EXE:=FALSE} \ + -DNymph_ENABLE_EXECUTABLES=${Nymph_ENABLE_EXECUTABLES:=TRUE} \ + -DNymph_ENABLE_PYTHON=${Nymph_ENABLE_PYTHON:=FALSE} \ + -DNymph_ENABLE_TESTING=${Nymph_ENABLE_TESTING:=FALSE} \ + -DNymph_SINGLETHREADED=${Nymph_SINGLETHREADED:=FALSE} \ + -DNymph_TAG=${Nymph_TAG:=nymph2_2/develop} \ + .. + +make -j${NARG:=} install diff --git a/Examples/CppRepo/CMakeLists.txt b/Examples/CppRepo/CMakeLists.txt new file mode 100644 index 0000000..9e13dd5 --- /dev/null +++ b/Examples/CppRepo/CMakeLists.txt @@ -0,0 +1,91 @@ +# Minimum cmake verison 3.12 required for Scarab +cmake_minimum_required (VERSION 3.12) + +# Define the project +cmake_policy( SET CMP0048 NEW ) # version in project() +project( CppRepo VERSION 0.0.0 ) + +include( FetchContent ) +# Get Nymph with FetchContent +# If Nymph is a submodule, then set the SOURCE_DIR option to point to it; also in that case, remove any download specifications +message( STATUS "Getting Nymph" ) +option( Nymph_TAG "Version of Nymph to use" nymph2_2/develop ) +message( "$$$$$$ tag: ${Nymph_TAG}" ) +set( Nymph_DIR nymph_src ) +FetchContent_Populate( nymph + SOURCE_DIR ${Nymph_DIR} + GIT_REPOSITORY https://github.com/project8/nymph + GIT_TAG ${Nymph_TAG} + GIT_SHALLOW TRUE +) + +# If nymph were a submodule in ${PROJECT_SOURCE_DIR}/nymph, that would be used in place of ${Nymph_DIR} +list( APPEND CMAKE_MODULE_PATH + ${CMAKE_BINARY_DIR}/${Nymph_DIR}/Scarab/cmake + ${CMAKE_BINARY_DIR}/${Nymph_DIR}/cmake +) +include( PackageBuilder ) +include( Nymph ) + +######### +# flags # +######### + +set( CMAKE_CXX_STANDARD 17 ) + + +################ +# dependencies # +################ + +set( PUBLIC_EXT_LIBS ) +set( PRIVATE_EXT_LIBS ) + + + + +##################### +# prepare for build # +##################### + +pbuilder_prepare_project() + + +############## +# submodules # +############## + +# Nymph +pbuilder_add_submodule( Nymph ${CMAKE_BINARY_DIR}/${Nymph_DIR} ) + +pbuilder_use_sm_library( Nymph Nymph ) + +##################### +# build the project # +##################### + +# add include directories +include_directories( BEFORE + Library/Processors + Library/Data +) + +# build this project +add_subdirectory( Library ) + +if( tettigoniidae_ENABLE_EXECUTABLES ) + #add_subdirectory( Executables ) +endif() + +if( tettigoniidae_ENABLE_TESTING ) + #add_subdirectory( Testing ) +endif() + + +################## +# package config # +################## + +#configure_file( ${PROJECT_SOURCE_DIR}/tettigoniidaeConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tettigoniidaeConfig.cmake @ONLY ) + +#pbuilder_do_package_config() \ No newline at end of file diff --git a/Examples/CppRepo/Library/CMakeLists.txt b/Examples/CppRepo/Library/CMakeLists.txt new file mode 100644 index 0000000..ea7dff2 --- /dev/null +++ b/Examples/CppRepo/Library/CMakeLists.txt @@ -0,0 +1,5 @@ +# CMakeLists for nymph/Examples/CppRepo/Library +# Author: N.S. Oblath + +add_subdirectory( Data ) +add_subdirectory( Processors ) diff --git a/Examples/CppRepo/Library/Data/CMakeLists.txt b/Examples/CppRepo/Library/Data/CMakeLists.txt new file mode 100644 index 0000000..c4f007f --- /dev/null +++ b/Examples/CppRepo/Library/Data/CMakeLists.txt @@ -0,0 +1,32 @@ +# CMakeLists for nymph/Examples/CppRepo/Library/Data +# Author: N.S. Oblath + +include_directories( BEFORE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set( CppRepoData_HEADERFILES + DoubleData.hh + IntData.hh +) + +set( CppRepoData_SOURCEFILES + DoubleData.cc + IntData.cc +) + + +################################################## + +pbuilder_library( + TARGET CppRepoData + SOURCES ${CppRepoData_SOURCEFILES} + PUBLIC_EXTERNAL_LIBRARIES ${PUBLIC_EXT_LIBS} +) + +pbuilder_component_install_and_export( + COMPONENT Library + LIBTARGETS CppRepoData +) + +pbuilder_install_headers( ${CppRepoData_HEADERFILES} ) diff --git a/Examples/CppRepo/Library/Data/DoubleData.cc b/Examples/CppRepo/Library/Data/DoubleData.cc new file mode 100644 index 0000000..493eb78 --- /dev/null +++ b/Examples/CppRepo/Library/Data/DoubleData.cc @@ -0,0 +1,14 @@ + +#include "DoubleData.hh" + +namespace tettigoniidae +{ + DoubleData::DoubleData() : + Nymph::Data(), + fDValue1( 0. ), + fDValue2( 10. ) + {} + + DoubleData::~DoubleData() + {} +} diff --git a/Examples/CppRepo/Library/Data/DoubleData.hh b/Examples/CppRepo/Library/Data/DoubleData.hh new file mode 100644 index 0000000..ee88e02 --- /dev/null +++ b/Examples/CppRepo/Library/Data/DoubleData.hh @@ -0,0 +1,31 @@ +/* + * TestData2.hh + * + * Created on: Jan 6, 2022 + * Author: N.S. Oblath + */ + +#ifndef TTGD_TESTING_TESTDATA2 +#define TTGD_TESTING_TESTDATA2 + +#include "Data.hh" +#include "MemberVariable.hh" + +namespace tettigoniidae +{ + + class DoubleData : public Nymph::Data + { + public: + DoubleData(); + + virtual ~DoubleData(); + + MEMVAR( double, DValue1 ); + MEMVAR( double, DValue2 ); + }; + + +} /* namespace tettigoniidae */ + +#endif /* TTGD_TESTING_TESTDATA2 */ diff --git a/Examples/CppRepo/Library/Data/IntData.cc b/Examples/CppRepo/Library/Data/IntData.cc new file mode 100644 index 0000000..8fef364 --- /dev/null +++ b/Examples/CppRepo/Library/Data/IntData.cc @@ -0,0 +1,14 @@ + +#include "IntData.hh" + +namespace tettigoniidae +{ + IntData::IntData() : + Nymph::Data(), + fIValue1( 0 ), + fIValue2( 5 ) + {} + + IntData::~IntData() + {} +} diff --git a/Examples/CppRepo/Library/Data/IntData.hh b/Examples/CppRepo/Library/Data/IntData.hh new file mode 100644 index 0000000..3cbe8ee --- /dev/null +++ b/Examples/CppRepo/Library/Data/IntData.hh @@ -0,0 +1,35 @@ +/* + * IntData.hh + * + * Created on: Jan 6, 2022 + * Author: N.S. Oblath + */ + +#ifndef TTGD_DATA_INTDATA +#define TTGD_DATA_INTDATA + +#include "Data.hh" +#include "MemberVariable.hh" + +namespace tettigoniidae +{ + + /*! + @class IntData + @author N. S. Oblath + @brief Two integer values + */ + class IntData : public Nymph::Data + { + public: + IntData(); + + virtual ~IntData(); + + MEMVAR( int, IValue1 ); + MEMVAR( int, IValue2 ); + }; + +} /* namespace tettigoniidae */ + +#endif /* TTGD_DATA_INTDATA */ diff --git a/Examples/CppRepo/Library/Processors/Adder.cc b/Examples/CppRepo/Library/Processors/Adder.cc new file mode 100644 index 0000000..9fed0ca --- /dev/null +++ b/Examples/CppRepo/Library/Processors/Adder.cc @@ -0,0 +1,35 @@ + +#include "Adder.hh" + +#include "IntData.hh" + + +REGISTER_PROCESSOR( tettigoniidae, Adder, "adder" ) + +namespace tettigoniidae +{ + Adder::Adder( const std::string& name ) : + Processor( name ), + fIntValue( 0 ), + fIntSignal( "int", this ), + fAddIntSlot( "add-int", this, &Adder::Add, &fIntSignal ) + {} + + Adder::~Adder() + {} + + void Adder::Configure( const scarab::param_node& node ) + { + fIntValue = node.get_value( "int-value", fIntValue ); + + return; + } + + void Adder::Add( IntData& data ) + { + data.SetIValue1( data.GetIValue1() + fIntValue ); + data.SetIValue2( data.GetIValue2() + fIntValue ); + return; + } + +} /* namespace tettigoniidae */ diff --git a/Examples/CppRepo/Library/Processors/Adder.hh b/Examples/CppRepo/Library/Processors/Adder.hh new file mode 100644 index 0000000..93ab1d8 --- /dev/null +++ b/Examples/CppRepo/Library/Processors/Adder.hh @@ -0,0 +1,64 @@ +/*! + * @file Adder.hh + * + * Created on: Nov 25, 2021 + * Author: N.S. Oblath + */ + +#ifndef TTGD_PROCESSORS_ADDER +#define TTGD_PROCESSORS_ADDER + +#include "Processor.hh" +#include "SignalData.hh" +#include "SlotData.hh" + +namespace tettigoniidae +{ + class IntData; + + /*! + @class Adder + @author N. S. Oblath + + @brief Adds a value to data + + @procdetails + Does addition in place + + @proctype adder + + @config + @configparam{int-value,int} Value to add to IntData + + @slots + @slot{add-int,void (DataHandle)} Adds a value to IntData; Requires IntData; Adds no data; Emits signal "int" + + @signals + @signal{int,void (DataHandle)} Emitted after adding to IntData + */ + class Adder : public Nymph::Processor + { + public: + Adder( const std::string& name = "adder" ); + + virtual ~Adder(); + + /// Processor configuration + void Configure( const scarab::param_node& node ); + + MEMVAR( int, IntValue ); + + public: + /// Add an integer to integer data + void Add( IntData& data ); + + public: + Nymph::SignalData fIntSignal; + + Nymph::SlotData< Nymph::In, Nymph::Out<> > fAddIntSlot; + + }; + +} /* namespace tettigoniidae */ + +#endif /* TTGD_PROCESSORS_ADDER */ diff --git a/Examples/CppRepo/Library/Processors/CMakeLists.txt b/Examples/CppRepo/Library/Processors/CMakeLists.txt new file mode 100644 index 0000000..1bd998c --- /dev/null +++ b/Examples/CppRepo/Library/Processors/CMakeLists.txt @@ -0,0 +1,35 @@ +# CMakeLists for nymph/Examples/CppRepo/Library/Processors +# Author: N.S. Oblath + +include_directories( BEFORE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set( CppRepo_LIBS + CppRepoData +) + +set( CppRepoProcs_HEADERFILES + Adder.hh +) + +set( CppRepoProcs_SOURCEFILES + Adder.cc +) + + +################################################## + +pbuilder_library( + TARGET CppRepoProcs + SOURCES ${CppRepoProcs_SOURCEFILES} + PUBLIC_EXTERNAL_LIBRARIES ${PUBLIC_EXT_LIBS} + PROJECT_LIBRARIES ${CppRepo_LIBS} +) + +pbuilder_component_install_and_export( + COMPONENT Library + LIBTARGETS CppRepoProcs +) + +pbuilder_install_headers( ${CppRepoProcs_HEADERFILES} ) diff --git a/Examples/PyRepo/BUILD_ME.sh b/Examples/PyRepo/BUILD_ME.sh new file mode 100755 index 0000000..6682c99 --- /dev/null +++ b/Examples/PyRepo/BUILD_ME.sh @@ -0,0 +1,35 @@ +#! /bin/bash + +# This script builds the PyRepo example of a Nymph-based Python-only package. +# We first have to build the C++ Nymph library, and then we can install the Python Nymph package. +# Finally, we install the PyRepo package. + +# This assumes that if the _nymph directory exists, then _nymph has been built and installed +if [[ ! -d _nymph ]]; then + git clone --recurse-submodules -b ${Nymph_TAG:=nymph2_2/develop} https://github.com/project8/nymph _nymph + cd _nymph + + mkdir build + cd build + + cmake -DCMAKE_BUILD_TYPE=${Nymph_BUILD_TYPE:=Debug} \ + -DNymph_BUILD_NYMPH_EXE=${Nymph_BUILD_NYMPH_EXE:=TRUE} \ + -DNymph_ENABLE_EXECUTABLES=${Nymph_ENABLE_EXECUTABLES:=TRUE} \ + -DNymph_ENABLE_PYTHON=${Nymph_ENABLE_PYTHON:=TRUE} \ + -DNymph_ENABLE_TESTING=${Nymph_ENABLE_TESTING:=FALSE} \ + -DNymph_SINGLETHREADED=${Nymph_SINGLETHREADED:=FALSE} \ + .. + + make -j${NARG:=} install + source bin/add_lib_python_path.sh + + cd .. + + pip install . + + cd .. +else + source _nymph/build/bin/add_lib_python_path.sh +fi + +pip install -e . diff --git a/Examples/PyRepo/pyproject.toml b/Examples/PyRepo/pyproject.toml new file mode 100644 index 0000000..1724f76 --- /dev/null +++ b/Examples/PyRepo/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = [ + "setuptools>=42", +] +build-backend = "setuptools.build_meta" + +[project] +name = "PyRepo" +#dependencies = [ +# "nymph_bindings @ file:///src/build-ny22py-debug-docker/lib", +#] +version = "1.0.0" + +[project.scripts] +hello-world = "pyrepo:hello_world" + +#[tool.setuptools.packages.find] +#where = ["Python"] diff --git a/Examples/PyRepo/pyrepo/__init__.py b/Examples/PyRepo/pyrepo/__init__.py new file mode 100644 index 0000000..ddd37b4 --- /dev/null +++ b/Examples/PyRepo/pyrepo/__init__.py @@ -0,0 +1,3 @@ +__all__ = [] + +from .hello_world import hello_world diff --git a/Examples/PyRepo/pyrepo/hello_world.py b/Examples/PyRepo/pyrepo/hello_world.py new file mode 100644 index 0000000..925976c --- /dev/null +++ b/Examples/PyRepo/pyrepo/hello_world.py @@ -0,0 +1,6 @@ + +def hello_world(): + print("Hello, world") + +if __name__ == "__main__": + hello_world() diff --git a/Scarab b/Scarab index e5c49f5..b899601 160000 --- a/Scarab +++ b/Scarab @@ -1 +1 @@ -Subproject commit e5c49f58bd38660ecfb13f607e1d0b021d24fc97 +Subproject commit b899601d9c5f6a81734b6bd78f3056a1bf52b708 diff --git a/Testing/Python/Bindings/testprocessortoolbox.py b/Testing/Python/Bindings/testprocessortoolbox.py index 20d51a4..c30baf9 100644 --- a/Testing/Python/Bindings/testprocessortoolbox.py +++ b/Testing/Python/Bindings/testprocessortoolbox.py @@ -7,7 +7,7 @@ """ import unittest -import nymph_bindings, _nymph_testing +import nymph_bindings #, _nymph_testing class TestDataMethods(unittest.TestCase):