diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..356c394 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +name: CI + +on: + push: + pull_request: + release: + types: + - created + workflow_dispatch: + +jobs: + ubuntu_test: + strategy: + matrix: + runs-on: [ubuntu-20.04, ubuntu-22.04] + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v3 + - name: apt + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake python3-pip python3-setuptools python3-wheel + - name: pip + run: | + python3 -m pip install --upgrade pip + python3 -m pip install --user git+https://github.com/johnwason/drekar-launch-process.git + python3 -m pip install --user git+https://github.com/johnwason/drekar-launch.git + - name: configure + run: | + mkdir build + cd build + cmake -DBUILD_TESTING=ON .. + - name: build + run: | + cd build + cmake --build . + - name: test + run: | + python3 -m drekar_launch --config=test/drekar-launch/drekar-launch.yaml + windows_test: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: pip + run: | + python -m pip install --user git+https://github.com/johnwason/drekar-launch-process.git + python -m pip install --user git+https://github.com/johnwason/drekar-launch.git + - name: configure + run: | + mkdir build + cd build + cmake -G Ninja -DBUILD_TESTING=ON .. + - name: build + run: | + cd build + cmake --build . + - name: test + run: | + python -m drekar_launch --config=test/drekar-launch/drekar-launch.yaml + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ccc24a..f202fe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.3) FILE (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/package.xml" lib_version1 REGEX "[0-9]+\\.[0-9]+\\.[0-9]+") IF ("${lib_version1}" STREQUAL "" ) -MESSAGE(FATAL_ERROR "Could not read simple-laurch-process-cpp version.") +MESSAGE(FATAL_ERROR "Could not read drekar-launch-process-cpp version.") ENDIF() STRING (REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)" "\\1" lib_version2 ${lib_version1}) STRING (STRIP ${lib_version2} lib_version) -MESSAGE(STATUS "simple-laurch-process-cpp version: ${lib_version}") +MESSAGE(STATUS "drekar-launch-process-cpp version: ${lib_version}") -project(simple-launch-process-cpp VERSION ${lib_version} LANGUAGES CXX) +project(drekar-launch-process-cpp VERSION ${lib_version} LANGUAGES CXX) set (CMAKE_CXX_STANDARD 11) @@ -16,9 +16,9 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON) if (WIN32) add_definitions(-D_WIN32_WINNT=0x0601) - set(SRCS src/simple_launch_process_cpp_win32.cpp) + set(SRCS src/drekar_launch_process_cpp_win32.cpp) else() - set(SRCS src/simple_launch_process_cpp_posix.cpp) + set(SRCS src/drekar_launch_process_cpp_posix.cpp) endif() add_library(${PROJECT_NAME} ${SRCS}) @@ -47,8 +47,8 @@ install(EXPORT ${PROJECT_NAME}-targets DESTINATION "${CONFIG_EXPORT_DIR}") configure_package_config_file( - "${PROJECT_SOURCE_DIR}/cmake/simple-launch-process-cpp-config.cmake.in" - "${PROJECT_BINARY_DIR}/simple-launch-process-cpp-config.cmake" + "${PROJECT_SOURCE_DIR}/cmake/drekar-launch-process-cpp-config.cmake.in" + "${PROJECT_BINARY_DIR}/drekar-launch-process-cpp-config.cmake" INSTALL_DESTINATION "${CONFIG_EXPORT_DIR}" PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR CONFIG_EXPORT_DIR BUILD_SHARED_LIBS) unset(EXPORT_TARGETS) @@ -66,9 +66,9 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-version.cmake # include(CTest) if (BUILD_TESTING) - add_executable(${PROJECT_NAME}_wait_exit_test test/test_simple_launch_process_cpp_wait_exit.cpp) + add_executable(${PROJECT_NAME}_wait_exit_test test/test_drekar_launch_process_cpp_wait_exit.cpp) target_link_libraries(${PROJECT_NAME}_wait_exit_test ${PROJECT_NAME}) - add_executable(${PROJECT_NAME}_callback_exit_test test/test_simple_launch_process_cpp_callback_exit.cpp) + add_executable(${PROJECT_NAME}_callback_exit_test test/test_drekar_launch_process_cpp_callback_exit.cpp) target_link_libraries(${PROJECT_NAME}_callback_exit_test ${PROJECT_NAME}) endif() \ No newline at end of file diff --git a/README.md b/README.md index 25d9f89..96dae9a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# Simple Launch Process C++ +# Drekar Launch Process C++ -This library contains client utility functions for processes launched using `simple-launch`, although they may also be used without `simple-launch`. Currently this package provides a reliable way for processes to receive shutdown signals from a process manager or the user using `ctrl-c`. This package contains -C++ implementations, analogous to `simple-launch-process` for Python. See https://github.com/johnwason/simple-launch-process for more information. +This library contains client utility functions for processes launched using `drekar-launch`, although they may also be used without `drekar-launch`. Currently this package provides a reliable way for processes to receive shutdown signals from a process manager or the user using `ctrl-c`. This package contains +C++ implementations, analogous to `drekar-launch-process` for Python. See https://github.com/johnwason/drekar-launch-process for more information. ## Building Use cmake to build the library. ``` -git clone https://github.com/johnwason/simple-launch-process-process-cpp +git clone https://github.com/johnwason/drekar-launch-process-process-cpp mkdir build cd build cmake .. @@ -21,7 +21,7 @@ Alternatively build using vcpkg: git clone https://github.com/microsoft/vcpkg.git cd vcpkg git clone https://github.com/robotraconteur/vcpkg-robotraconteur.git -vcpkg --overlay-ports=vcpkg-robotraconteur\ports install simple-launch-process-cpp:x64-windows +vcpkg --overlay-ports=vcpkg-robotraconteur\ports install drekar-launch-process-cpp:x64-windows ``` ## Usage @@ -33,12 +33,12 @@ trigger a callback when the exit signal is received. Blocking example: ```cpp -#include "simple_launch_process_cpp/simple_launch_process_cpp.h" +#include "drekar_launch_process_cpp/drekar_launch_process_cpp.h" #include int main() { - simple_launch_process_cpp::CWaitForExit wait_for_exit; + drekar_launch_process_cpp::CWaitForExit wait_for_exit; std::cout << "Press Ctrl+C to exit" << std::endl; wait_for_exit.WaitForExit(); std::cout << "Exit" << std::endl; @@ -49,7 +49,7 @@ int main() Callback example: ```cpp -#include "simple_launch_process_cpp/simple_launch_process_cpp.h" +#include "drekar_launch_process_cpp/drekar_launch_process_cpp.h" #include #include #include @@ -67,7 +67,7 @@ void exit_callback() int main() { - simple_launch_process_cpp::CWaitForExit wait_for_exit; + drekar_launch_process_cpp::CWaitForExit wait_for_exit; wait_for_exit.CallbackWaitForExit(exit_callback); std::unique_lock lock(cv_mutex); std::cout << "Press Ctrl+C to exit" << std::endl; diff --git a/cmake/drekar-launch-process-cpp-config.cmake.in b/cmake/drekar-launch-process-cpp-config.cmake.in new file mode 100644 index 0000000..9d2e7e6 --- /dev/null +++ b/cmake/drekar-launch-process-cpp-config.cmake.in @@ -0,0 +1,22 @@ +# - Config file for the drekar-launch-process-cpp package +# It defines the following variables +# DREKAR_LAUNCH_PROCESS_CPP_INCLUDE_DIR - include directory +# DREKAR_LAUNCH_PROCESS_CPP_LIBRARY_DIR - directory containing libraries +# DREKAR_LAUNCH_PROCESS_CPP_SHARED_LIBS_BUILT - whether we have built shared libraries or not +# DREKAR_LAUNCH_PROCESS_CPP_LIBRARIES - libraries to link against + +@PACKAGE_INIT@ + +set_and_check(DREKAR_LAUNCH_PROCESS_CPP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(DREKAR_LAUNCH_PROCESS_CPP_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") + +# Are we building shared libraries? +set(DREKAR_LAUNCH_PROCESS_CPP_SHARED_LIBS_BUILT "@PACKAGE_BUILD_SHARED_LIBS@") + +# Our library dependencies (contains definitions for IMPORTED targets) +include(${CMAKE_CURRENT_LIST_DIR}/drekar-launch-process-cpp-targets.cmake) + +# These are IMPORTED targets created by drekar-launch-process-cpp-targets.cmake +set(DREKAR_LAUNCH_PROCESS_CPP_LIBRARIES "drekar-launch-process-cpp") + +check_required_components(drekar-launch-process-cpp) \ No newline at end of file diff --git a/cmake/simple-launch-process-cpp-config.cmake.in b/cmake/simple-launch-process-cpp-config.cmake.in deleted file mode 100644 index 6a24576..0000000 --- a/cmake/simple-launch-process-cpp-config.cmake.in +++ /dev/null @@ -1,22 +0,0 @@ -# - Config file for the simple-launch-process-cpp package -# It defines the following variables -# SIMPLE_LAUNCH_PROCESS_CPP_INCLUDE_DIR - include directory -# SIMPLE_LAUNCH_PROCESS_CPP_LIBRARY_DIR - directory containing libraries -# SIMPLE_LAUNCH_PROCESS_CPP_SHARED_LIBS_BUILT - whether we have built shared libraries or not -# SIMPLE_LAUNCH_PROCESS_CPP_LIBRARIES - libraries to link against - -@PACKAGE_INIT@ - -set_and_check(SIMPLE_LAUNCH_PROCESS_CPP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") -set_and_check(SIMPLE_LAUNCH_PROCESS_CPP_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") - -# Are we building shared libraries? -set(SIMPLE_LAUNCH_PROCESS_CPP_SHARED_LIBS_BUILT "@PACKAGE_BUILD_SHARED_LIBS@") - -# Our library dependencies (contains definitions for IMPORTED targets) -include(${CMAKE_CURRENT_LIST_DIR}/simple-launch-process-cpp-targets.cmake) - -# These are IMPORTED targets created by simple-launch-process-cpp-targets.cmake -set(SIMPLE_LAUNCH_PROCESS_CPP_LIBRARIES "simple-launch-process-cpp") - -check_required_components(simple-launch-process-cpp) \ No newline at end of file diff --git a/include/simple_launch_process_cpp/simple_launch_process_cpp.h b/include/drekar_launch_process_cpp/drekar_launch_process_cpp.h similarity index 64% rename from include/simple_launch_process_cpp/simple_launch_process_cpp.h rename to include/drekar_launch_process_cpp/drekar_launch_process_cpp.h index 17352e5..6bd0f4e 100644 --- a/include/simple_launch_process_cpp/simple_launch_process_cpp.h +++ b/include/drekar_launch_process_cpp/drekar_launch_process_cpp.h @@ -1,10 +1,10 @@ -#ifndef SIMPLE_LAUNCH_PROCESS_CPP_H -#define SIMPLE_LAUNCH_PROCESS_CPP_H +#ifndef DREKAR_LAUNCH_PROCESS_CPP_H +#define DREKAR_LAUNCH_PROCESS_CPP_H #pragma once -namespace simple_launch_process_cpp +namespace drekar_launch_process_cpp { namespace detail { @@ -22,4 +22,4 @@ namespace simple_launch_process_cpp }; } -#endif // SIMPLE_LAUNCH_PROCESS_CPP_H \ No newline at end of file +#endif // DREKAR_LAUNCH_PROCESS_CPP_H \ No newline at end of file diff --git a/package.xml b/package.xml index f380a3e..477facd 100644 --- a/package.xml +++ b/package.xml @@ -1,14 +1,14 @@ - simple_launch_process_cpp + drekar_launch_process_cpp 0.1.0 - C++ client for the simple-launch orchestractor + C++ client for the drekar-launch orchestractor John Wason Apache 2.0 - https://github.com/johnwason/simple-launch-process-cpp + https://github.com/johnwason/drekar-launch-process-cpp John Wason diff --git a/src/simple_launch_process_cpp_posix.cpp b/src/drekar_launch_process_cpp_posix.cpp similarity index 91% rename from src/simple_launch_process_cpp_posix.cpp rename to src/drekar_launch_process_cpp_posix.cpp index d012b88..f85ebd3 100644 --- a/src/simple_launch_process_cpp_posix.cpp +++ b/src/drekar_launch_process_cpp_posix.cpp @@ -1,10 +1,10 @@ #include #include -#include "simple_launch_process_cpp/simple_launch_process_cpp.h" +#include "drekar_launch_process_cpp/drekar_launch_process_cpp.h" #include #include -namespace simple_launch_process_cpp +namespace drekar_launch_process_cpp { namespace detail { diff --git a/src/simple_launch_process_cpp_win32.cpp b/src/drekar_launch_process_cpp_win32.cpp similarity index 91% rename from src/simple_launch_process_cpp_win32.cpp rename to src/drekar_launch_process_cpp_win32.cpp index 4d38fb0..d744ca2 100644 --- a/src/simple_launch_process_cpp_win32.cpp +++ b/src/drekar_launch_process_cpp_win32.cpp @@ -3,10 +3,10 @@ #include #include -#include "simple_launch_process_cpp/simple_launch_process_cpp.h" -// Create a class with a message only window and a simple message loop +#include "drekar_launch_process_cpp/drekar_launch_process_cpp.h" +// Create a class with a message only window and a drekar message loop -namespace simple_launch_process_cpp +namespace drekar_launch_process_cpp { namespace detail { @@ -180,7 +180,7 @@ bool CWaitForExit::CallbackWaitForExit(void (*exit_callback)()) void CWaitForExit::WaitForExit() { // Create the message window - if (!impl->Create("simple_launch_process", "simple_launch_process")) + if (!impl->Create("drekar_message_window", "drekar_hidden_window")) { std::cerr << "Failed to create message window" << std::endl; return; diff --git a/test/drekar-launch/drekar-launch.yaml b/test/drekar-launch/drekar-launch.yaml new file mode 100644 index 0000000..e4c80bc --- /dev/null +++ b/test/drekar-launch/drekar-launch.yaml @@ -0,0 +1,11 @@ +name: test_cpp_launch +tasks: + - name: wait_exit + program: ./build/drekar-launch-process-cpp_wait_exit_test + - name: callback_exit + program: ./build/drekar-launch-process-cpp_callback_exit_test + - name: sleep + program: sleep + args: ["5"] + quit-on-terminate: true + \ No newline at end of file diff --git a/test/test_simple_launch_process_cpp_callback_exit.cpp b/test/test_drekar_launch_process_cpp_callback_exit.cpp similarity index 78% rename from test/test_simple_launch_process_cpp_callback_exit.cpp rename to test/test_drekar_launch_process_cpp_callback_exit.cpp index 15ff134..a6cc7f2 100644 --- a/test/test_simple_launch_process_cpp_callback_exit.cpp +++ b/test/test_drekar_launch_process_cpp_callback_exit.cpp @@ -1,4 +1,4 @@ -#include "simple_launch_process_cpp/simple_launch_process_cpp.h" +#include "drekar_launch_process_cpp/drekar_launch_process_cpp.h" #include #include #include @@ -16,7 +16,7 @@ void exit_callback() int main() { - simple_launch_process_cpp::CWaitForExit wait_for_exit; + drekar_launch_process_cpp::CWaitForExit wait_for_exit; wait_for_exit.CallbackWaitForExit(exit_callback); std::unique_lock lock(cv_mutex); std::cout << "Press Ctrl+C to exit" << std::endl; diff --git a/test/test_simple_launch_process_cpp_wait_exit.cpp b/test/test_drekar_launch_process_cpp_wait_exit.cpp similarity index 56% rename from test/test_simple_launch_process_cpp_wait_exit.cpp rename to test/test_drekar_launch_process_cpp_wait_exit.cpp index b557744..57e9688 100644 --- a/test/test_simple_launch_process_cpp_wait_exit.cpp +++ b/test/test_drekar_launch_process_cpp_wait_exit.cpp @@ -1,9 +1,9 @@ -#include "simple_launch_process_cpp/simple_launch_process_cpp.h" +#include "drekar_launch_process_cpp/drekar_launch_process_cpp.h" #include int main() { - simple_launch_process_cpp::CWaitForExit wait_for_exit; + drekar_launch_process_cpp::CWaitForExit wait_for_exit; std::cout << "Press Ctrl+C to exit" << std::endl; wait_for_exit.WaitForExit(); std::cout << "Exit" << std::endl;