This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconanfile.py
executable file
·122 lines (104 loc) · 4.44 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from conans import ConanFile, CMake, tools
import os
class HarfbuzzConan(ConanFile):
name = "harfbuzz"
version = "2.6.7"
description = "HarfBuzz is an OpenType text shaping engine."
topics = ("conan", "harfbuzz", "opentype", "text", "engine")
url = "http://github.com/bincrafters/conan-harfbuzz"
homepage = "http://harfbuzz.org"
license = "MIT"
exports = ["FindHarfBuzz.cmake", "LICENSE.md"]
exports_sources = ["CMakeLists.txt", "source_subfolder.patch"]
generators = "cmake"
short_paths = True
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_freetype": [True, False],
"with_icu": [True, False],
"with_glib": [True, False],
"with_gdi": [True, False],
"with_uniscribe": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"with_freetype": True,
"with_icu": False,
"with_glib": True,
"with_gdi": True,
"with_uniscribe": True
}
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
def requirements(self):
if self.options.with_freetype:
self.requires.add("freetype/2.10.1")
if self.options.with_icu:
self.requires.add("icu/64.2")
if self.options.with_glib:
self.requires.add("glib/2.64.0@bincrafters/stable")
def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
else:
del self.options.with_gdi
del self.options.with_uniscribe
def source(self):
source_url = "https://github.com/harfbuzz/harfbuzz"
sha256 = "53974165e3a4b46624619a54407c7dc2cc77354ae1297b5ca1f8987569348693"
tools.get("{0}/archive/{1}.tar.gz".format(source_url, self.version), sha256=sha256)
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
tools.patch(patch_file="source_subfolder.patch")
def _configure_cmake_compiler_flags(self, cmake):
flags = []
compiler = str(self.settings.compiler)
if compiler in ("clang", "apple-clang"):
flags.append("-Wno-deprecated-declarations")
if self.settings.compiler == "gcc" and self.settings.os == "Windows":
flags.append("-Wa,-mbig-obj")
cmake.definitions["CMAKE_C_FLAGS"] = " ".join(flags)
cmake.definitions["CMAKE_CXX_FLAGS"] = cmake.definitions["CMAKE_C_FLAGS"]
return cmake
def _configure_cmake_macos(self, cmake):
if str(self.settings.os) in ["Macos", "iOS", "watchOS", "tvOS"]:
cmake.definitions["CMAKE_MACOSX_RPATH"] = True
return cmake
def _configure_cmake(self):
cmake = CMake(self)
cmake = self._configure_cmake_compiler_flags(cmake)
cmake = self._configure_cmake_macos(cmake)
cmake.definitions["HB_HAVE_FREETYPE"] = self.options.with_freetype
cmake.definitions["HB_BUILD_TESTS"] = False
cmake.definitions["HB_HAVE_ICU"] = self.options.with_icu
cmake.definitions["HB_HAVE_GLIB"] = self.options.with_glib
if self.options.with_icu:
cmake.definitions["CMAKE_CXX_STANDARD"] = "17"
if self.settings.os == "Windows":
cmake.definitions["HB_HAVE_GDI"] = self.options.with_gdi
cmake.definitions["HB_HAVE_UNISCRIBE"] = self.options.with_uniscribe
cmake.configure(build_folder=self._build_subfolder)
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy("FindHarfBuzz.cmake")
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.includedirs.append(os.path.join("include", "harfbuzz"))
if self.settings.os == "Linux":
self.cpp_info.system_libs.append("m")
if self.settings.os == "Windows" and not self.options.shared:
self.cpp_info.system_libs.extend(["dwrite", "rpcrt4", "usp10", "gdi32", "user32"])
if self.settings.os == "Macos":
self.cpp_info.frameworks.extend(["CoreFoundation", "CoreGraphics", "CoreText"])