Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflows #42

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 83 additions & 3 deletions .github/workflows/pullreq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,90 @@ jobs:
strategy:
matrix:
include:
- os: windows-latest
cmakeargs: -A x64
install_ninja: false
name: Windows 64bit MSVC
exe: .exe

- os: windows-latest
cmakeargs: -A x64 -DCLAP_HELPERS_TESTS_CXX_STANDARD=20
install_ninja: false
name: Windows 64bit C++20 MSVC
exe: .exe

#- os: windows-latest
# cmakeargs: -GNinja -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
# install_ninja: true
# name: Windows gcc/minGW
# exe: .exe

- os: windows-latest
cmakeargs: -GNinja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
install_ninja: true
name: Windows clang
exe: .exe

- os: ubuntu-latest
cmakeargs: -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11
install_ninja: false
name: Linux gcc11

- os: ubuntu-latest
cmakeargs: -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12
install_ninja: false
name: Linux gcc12

- os: ubuntu-latest
cmakeargs: -DCLAP_HELPERS_TESTS_CXX_STANDARD=20 -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12
install_ninja: false
name: Linux gcc12 C++20

- os: ubuntu-latest
name: Linux
cmakeargs: -DCLAP_HELPERS_TESTS_CXX_STANDARD=23 -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12
install_ninja: false
name: Linux gcc12 C++23

- os: macos-latest
cmakeargs: -GNinja
install_ninja: true
name: MacOS Ninja

- os: macos-latest
cmakeargs: -G"Xcode"
install_ninja: false
name: MacOS Xcode

- os: macos-latest
cmakeargs: -G"Ninja Multi-Config" -DCLAP_HELPERS_TESTS_CXX_STANDARD=20
install_ninja: true
name: MacOS Ninja Multi C++20

- os: macos-latest
cmakeargs: -G"Unix Makefiles"
install_ninja: false
name: MacOS Unix Makefiles

steps:
- name: Echo
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install Ninja
if: ${{ matrix.install_ninja }}
uses: seanmiddleditch/gha-setup-ninja@master

- name: Build project
run: |
cmake -S . -B ./build ${{ matrix.cmakeargs }} -DCMAKE_BUILD_TYPE=Debug -DCLAP_HELPERS_BUILD_TESTS=TRUE
cmake --build ./build --config Debug --target clap-helpers-tests --parallel

- name: Run Tests
shell: bash
run: |
echo "Hello World"
echo "About to run " ./build/clap-helpers-tests${{ matrix.exe }}
ls -l ./build/clap-helpers-tests${{ matrix.exe }}
echo "Starting Run"
./build/clap-helpers-tests${{ matrix.exe }}
echo "Run complete"
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

#vs
.vs
out

#clion
.idea
cmake-build-*

#baconpaul habit
ignore/
#df habit
build/
out/
.DS_Store
73 changes: 54 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,69 @@
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0100 NEW) # handle .hh files
project(CLAP_HELPERS C CXX)
project(clap-helpers C CXX)

add_library(clap-helpers INTERFACE)
target_include_directories(clap-helpers SYSTEM INTERFACE include)
target_link_libraries(clap-helpers INTERFACE clap)
option(CLAP_HELPERS_BUILD_TESTS "Build tests for the CLAP Helper" FALSE)
option(CLAP_HELPERS_ALWAYS_DOWNLOAD "Always download CPM versions even if target defined" FALSE)

# CLAP_BUILD_TESTS is inherited from clap
if (${CLAP_BUILD_TESTS})
enable_testing()
find_package(Catch2 3 QUIET)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE include)

