Skip to content

Commit

Permalink
Merge branch 'master' into openvino/2024.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
culhatsker committed Apr 30, 2024
2 parents ca6a098 + 8b46db5 commit d6af901
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 0 deletions.
5 changes: 5 additions & 0 deletions recipes/openvino/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ sources:
url: "https://github.com/oneapi-src/oneDNN/archive/4b82a66ed38ecaa993352e5cc6ed7753656b8a26.tar.gz"
sha256: "cb17c003fe51bc9b4e20189573956b4446468162adf0fc4cea2ee0820cff0cd0"
patches:
"2024.1.0":
- patch_file: "patches/2024.1.0/0001-fix-cxxflags.patch"
patch_description: "Fix build failure when explicitly passing different gcc ABI via cxx flags"
patch_type: "portability"
patch_source: "https://github.com/openvinotoolkit/openvino/pull/24274"
"2024.0.0":
- patch_file: "patches/2024.0.0/0001-Include-mutex-for-std-call_once.patch"
patch_description: "Include mutex for std::call_once"
Expand Down
48 changes: 48 additions & 0 deletions recipes/openvino/all/patches/2024.1.0/0001-fix-cxxflags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/cmake/developer_package/target_flags.cmake b/cmake/developer_package/target_flags.cmake
index d047a1ae..ae54926d 100644
--- a/cmake/developer_package/target_flags.cmake
+++ b/cmake/developer_package/target_flags.cmake
@@ -118,23 +118,30 @@ function(ov_get_compiler_definition definition var)
message(FATAL_ERROR "Internal error: 'ov_get_definition' must be used only on Linux")
endif()

