Skip to content

Commit

Permalink
(#18634) add svgpp library
Browse files Browse the repository at this point in the history
* add svgpp

* add c++11 compiler feature to test_package

fix

* Update recipes/svgpp/all/conanfile.py

---------

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
  • Loading branch information
maksim-petukhov and czoido authored Jul 25, 2023
1 parent 2446b36 commit 108aa46
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/svgpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20221030":
url: "https://github.com/svgpp/svgpp/archive/1583a7b209038bfd0d98c6ce7d4c93986f7b235e.tar.gz"
sha256: "95f4145c43aada913e7b24e37d20d0eef5f170a7c70e00ffcb318a3910b43ca6"
59 changes: 59 additions & 0 deletions recipes/svgpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import get, copy
from conan.tools.layout import basic_layout
import os


required_conan_version = ">=1.52.0"


class SvgPPConan(ConanFile):
name = "svgpp"
description = "SVG++ library contains parsers for various SVG syntaxes, " \
"adapters that simplify handling of parsed data and a lot of other utilities and helpers for the most common tasks."
license = "BSL-1.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/svgpp/svgpp"
topics = ("svgpp", "svg", "parser", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _min_cppstd(self):
return 11

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

def requirements(self):
self.requires("boost/1.82.0", transitive_headers=True)

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

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

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

def build(self):
pass

def package(self):
copy(self, pattern="LICENSE_1_0.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(
self,
pattern="*.*",
dst=os.path.join(self.package_folder, "include"),
src=os.path.join(self.source_folder, "include"),
)

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

self.cpp_info.requires.append("boost::headers")
8 changes: 8 additions & 0 deletions recipes/svgpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(svgpp REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE svgpp::svgpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
26 changes: 26 additions & 0 deletions recipes/svgpp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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)

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")
23 changes: 23 additions & 0 deletions recipes/svgpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <svgpp/svgpp.hpp>
#include <algorithm>
#include <iterator>

using namespace svgpp;

struct Context
{
void transform_matrix(const boost::array<double, 6> & matrix)
{
std::copy(matrix.begin(), matrix.end(),
std::ostream_iterator<double>(std::cout, " "));
std::cout << "\n";
}
};

int main()
{
Context context;
value_parser<tag::type::transform_list>::parse(tag::attribute::transform(), context,
std::string("translate(-10,-20) scale(2) rotate(45) translate(5,10)"), tag::source::attribute());
return 0;
}
3 changes: 3 additions & 0 deletions recipes/svgpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20221030":
folder: "all"

0 comments on commit 108aa46

Please sign in to comment.