Skip to content
Open
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
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: libuca tests

on:
push:

permissions:
contents: read

jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: get conan
uses: turtlebrowser/get-conan@v1.0
- name: create conan profile
run: |
pip install --force-reinstall -v "conan==1.59.0"
conan profile new default --detect
- name: build
run: |
mkdir build
cd build
conan install .. -o libuca:shared=True --build missing
cmake ..
cmake --build .
cmake --install .
- name: build
uses: actions/upload-artifact@v3
with:
name: build_folder
path: build
- name: run test-mock
run: |
build\bin\test-mock.exe
- name: run test-ring-buffer
run: |
build\bin\test-ring-buffer
45 changes: 14 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
cmake_minimum_required(VERSION 2.6)

if (POLICY CMP0053)
cmake_policy(SET CMP0053 OLD)
endif ()
cmake_minimum_required(VERSION 3.11)
project(uca C)

if (POLICY CMP0054)
cmake_policy(SET CMP0054 OLD)
endif ()
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message(FATAL_ERROR "Please run 'conan install' first!")
endif()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)

project(uca C)
conan_basic_setup(TARGETS)

#{{{ CMake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
Expand All @@ -35,7 +33,7 @@ set(UCA_ABI_VERSION "2")
macro(create_enums prefix template_prefix header_list)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${prefix}.h
COMMAND ${GLIB2_MKENUMS}
COMMAND python ${GLIB2_MKENUMS}
ARGS
--template ${template_prefix}.h.template
${header_list} > ${CMAKE_CURRENT_BINARY_DIR}/${prefix}.h
Expand All @@ -44,7 +42,7 @@ macro(create_enums prefix template_prefix header_list)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${prefix}.c
COMMAND ${GLIB2_MKENUMS}
COMMAND python ${GLIB2_MKENUMS}
ARGS
--template ${template_prefix}.c.template
${header_list} > ${CMAKE_CURRENT_BINARY_DIR}/${prefix}.c
Expand All @@ -55,7 +53,7 @@ macro(create_enums prefix template_prefix header_list)
endmacro()
#}}}
#{{{ Configure
include(PkgConfigVars)
#include(PkgConfigVars)
include(GNUInstallDirs)

set(CMAKE_INSTALL_GIRDIR "${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0")
Expand All @@ -67,39 +65,24 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.sh.in
${CMAKE_CURRENT_BINARY_DIR}/package.sh)
#}}}
#{{{ Common dependencies
find_package(PkgConfig)
find_program(GLIB2_MKENUMS glib-mkenums REQUIRED)
pkg_check_modules(GLIB2 glib-2.0>=2.38 REQUIRED)
pkg_check_modules(GOBJECT2 gobject-2.0>=2.38 REQUIRED)
pkg_check_modules(GMODULE2 gmodule-2.0>=2.38 REQUIRED)
pkg_check_modules(GIO2 gio-2.0>=2.38 REQUIRED)

set(GLIB_VERSION_MIN_REQUIRED "GLIB_VERSION_2_38")
set(GLIB_VERSION_MAX_ALLOWED "GLIB_VERSION_2_38")

link_directories(${GLIB2_LIBRARY_DIRS})
#}}}
#{{{ Common includes
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${GLIB2_INCLUDE_DIRS}
${GOBJECT2_INCLUDE_DIRS}
${GMODULE2_INCLUDE_DIRS}
${GIO2_INCLUDE_DIRS})
#}}}

#{{{ Common variables
set(UCA_DEPS
${GLIB2_LIBRARIES}
${GOBJECT2_LIBRARIES}
${GMODULE2_LIBRARIES}
${GIO2_LIBRARIES})

set(UCA_ENUM_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/src/uca-camera.h
${CMAKE_CURRENT_SOURCE_DIR}/plugins/pco/uca-pco-camera.h)
#}}}
#{{{ Common definitions
add_definitions("-std=c99 -Wall -fPIC")
if (GNU)
add_definitions("-std=c99 -Wall -fPIC")
endif()
#}}}
#{{{ Subdirectories
add_subdirectory(src)
Expand Down
4 changes: 1 addition & 3 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
cmake_minimum_required(VERSION 2.6)

