[DO-981] qt package (!15)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
This commit is contained in:
22
recipes/openal-soft/all/test_package/CMakeLists.txt
Normal file
22
recipes/openal-soft/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(OpenAL REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenAL::OpenAL)
|
||||
|
||||
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindOpenAL.html are properly defined
|
||||
set(_custom_vars
|
||||
OPENAL_FOUND
|
||||
OPENAL_INCLUDE_DIR
|
||||
OPENAL_LIBRARY
|
||||
OPENAL_VERSION_STRING
|
||||
)
|
||||
foreach(_custom_var ${_custom_vars})
|
||||
if(DEFINED ${_custom_var})
|
||||
message(STATUS "${_custom_var}: ${${_custom_var}}")
|
||||
else()
|
||||
message(FATAL_ERROR "${_custom_var} not defined")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/gcc-12-x86_64-gnu17-release/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
26
recipes/openal-soft/all/test_package/conanfile.py
Normal file
26
recipes/openal-soft/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
134
recipes/openal-soft/all/test_package/test_package.c
Normal file
134
recipes/openal-soft/all/test_package/test_package.c
Normal file
@@ -0,0 +1,134 @@
|
||||
#include "alc.h"
|
||||
#include "al.h"
|
||||
#include "alext.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static ALenum checkALErrors(int linenum)
|
||||
{
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
printf("OpenAL Error: %s (0x%x), @ %d\n", alGetString(err), err, linenum);
|
||||
return err;
|
||||
}
|
||||
#define checkALErrors() checkALErrors(__LINE__)
|
||||
|
||||
static ALCenum checkALCErrors(ALCdevice *device, int linenum)
|
||||
{
|
||||
ALCenum err = alcGetError(device);
|
||||
if(err != ALC_NO_ERROR)
|
||||
printf("ALC Error: %s (0x%x), @ %d\n", alcGetString(device, err), err, linenum);
|
||||
return err;
|
||||
}
|
||||
#define checkALCErrors(x) checkALCErrors((x),__LINE__)
|
||||
|
||||
#define MAX_WIDTH 80
|
||||
|
||||
static void printList(const char *list, char separator)
|
||||
{
|
||||
size_t col = MAX_WIDTH, len;
|
||||
const char *indent = " ";
|
||||
const char *next;
|
||||
|
||||
if(!list || *list == '\0')
|
||||
{
|
||||
fprintf(stdout, "\n%s!!! none !!!\n", indent);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
next = strchr(list, separator);
|
||||
if(next)
|
||||
{
|
||||
len = next-list;
|
||||
do {
|
||||
next++;
|
||||
} while(*next == separator);
|
||||
}
|
||||
else
|
||||
len = strlen(list);
|
||||
|
||||
if(len + col + 2 >= MAX_WIDTH)
|
||||
{
|
||||
fprintf(stdout, "\n%s", indent);
|
||||
col = strlen(indent);
|
||||
}
|
||||
else
|
||||
{
|
||||
fputc(' ', stdout);
|
||||
col++;
|
||||
}
|
||||
|
||||
len = fwrite(list, 1, len, stdout);
|
||||
col += len;
|
||||
|
||||
if(!next || *next == '\0')
|
||||
break;
|
||||
fputc(',', stdout);
|
||||
col++;
|
||||
|
||||
list = next;
|
||||
} while(1);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
static void printALCInfo(ALCdevice *device)
|
||||
{
|
||||
ALCint major, minor;
|
||||
|
||||
if(device)
|
||||
{
|
||||
const ALCchar *devname = NULL;
|
||||
printf("\n");
|
||||
if(alcIsExtensionPresent(device, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
|
||||
devname = alcGetString(device, ALC_ALL_DEVICES_SPECIFIER);
|
||||
if(checkALCErrors(device) != ALC_NO_ERROR || !devname)
|
||||
devname = alcGetString(device, ALC_DEVICE_SPECIFIER);
|
||||
printf("** Info for device \"%s\" **\n", devname);
|
||||
}
|
||||
alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major);
|
||||
alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor);
|
||||
if(checkALCErrors(device) == ALC_NO_ERROR)
|
||||
printf("ALC version: %d.%d\n", major, minor);
|
||||
if(device)
|
||||
{
|
||||
printf("ALC extensions:");
|
||||
printList(alcGetString(device, ALC_EXTENSIONS), ' ');
|
||||
checkALCErrors(device);
|
||||
}
|
||||
}
|
||||
|
||||
static void printDeviceList(const char *list)
|
||||
{
|
||||
if(!list || *list == '\0')
|
||||
printf(" !!! none !!!\n");
|
||||
else do {
|
||||
printf(" %s\n", list);
|
||||
list += strlen(list) + 1;
|
||||
} while(*list != '\0');
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("Available playback devices:\n");
|
||||
if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
|
||||
printDeviceList(alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER));
|
||||
else
|
||||
printDeviceList(alcGetString(NULL, ALC_DEVICE_SPECIFIER));
|
||||
printf("Available capture devices:\n");
|
||||
printDeviceList(alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER));
|
||||
|
||||
if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
|
||||
printf("Default playback device: %s\n",
|
||||
alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER));
|
||||
else
|
||||
printf("Default playback device: %s\n",
|
||||
alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER));
|
||||
printf("Default capture device: %s\n",
|
||||
alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
|
||||
|
||||
printALCInfo(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user