Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 32 additions & 6 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,41 @@ jobs:
name: "Windows MSVC",
enabled: 1,
os: windows-latest,
deps: "",
deps1: "",
config: "cmake
-B build
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
-DRTOSC_WERROR=1
-DCMAKE_BUILD_TYPE=Release
",
build: "cmake --build build --config Release",
test: "ctest --output-on-failure --test-dir build -C Release"
}
- {
name: "MinGW",
enabled: 1,
os: ubuntu-latest,
update: "sudo apt-get update",
deps1: "sudo apt-get install -y mingw-w64 cmake ninja-build wine64",
deps2: "./build-mingw-deps $RUNNER_TEMP",
config: "PKG_CONFIG_PATH=$RUNNER_TEMP/prefix/lib/pkgconfig
cmake
-S .
-B build
-G Ninja
-DRTOSC_WERROR=ON
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw64.cmake
-DMINGW_PREFIX=$RUNNER_TEMP/prefix
-DCMAKE_BUILD_TYPE=Debug
",
build: "cmake --build build --config Debug",
test: "ctest --output-on-failure --test-dir build"
}
- {
name: "Ubuntu gcc",
enabled: 1,
os: ubuntu-latest,
deps: "sudo apt-get install liblo-dev",
deps1: "sudo apt-get install liblo-dev",
config: "cd build && cmake -DRTOSC_WERROR=1 ..",
build: "cd build && make",
test: "cd build && ctest --output-on-failure"
Expand All @@ -36,7 +56,7 @@ jobs:
name: "Ubuntu clang+lld",
enabled: 1,
os: ubuntu-latest,
deps: "sudo apt-get install liblo-dev",
deps1: "sudo apt-get install liblo-dev",
config: "cd build &&
cmake
-DRTOSC_WERROR=1
Expand All @@ -52,7 +72,7 @@ jobs:
name: "macOS clang",
enabled: 1,
os: macos-latest,
deps: "brew install liblo",
deps1: "brew install liblo",
config: "cd build && cmake -DRTOSC_WERROR=1 ..",
build: "cd build && make",
test: "cd build && ctest --output-on-failure"
Expand All @@ -62,9 +82,15 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install deps
- name: update system
if: ${{ matrix.config.enabled == 1 }}
run: ${{ matrix.config.update }}
- name: install deps (1)
if: ${{ matrix.config.enabled == 1 }}
run: ${{ matrix.config.deps1 }}
- name: install deps (2)
if: ${{ matrix.config.enabled == 1 }}
Comment thread
JohannesLorenz marked this conversation as resolved.
Outdated
run: ${{ matrix.config.deps }}
run: ${{ matrix.config.deps2 }}
- name: create build directory
if: ${{ matrix.config.enabled == 1 }}
run: mkdir build
Expand Down
67 changes: 64 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,79 @@ endif(BUILD_RTOSC_EXAMPLES)


# Testing Code


function(rtosc_add_test testname testbinary)
# Remaining arguments are test args
set(test_args ${ARGN})

# Default: native execution
set(cmd ${testbinary})
set(env)

# Condition 1: -DMINGW_PREFIX was passed
# Condition 2: environment variable forces wine
if(DEFINED MINGW_PREFIX OR DEFINED ENV{ZYN_USE_WINE})

# Allow override via environment (useful in CI)
if(DEFINED ENV{RUNNER_TEMP})
set(_runner_temp "$ENV{RUNNER_TEMP}")
else()
set(_runner_temp "")
endif()

# Compose WINEPATH
set(_winepath
"/usr/x86_64-w64-mingw32/bin/;"
"/usr/x86_64-w64-mingw32/lib/;"
"/usr/lib/gcc/x86_64-w64-mingw32/13-win32"
Comment thread
JohannesLorenz marked this conversation as resolved.
Outdated
)

if(_runner_temp)
list(APPEND _winepath
"${_runner_temp}/prefix/lib"
"${_runner_temp}/prefix/bin"
)
endif()

# Join with semicolons (WINEPATH wants ;, but ENVIRONMENT PROPERTY also wants it)
list(JOIN _winepath "\\\\;" WINEPATH_VALUE)

# Wine command
set(cmd wine ${testbinary})

# Environment for CTest
set(env "WINEPATH=${WINEPATH_VALUE}")

Comment thread
JohannesLorenz marked this conversation as resolved.
endif()

# Register test
add_test(
NAME ${testname}
COMMAND ${cmd} ${test_args}
)

# Apply environment only if needed
if(env)
set_tests_properties(${testname}
PROPERTIES ENVIRONMENT "${env}"
)
message(STATUS "${env}")
endif()
endfunction()

enable_testing()
macro(maketest fname)
add_executable(${fname} test/${fname}.c)
add_test(${fname} ${fname})
rtosc_add_test(${fname} ${fname})
target_link_libraries(${fname} PRIVATE rtosc)
target_compile_options(${fname} PRIVATE
"$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-std=c99>")
#add_test(memcheck_${fname} valgrind --leak-check=full --show-reachable=yes --error-exitcode=1 ./${fname})
endmacro(maketest)
macro(maketestcpp fname)
add_executable(${fname} test/${fname}.cpp)
add_test(${fname} ${fname})
rtosc_add_test(${fname} ${fname})
target_link_libraries(${fname} PRIVATE rtosc-cpp rtosc)
#add_test(memcheck_${fname} valgrind --leak-check=full --show-reachable=yes --error-exitcode=1 ./${fname})
endmacro(maketestcpp)
Expand Down Expand Up @@ -267,7 +328,7 @@ if(LIBLO_FOUND AND RUBY_FOUND)
target_link_directories(port-checker-testapp PRIVATE ${LIBLO_LIBRARY_DIRS})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/test-port-checker.rb
${CMAKE_CURRENT_BINARY_DIR}/test-port-checker.rb COPYONLY)
add_test(test-port-checker test-port-checker.rb)
rtosc_add_test(test-port-checker test-port-checker.rb)
Comment thread
JohannesLorenz marked this conversation as resolved.
Outdated
endif()

