-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* blend2d: add recipe * generate patch * rename patch file name * add C++11 * add dl * make asmjit shared * define BL_STATIC * avoid static lib{std}c++ linking * make asmjit static * make asmjit shared when option.shared is True in Linux. * remove unused glob * link asmjit explicit * check CMAKE_BUILD_TYPE * remove VERBOSE option * unsupport Visual Studio < 16 * fix version comparing logic * make asmjit shared * try to fix compilation error on windows * modify the way to refer libs variables * remove unused patch
- Loading branch information
Showing
8 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(cmake_wrapper LANGUAGES CXX) | ||
|
||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup(KEEP_RPATHS) | ||
|
||
add_subdirectory(source_subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"0.0.17": | ||
url: "https://blend2d.com/download/blend2d-beta17.zip" | ||
sha256: "06ee8fb0bea281d09291e498900093139426501a1a7f09dba0ec801dd340635e" | ||
|
||
patches: | ||
"0.0.17": | ||
- base_path: "source_subfolder" | ||
patch_file: "patches/0.0.17-0001-disable-embed-asmjit.patch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
class Blend2dConan(ConanFile): | ||
name = "blend2d" | ||
description = "2D Vector Graphics Engine Powered by a JIT Compiler" | ||
topics = ("2d-graphics", "rasterization", "asmjit", "jit") | ||
license = "Zlib" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://blend2d.com/" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _is_msvc(self): | ||
return str(self.settings.compiler) in ["Visual Studio", "msvc"] | ||
|
||
def export_sources(self): | ||
self.copy("CMakeLists.txt") | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
self.copy(patch["patch_file"]) | ||
|
||
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 requirements(self): | ||
self.requires("asmjit/cci.20220210") | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, 11) | ||
|
||
# In Visual Studio < 16, there are compilation error. patch is already provided. | ||
# https://github.com/blend2d/blend2d/commit/63db360c7eb2c1c3ca9cd92a867dbb23dc95ca7d | ||
if self._is_msvc and tools.Version(self.settings.compiler.version) < "16": | ||
raise tools.ConanInvalidConfiguration("This recipe does not support this compiler version") | ||
|
||
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.definitions["BLEND2D_TEST"] = False | ||
self._cmake.definitions["BLEND2D_EMBED"] = False | ||
self._cmake.definitions["BLEND2D_STATIC"] = not self.options.shared | ||
self._cmake.definitions["BLEND2D_NO_STDCXX"] = False | ||
if not self.options.shared: | ||
self._cmake.definitions["CMAKE_C_FLAGS"] = "-DBL_STATIC" | ||
self._cmake.definitions["CMAKE_CXX_FLAGS"] = "-DBL_STATIC" | ||
self._cmake.configure() | ||
return self._cmake | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy(pattern="LICENSE.md", dst="licenses", src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["blend2d"] | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.extend(["pthread", "rt",]) | ||
if not self.options.shared: | ||
self.cpp_info.defines.append("BL_STATIC") |
19 changes: 19 additions & 0 deletions
19
recipes/blend2d/all/patches/0.0.17-0001-disable-embed-asmjit.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 52d295a..97dcd32 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -398,10 +398,10 @@ if (NOT BLEND2D_NO_JIT) | ||
set(ASMJIT_EMBED TRUE CACHE BOOL "") | ||
endif() | ||
|
||
- include("${ASMJIT_DIR}/CMakeLists.txt") | ||
- list(APPEND BLEND2D_DEPS ${ASMJIT_LIBS}) | ||
- list(APPEND BLEND2D_PRIVATE_CFLAGS ${ASMJIT_CFLAGS}) | ||
- list(APPEND BLEND2D_PRIVATE_CFLAGS -DASMJIT_NO_STDCXX) | ||
+ find_package(asmjit CONFIG REQUIRED) | ||
+ list(APPEND BLEND2D_DEPS ${asmjit_LIBRARIES_DEBUG}${asmjit_LIBRARIES_RELEASE}) | ||
+ list(APPEND BLEND2D_PRIVATE_CFLAGS ${asmjit_DEFINITIONS_DEBUG}${asmjit_DEFINITIONS_RELEASE}) | ||
+ | ||
|
||
# A possibility to reduce the resulting binary size by disabling asmjit logging. | ||
if (BLEND2D_NO_JIT_LOGGING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(blend2d CONFIG REQUIRED) | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package blend2d::blend2d) | ||
target_compile_features(test_package PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <iostream> | ||
|
||
#include "blend2d.h" | ||
|
||
int main() { | ||
auto img = BLImage(480, 480, BL_FORMAT_PRGB32); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.0.17": | ||
folder: all |