Skip to content

Commit

Permalink
(#5251) libui 0.4.1
Browse files Browse the repository at this point in the history
* Initial attempt at libui for CCI.

* Update recipes/libui/all/conanfile.py

Co-authored-by: Anonymous Maarten <[email protected]>

* Update recipes/libui/all/test_package/conanfile.py

Co-authored-by: Anonymous Maarten <[email protected]>

* Update recipes/libui/all/test_package/conanfile.py

Co-authored-by: Anonymous Maarten <[email protected]>

* Update recipes/libui/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* Update recipes/libui/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* Fix syntax error.

Co-authored-by: Anonymous Maarten <[email protected]>
Co-authored-by: Chris Mc <[email protected]>
  • Loading branch information
3 people authored May 12, 2021
1 parent 8a3a758 commit d5786a0
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/libui/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/libui/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.4.1":
url: "https://github.com/andlabs/libui/archive/refs/tags/alpha4.1.tar.gz"
sha256: "f51a9e20e9f9a4c0bce1571ee37f203f42de33e3ac7359a6aac87a54798e8716"
79 changes: 79 additions & 0 deletions recipes/libui/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from conans import ConanFile, CMake, tools
from conans.tools import os_info
import os


class libuiConan(ConanFile):
name = "libui"
description = "Simple and portable GUI library in C that uses the native GUI technologies of each platform it supports."
topics = ("conan", "libui", "ui", "gui")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/andlabs/libui"
license = "MIT"
exports_sources = ["CMakeLists.txt"]
generators = "cmake", "pkg_config"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC

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

def requirements(self):
self.requires("gtk/3.24.24")

def _configure_cmake(self):
cmake = CMake(self)
cmake.configure(build_folder=self._build_subfolder)
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="LICENSE", dst="licenses",
src=self._source_subfolder)
self.copy(pattern="*.h", dst="include", src=self._source_subfolder)
self.copy(pattern="*.dll", dst="bin", keep_path=False)
self.copy(pattern="*.lib", dst="lib", keep_path=False)
self.copy(pattern="*.a", dst="lib", keep_path=False)
self.copy(pattern="*.so*", dst="lib", keep_path=False)
self.copy(pattern="*.dylib", dst="lib", keep_path=False)

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Windows":
self.cpp_info.system_libs.extend(
[
"user32",
"kernel32",
"gdi32",
"comctl32",
"msimg32",
"comdlg32",
"d2d1",
"dwrite",
"ole32",
"oleaut32",
"oleacc",
"uuid",
"windowscodecs",
]
)
9 changes: 9 additions & 0 deletions recipes/libui/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)


include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/libui/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
21 changes: 21 additions & 0 deletions recipes/libui/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "ui.h"
#include <stdio.h>

int main(void)
{
uiInitOptions o;

const char *err;
o.Size = 0;
err = uiInit(&o);
if (err != NULL)
{
fprintf(stderr, "error initializing ui: %s\n", err);
uiFreeInitError(err);
return 0;
}

uiMain();
uiUninit();
return 0;
}
3 changes: 3 additions & 0 deletions recipes/libui/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.4.1":
folder: "all"

0 comments on commit d5786a0

Please sign in to comment.