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

plutovg: add recipe #9274

Merged
merged 8 commits into from
Feb 27, 2022
Merged
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
9 changes: 9 additions & 0 deletions recipes/plutovg/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.4)
project(cmake_wrapper LANGUAGES C)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

include(conanbuildinfo.cmake)
conan_basic_setup(KEEP_RPATHS)

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/plutovg/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20220103":
url: "https://github.com/sammycage/plutovg/archive/51f1a79e04fbb42ec9e93499a18869eea06f3054.tar.gz"
sha256: "c2ce39b8085e0a8795263666f62af15239c36964330865fd54b9db25c67e063b"
74 changes: 74 additions & 0 deletions recipes/plutovg/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from conans import ConanFile, CMake, tools
import os

required_conan_version = ">=1.43.0"

class PlutoVGConan(ConanFile):
name = "plutovg"
description = "Tiny 2D vector graphics library in C"
topics = ("vector", "graphics", )
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/sammycage/plutovg"
license = "MIT",

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

exports_sources = ["CMakeLists.txt"]
generators = "cmake"
_cmake = None

@property
def _source_subfolder(self):
return "source_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
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

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

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure()
return self._cmake

def build(self):
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
"add_library(plutovg STATIC)", "add_library(plutovg)")
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
"add_subdirectory(example)", "")

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=os.path.join(self._source_subfolder, "include"))
self.copy(pattern="*.a", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.so", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False)
self.copy(pattern="*.dylib", dst="lib", src="lib", keep_path=False)

def package_info(self):
self.cpp_info.libs = ["plutovg"]
if self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.system_libs = ["m"]
10 changes: 10 additions & 0 deletions recipes/plutovg/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

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

find_package(plutovg REQUIRED CONFIG)

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

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

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

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

int main(void) {
const int width = 150;
const int height = 150;

plutovg_surface_t* surface = plutovg_surface_create(width, height);
plutovg_t* pluto = plutovg_create(surface);

plutovg_surface_destroy(surface);
plutovg_destroy(pluto);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/plutovg/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20220103":
folder: all