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

fenster: new recipe #25186

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions recipes/fenster/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.1.0":
url: "https://github.com/zserge/fenster/archive/refs/tags/v0.1.0.tar.gz"
sha256: "058bc7c7a28c66da5760bedfcc2a28b0f29f5cec640049b10e5ad2551b51d8de"
74 changes: 74 additions & 0 deletions recipes/fenster/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import os

from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout

required_conan_version = ">=1.52.0"


class FensterConan(ConanFile):
name = "fenster"
description = "The most minimal cross-platform GUI library"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/zserge/fenster"
topics = ("gui", "audio", "minimal")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True
options = {
"enable_graphics": [True, False],
"enable_audio": [True, False],
}
default_options = {
"enable_graphics": True,
"enable_audio": False,
}

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
if self.settings.os in ["Linux", "FreeBSD"]:
if self.options.enable_graphics:
self.requires("xorg/system")
if self.options.enable_audio:
self.requires("libalsa/1.2.12")

def validate(self):
if conan_version.major == 1:
# linking against asound fails on C3I for v1 but not v2
raise ConanInvalidConfiguration("This recipe is only compatible with Conan 2.0 or newer")

def package_id(self):
self.info.clear()

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*.h", self.source_folder, os.path.join(self.package_folder, "include"))

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

if self.options.enable_graphics:
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.requires.append("xorg::x11")
elif is_apple_os(self):
self.cpp_info.frameworks.append("Cocoa")
elif self.settings.os == "Windows":
self.cpp_info.system_libs.append("gdi32")

if self.options.enable_audio:
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.requires.append("libalsa::libalsa")
elif is_apple_os(self):
self.cpp_info.frameworks.append("AudioToolbox")
elif self.settings.os == "Windows":
self.cpp_info.system_libs.append("winmm")
7 changes: 7 additions & 0 deletions recipes/fenster/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES C)

find_package(fenster REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE fenster::fenster)
29 changes: 29 additions & 0 deletions recipes/fenster/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str, options={
"enable_graphics": True,
"enable_audio": True,
})

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.bindir, "test_package")
self.run(bin_path, env="conanrun")
16 changes: 16 additions & 0 deletions recipes/fenster/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <fenster.h>
#include <fenster_audio.h>

#define W 320
#define H 240

void dummy() {
uint32_t buf[W * H];
struct fenster f = { .title = "hello", .width = W, .height = H, .buf = buf };
fenster_open(&f);
fenster_close(&f);
}

int main() {
return 0;
}
3 changes: 3 additions & 0 deletions recipes/fenster/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.1.0":
folder: all
Loading