Skip to content

Commit 4b952ed

Browse files
committed
[thorvg] update to 1.0.1
1 parent 9ffe686 commit 4b952ed

File tree

6 files changed

+91
-12
lines changed

6 files changed

+91
-12
lines changed

recipes/thorvg/all/conandata.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
sources:
2+
"1.0.1":
3+
url: "https://github.com/thorvg/thorvg/archive/refs/tags/v1.0.1.tar.gz"
4+
sha256: "061343ed560f08ef2f7b48a7f6b684ae6bfd50b7904599d8581e466b2531844f"
25
"0.15.16":
36
url: "https://github.com/thorvg/thorvg/archive/refs/tags/v0.15.16.tar.gz"
47
sha256: "a7fc0aaf9e1aa5c1bc8f4f2035571ce87136a3c65fd9b3019eb25f9c58fba83c"

recipes/thorvg/all/conanfile.py

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ class ThorvgConan(ConanFile):
2727
options = {
2828
"shared": [True, False],
2929
"fPIC": [True, False],
30-
"with_engines": ['sw', 'gl_beta', 'wg_beta', "gl"],
30+
"with_engines": ['sw', 'gl_beta', 'wg_beta', "gl", "wg", "all"],
3131
"with_loaders": [False, 'tvg', 'svg', 'png', 'jpg', 'lottie', 'ttf', 'webp', 'all'],
3232
"with_savers": [False, 'tvg', 'gif', 'all'],
3333
"with_bindings": [False, 'capi', 'wasm_beta'],
3434
"with_tools": [False, 'svg2tvg', 'svg2png', 'lottie2gif', 'all'],
3535
"with_threads": [True, False],
3636
"with_simd": [True, False],
3737
"with_examples": [True, False],
38-
"with_extra": [False, 'lottie_expressions'],
38+
"with_lottie_exp": [False, True],
39+
"with_openmp": [False, True],
40+
"with_gl_variant": [False, True],
3941
"with_file": [True, False],
4042
}
4143
default_options = {
@@ -49,7 +51,9 @@ class ThorvgConan(ConanFile):
4951
"with_threads": True,
5052
"with_simd": False,
5153
"with_examples": False,
52-
"with_extra": 'lottie_expressions',
54+
"with_lottie_exp": True,
55+
"with_openmp": False,
56+
"with_gl_variant": False,
5357
"with_file": True,
5458
}
5559
# See more here: https://github.com/thorvg/thorvg/blob/main/meson_options.txt
@@ -62,7 +66,9 @@ class ThorvgConan(ConanFile):
6266
"with_bindings": "Enable API bindings",
6367
"with_tools": "Enable building thorvg tools",
6468
"with_examples": "Enable building examples",
65-
"with_extra": "Enable support for exceptionally advanced features",
69+
"with_lottie_exp": "Enable support for Lottie Expressions",
70+
"with_openmp": "Enable support for OpenMP",
71+
"with_gl_variant": "Enable support for OpenGL Variant",
6672
}
6773
short_paths = True
6874

@@ -111,6 +117,24 @@ def validate(self):
111117
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=gl, use with_engines=gl_beta instead")
112118
if Version(self.version) >= "0.14.0" and self.options.with_engines in ["gl_beta"]:
113119
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=gl_beta, use with_engines=gl instead")
120+
if Version(self.version) < "1.0.0" and self.options.with_engines in ["wg"]:
121+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=wg, use with_engines=wg_beta instead")
122+
if Version(self.version) >= "1.0.0" and self.options.with_engines in ["wg_beta"]:
123+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=wg_beta, use with_engines=wg instead")
124+
if Version(self.version) < "1.0.0" and self.options.with_engines in ["all"]:
125+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=all")
126+
if Version(self.version) >= "1.0.0" and self.options.with_loaders in ["tvg"]:
127+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_loaders=tvg")
128+
if Version(self.version) >= "1.0.0" and self.options.with_savers in ["tvg"]:
129+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_savers=tvg")
130+
if Version(self.version) >= "1.0.0" and self.options.with_bindings in ["wasm_beta"]:
131+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_bindings=wasm_beta")
132+
if Version(self.version) >= "1.0.0" and self.options.with_tools in ["svg2tvg"]:
133+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_tools=svg2tvg")
134+
if Version(self.version) < "1.0.0" and self.options.with_openmp is True:
135+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_openmp=True")
136+
if Version(self.version) < "1.0.0" and self.options.with_gl_variant is True:
137+
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_gl_variant=True")
114138