- execute_process(COMMAND echo "#include <string>"
- COMMAND "${CMAKE_CXX_COMPILER}" -x c++ - -E -dM
- COMMAND grep -E "^#define ${definition} "
- OUTPUT_VARIABLE output_value
- ERROR_VARIABLE error_message
- RESULT_VARIABLE exit_code
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- if(NOT exit_code EQUAL 0)
- message(FATAL_ERROR "Failed to detect '${definition}' definition value: ${error_message}\n${output_value}")
- endif()
+ get_directory_property("PROP_COMPILE_DEFS" "COMPILE_DEFINITIONS")

- if(output_value MATCHES "^#define ${definition} ([0-9]+)")
+ if(PROP_COMPILE_DEFS MATCHES "${definition}=([0-9]+)")
set("${var}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
else()
- message(FATAL_ERROR "Internal error: failed to parse ${definition} from '${output_value}'")
+ execute_process(COMMAND echo "#include <string>"
+ COMMAND bash -c "${CMAKE_CXX_COMPILER} -x c++ - -E -dM ${CMAKE_CXX_FLAGS}"
+ COMMAND grep -E "^#define ${definition} "
+ OUTPUT_VARIABLE output_value
+ ERROR_VARIABLE error_message
+ RESULT_VARIABLE exit_code
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(NOT exit_code EQUAL 0)
+ message(FATAL_ERROR "Failed to detect '${definition}' definition value: ${error_message}\n${output_value}")
+ endif()
+
+ if(output_value MATCHES "^#define ${definition} ([0-9]+)")
+ set("${var}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ else()
+ message(FATAL_ERROR "Internal error: failed to parse ${definition} from '${output_value}'")
+ endif()
endif()
+
endfunction()

function(ov_glibc_version)
4 changes: 4 additions & 0 deletions recipes/thorvg/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.13.0":
url: "https://github.com/thorvg/thorvg/archive/refs/tags/v0.13.0.tar.gz"
sha256: "4245c401fa637452c8526c0c4448d8c7915f09a6a2e1fa85d6e9032ee610b454"
160 changes: 160 additions & 0 deletions recipes/thorvg/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get, rmdir, rename, replace_in_file, rm
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.scm import Version
from conan.tools.microsoft import is_msvc
from conan.tools.env import VirtualBuildEnv
import os


required_conan_version = ">=1.64.0 <2 || >=2.2.0"


class ThorvgConan(ConanFile):
name = "thorvg"
description = "ThorVG is a platform-independent portable library that allows for drawing vector-based scenes and animations."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/thorvg/thorvg"
topics = ("svg", "animation", "tvg")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_engines": ['sw', 'gl_beta', 'wg_beta'],
"with_loaders": [False, 'tvg', 'svg', 'png', 'jpg', 'lottie', 'ttf', 'webp', 'all'],
"with_savers": [False, 'tvg', 'gif', 'all'],
"with_bindings": [False, 'capi', 'wasm_beta'],
"with_tools": [False, 'svg2tvg', 'svg2png', 'lottie2gif', 'all'],
"with_threads": [True, False],
"with_vector": [True, False],
"with_examples": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"with_engines": 'sw',
"with_loaders": 'all',
"with_savers": False,
"with_bindings": 'capi',
"with_tools": False,
"with_threads": True,
"with_vector": False,
"with_examples": False
}
# See more here: https://github.com/thorvg/thorvg/blob/main/meson_options.txt
options_description = {
"engines": "Enable Rasterizer Engine in thorvg",
"loaders": "Enable File Loaders in thorvg",
"savers": "Enable File Savers in thorvg",
"threads": "Enable the multi-threading task scheduler in thorvg",
"vector": "Enable CPU Vectorization(SIMD) in thorvg",
"bindings": "Enable API bindings",
"tools": "Enable building thorvg tools",
"examples": "Enable building examples",
}

@property
def _min_cppstd(self):
return 14

@property
def _compilers_minimum_version(self):
return {
"gcc": "6",
"clang": "5",
"apple-clang": "10",
"Visual Studio": "15",
"msvc": "191",
}

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

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

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

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

def build_requirements(self):
self.tool_requires("meson/1.4.0")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.1.0")

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

def generate(self):
tc = MesonToolchain(self, backend=("vs" if is_msvc(self) else None))
is_debug = self.settings.get_safe("build_type") == "Debug"
tc.project_options.update({
"engines": str(self.options.with_engines),
"loaders": str(self.options.with_loaders) if self.options.with_loaders else '',
"savers": str(self.options.with_savers) if self.options.with_savers else '',
"bindings": str(self.options.with_bindings) if self.options.with_bindings else '',
"tools": str(self.options.with_tools )if self.options.with_tools else '',
"threads": bool(self.options.with_threads),
"vector": bool(self.options.with_vector),
"examples": bool(self.options.with_examples),
"tests": False,
"log": is_debug
})
# Workaround to avoid: error D8016: '/O1' and '/RTC1' command-line options are incompatible
if is_msvc(self) and is_debug:
tc.project_options["optimization"] = "plain"
tc.generate()
tc = PkgConfigDeps(self)
tc.generate()
venv = VirtualBuildEnv(self)
venv.generate()

def _patch_sources(self):
# Workaround to avoid: Stripping target 'src\\thorvg-0.dll'.
if is_msvc(self) and self.options.shared:
replace_in_file(self, os.path.join(self.source_folder, "meson.build"), ", 'strip=true'", "")

def build(self):
self._patch_sources()
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
meson = Meson(self)
meson.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
fix_apple_shared_install_name(self)

if is_msvc(self) and not self.options.shared:
rename(self, os.path.join(self.package_folder, "lib", "libthorvg.a"), os.path.join(self.package_folder, "lib", "thorvg.lib"))

def package_info(self):
self.cpp_info.libs = ["thorvg"]

self.cpp_info.set_property("pkg_config_name", "libthorvg")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["pthread", "m"])
if not self.options.shared:
self.cpp_info.defines = ["TVG_STATIC"]
else:
self.cpp_info.defines = ["TVG_EXPORT", "TVG_BUILD"]
8 changes: 8 additions & 0 deletions recipes/thorvg/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(thorvg REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE thorvg::thorvg)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
26 changes: 26 additions & 0 deletions recipes/thorvg/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 requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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

int main() {
const int WIDTH = 800;
const int HEIGHT = 600;

tvg::Initializer::init(tvg::CanvasEngine::Sw, 0);

static uint32_t buffer[WIDTH * HEIGHT]; // canvas target buffer

auto canvas = tvg::SwCanvas::gen(); // generate a canvas
canvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::SwCanvas::ARGB8888); // buffer, stride, w, h, Colorspace

auto rect = tvg::Shape::gen(); // generate a shape
rect->appendRect(50, 50, 200, 200, 20, 20); // define it as a rounded rectangle (x, y, w, h, rx, ry)
rect->fill(100, 100, 100, 255); // set its color (r, g, b, a)
canvas->push(move(rect)); // push the rectangle into the canvas

auto circle = tvg::Shape::gen(); // generate a shape
circle->appendCircle(400, 400, 100, 100); // define it as a circle (cx, cy, rx, ry)

auto fill = tvg::RadialGradient::gen(); // generate a radial gradient
fill->radial(400, 400, 150); // set the radial gradient geometry info (cx, cy, radius)

tvg::Fill::ColorStop colorStops[2]; // gradient colors
colorStops[0] = {0.0, 255, 255, 255, 255}; // 1st color values (offset, r, g, b, a)
colorStops[1] = {1.0, 0, 0, 0, 255}; // 2nd color values (offset, r, g, b, a)
fill->colorStops(colorStops, 2); // set the gradient colors info

circle->fill(move(fill)); // set the circle fill
canvas->push(move(circle)); // push the circle into the canvas
}
3 changes: 3 additions & 0 deletions recipes/thorvg/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.13.0":
folder: all

0 comments on commit d6af901

Please sign in to comment.