if (Catch2_FOUND)
add_executable(clap-helpers-tests EXCLUDE_FROM_ALL
if ((NOT TARGET clap) OR ${CLAP_HELPERS_ALWAYS_DOWNLOAD})
message(STATUS "${PROJECT_NAME}: Downloading CLAP using CPM")

message(STATUS "${PROJECT_NAME}: including CPM")
include(cmake/external/CPM.cmake)
baconpaul marked this conversation as resolved.
Show resolved Hide resolved
CPMAddPackage(
NAME "clap"
GITHUB_REPOSITORY "free-audio/clap"
GIT_TAG "next"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be set to "1.2.0" once that one is ready, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

EXCLUDE_FROM_ALL TRUE
DOWNLOAD_ONLY TRUE
SOURCE_DIR cpm/clap
)

add_subdirectory(${CMAKE_BINARY_DIR}/cpm/clap)
endif()
target_link_libraries(${PROJECT_NAME} INTERFACE clap)

if (${CLAP_HELPERS_BUILD_TESTS})
if (NOT DEFINED CLAP_HELPERS_TESTS_CXX_STANDARD)
message(STATUS "${PROJECT_NAME}: defaulting to c++11")
set(CLAP_HELPERS_TESTS_CXX_STANDARD 11)
endif()

if ((NOT TARGET Catch2::Catch2WithMain) OR ${CLAP_HELPERS_ALWAYS_DOWNLOAD})
message(STATUS "${PROJECT_NAME}: Downloading Catch2")
include(cmake/external/CPM.cmake)
CPMAddPackage(
NAME "Catch2"
GITHUB_REPOSITORY "catchorg/Catch2"
GIT_TAG "v3.5.1"
EXCLUDE_FROM_ALL TRUE
DOWNLOAD_ONLY TRUE
SOURCE_DIR cpm/catch2
)
add_subdirectory(${CMAKE_BINARY_DIR}/cpm/catch2)
endif()

add_executable(${PROJECT_NAME}-tests EXCLUDE_FROM_ALL
tests/hex-encoder.cc
tests/plugin.cc
tests/param-queue-tests.cc
tests/event-list-tests.cc
tests/main.cc
tests/preset-discovery-indexer.cc
tests/preset-discovery-provider.cc
tests/preset-discovery-metadata-receiver.cc)
set_target_properties(clap-helpers-tests PROPERTIES CXX_STANDARD 11)
target_link_libraries(clap-helpers-tests clap-helpers clap Catch2::Catch2WithMain)
target_compile_definitions(clap-helpers-tests PUBLIC -DCATCH_CONFIG_PREFIX_ALL)
add_test(NAME test-clap-helpers COMMAND clap-helpers-tests)
add_dependencies(clap-tests clap-helpers-tests)
else()
message(STATUS "Catch2 >= 3 isn't found -> disable clap-helpers unit tests")
endif()
tests/preset-discovery-metadata-receiver.cc
)
set_target_properties(${PROJECT_NAME}-tests PROPERTIES CXX_STANDARD ${CLAP_HELPERS_TESTS_CXX_STANDARD})
target_link_libraries(${PROJECT_NAME}-tests ${PROJECT_NAME} Catch2::Catch2WithMain)
target_compile_definitions(${PROJECT_NAME}-tests PUBLIC -DCATCH_CONFIG_PREFIX_ALL)

add_custom_command(TARGET ${PROJECT_NAME}-tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Relocating $<TARGET_FILE:${PROJECT_NAME}-tests> to ${CMAKE_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${PROJECT_NAME}-tests>" "${CMAKE_BINARY_DIR}"
)
endif()

install(DIRECTORY include DESTINATION ".")
Expand Down
24 changes: 24 additions & 0 deletions cmake/external/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.38.6)
set(CPM_HASH_SUM "11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
1 change: 1 addition & 0 deletions include/clap/helpers/event-list.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdexcept>
#include <vector>
#include <functional>
#include <algorithm>

#include <clap/events.h>

Expand Down
1 change: 0 additions & 1 deletion include/clap/helpers/plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <mutex>
#include <queue>
#include <string>
#include <string_view>
#include <vector>

#include <clap/all.h>
Expand Down
6 changes: 5 additions & 1 deletion include/clap/helpers/plugin.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,11 @@ namespace clap { namespace helpers {

if (!strcmp(id, CLAP_EXT_STATE) && self.implementsState())
return &_pluginState;
if ((!strcmp(id, CLAP_EXT_STATE_CONTEXT) || !strcmp(id, CLAP_EXT_STATE_CONTEXT_COMPAT)) &&
if ((!strcmp(id, CLAP_EXT_STATE_CONTEXT)
#ifdef CLAP_EXT_STATE_CONTEXT_COMPAT
|| !strcmp(id, CLAP_EXT_STATE_CONTEXT_COMPAT)
#endif
) &&
self.implementsStateContext() && self.implementsState())
return &_pluginStateContext;
if ((!strcmp(id, CLAP_EXT_PRESET_LOAD) || !strcmp(id, CLAP_EXT_PRESET_LOAD_COMPAT)) &&
Expand Down
4 changes: 2 additions & 2 deletions tests/param-queue-tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ namespace {

bool failed = false;

std::thread producer([&queue] {
std::thread producer([&queue, N] {
for (uint32_t i = 0; i < N; ++i)
queue.push(i);
});

std::thread consumer([&queue, &failed] {
std::thread consumer([&queue, &failed, N] {
uint32_t v = 0;
for (uint32_t i = 0; i < N; ++i) {
while (!queue.tryPop(v))
Expand Down
Loading