Skip to content

Commit b41fefd

Browse files
authored
(#13918) plutovg: add version cci.20221030 and support conan v2
* plutovg: add version cci.20221030 and support conan v2 * add end line * fix license issue
1 parent 29725ed commit b41fefd

File tree

8 files changed

+81
-50
lines changed

8 files changed

+81
-50
lines changed

recipes/plutovg/all/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

recipes/plutovg/all/conandata.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
sources:
2+
"cci.20221030":
3+
url: "https://github.com/sammycage/plutovg/archive/4d0eee77ce7d1850aac4d90e20ddaaa313d83e6a.tar.gz"
4+
sha256: "bb44b1107d1cd41032fecdf3e16cff59a1a06f15a92527029aacb73c5c4d059e"
25
"cci.20220103":
36
url: "https://github.com/sammycage/plutovg/archive/51f1a79e04fbb42ec9e93499a18869eea06f3054.tar.gz"
47
sha256: "c2ce39b8085e0a8795263666f62af15239c36964330865fd54b9db25c67e063b"

recipes/plutovg/all/conanfile.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from conans import ConanFile, CMake, tools
1+
from conan import ConanFile
2+
from conan.tools.files import get, copy, replace_in_file
3+
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
4+
25
import os
36

4-
required_conan_version = ">=1.43.0"
7+
required_conan_version = ">=1.52.0"
58

69
class PlutoVGConan(ConanFile):
710
name = "plutovg"
@@ -21,52 +24,53 @@ class PlutoVGConan(ConanFile):
2124
"fPIC": True,
2225
}
2326

24-
exports_sources = ["CMakeLists.txt"]
25-
generators = "cmake"
26-
_cmake = None
27-
28-
@property
29-
def _source_subfolder(self):
30-
return "source_subfolder"
31-
3227
def config_options(self):
3328
if self.settings.os == "Windows":
3429
del self.options.fPIC
3530

3631
def configure(self):
3732
if self.options.shared:
38-
del self.options.fPIC
39-
del self.settings.compiler.libcxx
40-
del self.settings.compiler.cppstd
33+
try:
34+
del self.options.fPIC
35+
except Exception:
36+
pass
37+
try:
38+
del self.settings.compiler.libcxx
39+
except Exception:
40+
pass
41+
try:
42+
del self.settings.compiler.cppstd
43+
except Exception:
44+
pass
45+
46+
def layout(self):
47+
cmake_layout(self, src_folder="src")
4148

4249
def source(self):
43-
tools.get(**self.conan_data["sources"][self.version],
44-
destination=self._source_subfolder, strip_root=True)
50+
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
4551

46-
def _configure_cmake(self):
47-
if self._cmake:
48-
return self._cmake
49-
self._cmake = CMake(self)
50-
self._cmake.configure()
51-
return self._cmake
52+
def generate(self):
53+
tc = CMakeToolchain(self)
54+
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
55+
tc.generate()
5256

5357
def build(self):
54-
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
58+
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
5559
"add_library(plutovg STATIC)", "add_library(plutovg)")
56-
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
60+
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
5761
"add_subdirectory(example)", "")
58-
59-
cmake = self._configure_cmake()
62+
cmake = CMake(self)
63+
cmake.configure()
6064
cmake.build()
6165

6266
def package(self):
63-
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
64-
self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include"))
65-
self.copy(pattern="*.a", dst="lib", src="lib", keep_path=False)
66-
self.copy(pattern="*.so", dst="lib", src="lib", keep_path=False)
67-
self.copy(pattern="*.lib", dst="lib", src="lib", keep_path=False)
68-
self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False)
69-
self.copy(pattern="*.dylib", dst="lib", src="lib", keep_path=False)
67+
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
68+
copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include"))
69+
copy(self, pattern="*.a", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
70+
copy(self, pattern="*.so", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
71+
copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
72+
copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False)
73+
copy(self, pattern="*.dylib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
7074

7175
def package_info(self):
7276
self.cpp_info.libs = ["plutovg"]
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
cmake_minimum_required(VERSION 3.1)
22
project(test_package LANGUAGES C)
33

4-
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5-
conan_basic_setup(TARGETS)
6-
74
find_package(plutovg REQUIRED CONFIG)
85

96
add_executable(${PROJECT_NAME} test_package.c)
10-
target_link_libraries(${PROJECT_NAME} plutovg::plutovg)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE plutovg::plutovg)
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
from conans import ConanFile, CMake, tools
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import cmake_layout, CMake
24
import os
35

46
class TestPackageConan(ConanFile):
57
settings = "os", "arch", "compiler", "build_type"
6-
generators = "cmake", "cmake_find_package_multi"
8+
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
9+
test_type = "explicit"
10+
11+
def requirements(self):
12+
self.requires(self.tested_reference_str)
13+
14+
def layout(self):
15+
cmake_layout(self)
716

817
def build(self):
918
cmake = CMake(self)
1019
cmake.configure()
1120
cmake.build()
1221

1322
def test(self):
14-
if not tools.cross_building(self):
15-
bin_path = os.path.join("bin", "test_package")
16-
self.run(bin_path, run_environment=True)
23+
if can_run(self):
24+
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
25+
self.run(bin_path, env="conanrun")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package LANGUAGES C)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup(TARGETS)
6+
7+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
8+
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from conans import ConanFile, CMake
2+
from conan.tools.build import cross_building
3+
import os
4+
5+
class TestPackageV1Conan(ConanFile):
6+
settings = "os", "arch", "compiler", "build_type"
7+
generators = "cmake", "cmake_find_package_multi"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not cross_building(self):
16+
bin_path = os.path.join("bin", "test_package")
17+
self.run(bin_path, run_environment=True)

recipes/plutovg/config.yml

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

0 commit comments

Comments
 (0)