# Documentation
Expand Down
65 changes: 65 additions & 0 deletions build-mingw-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

die()
{
echo "$@" >&2
exit 1
}

trap_func()
{
trap - ERR # don't run the trap again
die "Error in line $1 (return code $2)"
}

check_prerequisites()
{
for program in make wget tar autoconf automake x86_64-w64-mingw32-{gcc,ar}
do
command -v "$program" >/dev/null || die "Error: Must have \"$program\" installed"
done
}

main()
{
set -eE
trap 'trap_func $LINENO $?' ERR

check_prerequisites

local tmp_dir
if [ "$1" ]
then
[ -d "$1" ] || die "Error: Directory \"$1\" does not exit"
Comment thread
JohannesLorenz marked this conversation as resolved.
Outdated
tmp_dir=$1
else
tmp_dir=$(mktemp -d "/tmp/build-mingw-deps.XXXXXXXXXX")
fi

local urls=(
https://github.com/radarsat1/liblo/archive/refs/tags/0.34.tar.gz # GPL-2.1-only
)
local archives=(liblo-0.34)

# shellcheck disable=SC2043 # loop intended to run once (can be extended for future deps)
for i in 0
do
local tarball=$tmp_dir/${archives[$i]}.tar.gz
[ -f "$tarball" ] || wget "${urls[$i]}" -O "$tarball"
tar -C "$tmp_dir/" -xf "$tarball"
# rm "$tarball"
done

[ -d "$tmp_dir/prefix" ] || mkdir "$tmp_dir/prefix"

(cd "$tmp_dir/liblo-0.34"
./autogen.sh --host=x86_64-w64-mingw32 \
--prefix="$tmp_dir/prefix" \
--disable-shared \
--enable-static \
--disable-doc
make
make install)
}

main "$@"
17 changes: 17 additions & 0 deletions cmake/toolchains/mingw64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# MinGW-W64 compiler
SET(CMAKE_AR x86_64-w64-mingw32-gcc-ar CACHE FILEPATH "Archiver")
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
SET(CMAKE_LD x86_64-w64-mingw32-gcc)
Comment thread
JohannesLorenz marked this conversation as resolved.
Outdated

# Search for libraries only in MinGW root AND the prefix of compiled dependencies
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${MINGW_PREFIX})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
2 changes: 2 additions & 0 deletions test/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ Ports port_table = {
char events[20][1024];
char loc_buffer[1024];

#ifdef HAVE_LIBLO
static void liblo_error_cb(int i, const char *m, const char *loc)
{
fprintf(stderr, "liblo :-( %d-%s@%s\n",i,m,loc);
}
#endif

void print_results(const char* libname,
clock_t t_on, clock_t t_off, int repeats)
Expand Down
Loading