add_subdirectory(gui)
#add_subdirectory(gui)
add_subdirectory(tools)
11 changes: 7 additions & 4 deletions bin/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 2.6)

#{{{ Variables
set(libs uca)
#}}}
Expand All @@ -23,11 +21,16 @@ set(BINARIES "benchmark" "gen-doc" "info")

foreach (BINARY ${BINARIES})
add_executable(uca-${BINARY} ${BINARY}.c common.c)
target_link_libraries(uca-${BINARY} ${libs})
target_link_libraries(uca-${BINARY} PUBLIC ${libs})
endforeach ()

add_executable(uca-grab grab.c common.c)
target_link_libraries(uca-grab ${libs} m)
target_link_libraries(uca-grab PUBLIC ${libs})

if (GNU)
target_link_libraries(uca-grab PUBLIC m)
endif()


install(TARGETS uca-benchmark uca-grab uca-gen-doc uca-info
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand Down
35 changes: 35 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from conans import ConanFile, CMake, tools


class UcaConan(ConanFile):
name = "libuca"
version = "2.3.0"
license = "LGPL-2.1"
author = "Marius Elvert marius.elvert@softwareschneiderei.de"
url = "https://github.com/ufo-kit/libuca"
description = "GLib-based C library for unified camera access ."
topics = ("utilities",)
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = "shared=False"
generators = "cmake"
exports_sources = "src/*", "include/*", "test/*", "bin/*", "CMakeLists.txt", "package.sh.in"
requires = "glib/2.68.1",

def _configured_cmake(self):
cmake = CMake(self)
cmake.configure(source_folder=".")
return cmake

def build(self):
self._configured_cmake().build()

def package(self):
self._configured_cmake().install()

def package_info(self):
self.cpp_info.libs = ["uca"]

def imports(self):
self.copy("*.dll", "bin", "bin")
self.copy("*.dylib", "lib", "lib")
5 changes: 4 additions & 1 deletion plugins/mock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../package-plugin.sh.in
add_library(ucamock SHARED
uca-mock-camera.c)

target_link_libraries(ucamock uca m ${UCA_DEPS})
target_link_libraries(ucamock uca ${UCA_DEPS})
if (NOT WIN32)
target_link_libraries(ucamock m)
endif()

install(TARGETS ucamock
LIBRARY DESTINATION ${CMAKE_INSTALL_PLUGINDIR}
Expand Down
15 changes: 0 additions & 15 deletions plugins/mock/uca-mock-camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <gio/gio.h>
#include <string.h>
#include <math.h>
#include <signal.h>
#include "uca-mock-camera.h"

#define UCA_MOCK_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_MOCK_CAMERA, UcaMockCameraPrivate))
Expand Down Expand Up @@ -262,13 +261,6 @@ mock_grab_func(gpointer data)
return NULL;
}

static void
handle_sigusr1 (int signum)
{
g_mutex_lock (&signal_mutex);
g_cond_signal (&signal_cond);
g_mutex_unlock (&signal_mutex);
}

static void
uca_mock_camera_start_recording(UcaCamera *camera, GError **error)
Expand All @@ -278,7 +270,6 @@ uca_mock_camera_start_recording(UcaCamera *camera, GError **error)
g_return_if_fail(UCA_IS_MOCK_CAMERA(camera));

priv = UCA_MOCK_CAMERA_GET_PRIVATE(camera);
signal (SIGUSR1, handle_sigusr1);

/* TODO: check that roi_x + roi_width < priv->width */
priv->dummy_data = (guint8 *) g_malloc0(priv->roi_width * priv->roi_height * priv->bytes);
Expand Down Expand Up @@ -356,12 +347,6 @@ uca_mock_camera_grab (UcaCamera *camera, gpointer data, GError **error)
if (trigger_source == UCA_CAMERA_TRIGGER_SOURCE_SOFTWARE)
g_free (g_async_queue_pop (priv->trigger_queue));

if (trigger_source == UCA_CAMERA_TRIGGER_SOURCE_EXTERNAL) {
/* wait for signal to arrive */
g_mutex_lock (&signal_mutex);
g_cond_wait (&signal_cond, &signal_mutex);
g_mutex_unlock (&signal_mutex);
}

g_usleep (G_USEC_PER_SEC * exposure_time);

Expand Down
Loading