115139
def requirements(self):
116140
loaders_opt = str(self.options.with_loaders)
@@ -142,18 +166,29 @@ def generate(self):
142166
"bindings": str(self.options.with_bindings) if self.options.with_bindings else '',
143167
"tools": str(self.options.with_tools )if self.options.with_tools else '',
144168
"threads": bool(self.options.with_threads),
145-
"examples": bool(self.options.with_examples),
146169
"tests": False,
147170
"log": is_debug,
148171
})
149172
# Workaround to avoid: error D8016: '/O1' and '/RTC1' command-line options are incompatible
150173
if is_msvc(self) and is_debug:
151174
tc.project_options["optimization"] = "plain"
152175
tc.project_options["simd"] = bool(self.options.with_simd)
153-
if self.options.with_extra:
154-
tc.project_options["extra"] = str(self.options.with_extra)
176+
extras = []
177+
if self.options.with_lottie_exp:
178+
if Version(self.version) < "1.0.0":
179+
extras.append("lottie_expressions")
180+
else:
181+
extras.append("lottie_exp")
182+
if self.options.with_openmp:
183+
extras.append("openmp")
184+
if self.options.with_gl_variant:
185+
extras.append("gl_variant")
186+
if extras:
187+
tc.project_options["extra"] = ",".join(extras)
155188
if "with_file" in self.options:
156189
tc.project_options["file"] = self.options.with_file
190+
if Version(self.version) < "1.0.0":
191+
tc.project_options["examples"] = bool(self.options.with_examples)
157192
tc.generate()
158193
tc = PkgConfigDeps(self)
159194
tc.generate()
@@ -165,8 +200,8 @@ def _patch_sources(self):
165200
if is_msvc(self) and self.options.shared:
166201
replace_in_file(self, os.path.join(self.source_folder, "meson.build"), ", 'strip=true'", "")
167202

168-
# TODO: As OpenMP is tagged as "required: false", let's disable it for now to avoid extra flags and requirements injections.
169-
if Version(self.version) >= "0.15.1" and self.options.with_threads:
203+
if Version(self.version) >= "0.15.1" and Version(self.version) < "1.0.0" and self.options.with_threads:
204+
# As OpenMP is tagged as "required: false", let's disable it for now to avoid extra flags and requirements injections.
170205
# Notice that the use of disabler() is not working here. If it's used, there is no targets to build.
171206
replace_in_file(self, os.path.join(self.source_folder, "src", "renderer", "sw_engine", "meson.build"),
172207
"omp_dep = dependency('openmp', required: false)",
@@ -193,7 +228,10 @@ def package(self):
193228
rename(self, os.path.join(self.package_folder, "lib", "libthorvg.a"), os.path.join(self.package_folder, "lib", "thorvg.lib"))
194229

195230
def package_info(self):
196-
self.cpp_info.libs = ["thorvg"]
231+
if Version(self.version) >= "1.0.0":
232+
self.cpp_info.libs = ["thorvg-1"]
233+
else:
234+
self.cpp_info.libs = ["thorvg"]
197235

198236
self.cpp_info.set_property("pkg_config_name", "libthorvg")
199237
if self.settings.os in ["Linux", "FreeBSD"]:

recipes/thorvg/all/test_package/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ project(test_package LANGUAGES CXX)
33

44
find_package(thorvg REQUIRED CONFIG)
55

6-
add_executable(${PROJECT_NAME} test_package.cpp)
6+
if(thorvg_VERSION_MAJOR LESS 1)
7+
add_executable(${PROJECT_NAME} test_package-v0.cpp)
8+
else()
9+
add_executable(${PROJECT_NAME} test_package-v1.cpp)
10+
endif()
711
target_link_libraries(${PROJECT_NAME} PRIVATE thorvg::thorvg)
812
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

recipes/thorvg/all/test_package/test_package.cpp renamed to recipes/thorvg/all/test_package/test_package-v0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ int main() {
2929

3030
circle->fill(std::move(fill)); // set the circle fill
3131
canvas->push(std::move(circle)); // push the circle into the canvas
32-
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "thorvg-1/thorvg.h"
2+
3+
int main() {
4+
const int WIDTH = 800;
5+
const int HEIGHT = 600;
6+
7+
tvg::Initializer::init(0);
8+
9+
static uint32_t buffer[WIDTH * HEIGHT]; // canvas target buffer
10+
11+
auto canvas = tvg::SwCanvas::gen(); // generate a canvas
12+
canvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::ColorSpace::ARGB8888); // buffer, stride, w, h, Colorspace
13+
14+
auto rect = tvg::Shape::gen(); // generate a shape
15+
rect->appendRect(50, 50, 200, 200, 20, 20); // define it as a rounded rectangle (x, y, w, h, rx, ry)
16+
rect->fill(100, 100, 100, 255); // set its color (r, g, b, a)
17+
canvas->add(std::move(rect)); // push the rectangle into the canvas
18+
19+
auto circle = tvg::Shape::gen(); // generate a shape
20+
circle->appendCircle(400, 400, 100, 100); // define it as a circle (cx, cy, rx, ry)
21+
22+
auto fill = tvg::RadialGradient::gen(); // generate a radial gradient
23+
fill->radial(400, 400, 150, 400, 400, 150); // set the radial gradient geometry info (cx, cy, r, fx, fy, fr)
24+
25+
tvg::Fill::ColorStop colorStops[2]; // gradient colors
26+
colorStops[0] = {0.0, 255, 255, 255, 255}; // 1st color values (offset, r, g, b, a)
27+
colorStops[1] = {1.0, 0, 0, 0, 255}; // 2nd color values (offset, r, g, b, a)
28+
fill->colorStops(colorStops, 2); // set the gradient colors info
29+
30+
circle->fill(std::move(fill)); // set the circle fill
31+
canvas->add(std::move(circle)); // push the circle into the canvas
32+
}

recipes/thorvg/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
versions:
2+
"1.0.0":
3+
folder: all
24
"0.15.16":
35
folder: all

0 commit comments

Comments
 (0)