diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..3a3c8a8 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,79 @@ +name: libringqueue +on: + push: + tags: + - 'v*.*.*' # Triggers on version tags + branches: + - '**' # Triggers on all branches + workflow_dispatch: + +jobs: + build: + name: ${{ matrix.build-name }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + build-name: linux + additional-args: "['-DCMAKE_CXX_COMPILER=g++-14']" + - os: windows-2025 + build-name: windows + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: '0' + + - uses: lukka/get-cmake@latest + + - name: Build the project + uses: lukka/run-cmake@v10 + with: + configurePreset: Release + buildPreset: Release + configurePresetAdditionalArgs: ${{ matrix.additional-args }} + + - name: Create Github Artifact + uses: actions/upload-artifact@v4.1.0 + with: + name: libringqueue-${{ matrix.build-name }} + path: ${{ github.workspace }}/build/Release/libringqueue* + + finalize: + runs-on: ubuntu-latest + needs: + - build + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: '0' + + - name: Get Next Version + id: getver + uses: anothrNick/github-tag-action@v1 + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref_name == 'main') + env: + GITHUB_TOKEN: ${{ github.token }} + TAG_PREFIX: v + DEFAULT_BUMP: patch + + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + if: github.event_name == 'push' && ((startsWith(github.ref, 'refs/tags') || github.ref_name == 'main')) + with: + files: | + ${{ github.workspace }}/libringqueue.so + ${{ github.workspace }}/libringqueue.dll + + tag_name: ${{ steps.getver.outputs.new_tag }} + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 913cd4f..6f9e937 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set_target_properties (ringqueue PROPERTIES DEFINE_SYMBOL LIBRINGQUEUE_BUILD ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -pedantic-errors -Wpedantic -Wall -Werror -Wextra -Wabi -fPIC -fvisibility=hidden") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -pedantic-errors -Wpedantic -Wall -Werror -Wextra -fPIC -fvisibility=hidden") target_sources(ringqueue PRIVATE ${PROJECT_SOURCE_DIR}/src/ringbuffer_interface.cpp @@ -23,7 +23,7 @@ target_include_directories(ringqueue PUBLIC target_link_options(ringqueue PRIVATE -shared -fPIC -fvisibility=hidden) if (WIN32) - target_link_options(ringqueue PRIVATE -static-libgcc -static-libstdc++ LINKER:-Bstatic,--whole-archive -lwinpthread LINKER:-Bdynamic,--no-whole-archive -lonecore) + target_link_libraries(ringqueue PRIVATE -static-libgcc -static-libstdc++ LINKER:-Bstatic,--whole-archive -lwinpthread LINKER:-Bdynamic,--no-whole-archive -lonecore) endif () install(TARGETS ringqueue DESTINATION .) diff --git a/include/ringqueue.hpp b/include/ringqueue.hpp index 163a190..097375c 100644 --- a/include/ringqueue.hpp +++ b/include/ringqueue.hpp @@ -89,7 +89,8 @@ class RingQueue { #ifdef __linux int fd = memfd_create(ANONYMOUS_FILENAME, MFD_CLOEXEC); - ftruncate(fd, size); + const int _ = ftruncate(fd, size); + static_cast(_); void *const shm = mmap(nullptr, size * 2zu, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0l); diff --git a/src/ringbuffer_interface.cpp b/src/ringbuffer_interface.cpp index 41096dc..f29d734 100644 --- a/src/ringbuffer_interface.cpp +++ b/src/ringbuffer_interface.cpp @@ -20,7 +20,7 @@ extern "C" { try { reinterpret_cast*>(handle)->enqueueMany(std::span(static_cast(item), size)); } catch (const std::length_error &e) { - fprintf(stderr, e.what()); + fprintf(stderr, "%s\n", e.what()); return false; } @@ -31,7 +31,7 @@ extern "C" { try { return reinterpret_cast*>(handle)->popMany(static_cast(out), size); } catch (const std::out_of_range &e) { - fprintf(stderr, e.what()); + fprintf(stderr, "%s\n", e.what()); return false; }