|
1 |
| -from conans import ConanFile, AutoToolsBuildEnvironment, tools |
2 |
| -from conans.errors import ConanInvalidConfiguration |
| 1 | +from conan import ConanFile |
| 2 | +from conan.errors import ConanInvalidConfiguration |
| 3 | +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os |
| 4 | +from conan.tools.env import VirtualBuildEnv |
| 5 | +from conan.tools.files import chdir, copy, get, rm, rmdir |
| 6 | +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps |
| 7 | +from conan.tools.layout import basic_layout |
| 8 | +from conan.tools.scm import Version |
3 | 9 | import os
|
4 |
| -import shutil |
5 | 10 |
|
6 |
| -required_conan_version = ">=1.33.0" |
| 11 | +required_conan_version = ">=1.53.0" |
7 | 12 |
|
8 | 13 |
|
9 | 14 | class Libdc1394Conan(ConanFile):
|
10 | 15 | name = "libdc1394"
|
11 | 16 | license = "LGPL-2.1-or-later"
|
12 | 17 | url = "https://github.com/conan-io/conan-center-index"
|
13 |
| - homepage = 'https://damien.douxchamps.net/ieee1394/libdc1394/' |
| 18 | + homepage = "https://damien.douxchamps.net/ieee1394/libdc1394/" |
14 | 19 | description = "libdc1394 provides a complete high level API to control IEEE 1394 based cameras"
|
15 |
| - topics = ("conan", "ieee1394", "camera", "iidc", "dcam") |
16 |
| - settings = "os", "compiler", "build_type", "arch" |
17 |
| - options = {"shared": [True, False], "fPIC": [True, False]} |
18 |
| - default_options = {"shared": False, "fPIC": True} |
19 |
| - |
20 |
| - generators = "pkg_config" |
21 |
| - _env_build = None |
22 |
| - |
23 |
| - @property |
24 |
| - def _source_subfolder(self): |
25 |
| - return "source_subfolder" |
| 20 | + topics = ("ieee1394", "camera", "iidc", "dcam") |
| 21 | + |
| 22 | + settings = "os", "arch", "compiler", "build_type" |
| 23 | + options = { |
| 24 | + "shared": [True, False], |
| 25 | + "fPIC": [True, False], |
| 26 | + } |
| 27 | + default_options = { |
| 28 | + "shared": False, |
| 29 | + "fPIC": True, |
| 30 | + } |
26 | 31 |
|
27 | 32 | def config_options(self):
|
28 | 33 | if self.settings.os == "Windows":
|
29 | 34 | del self.options.fPIC
|
30 | 35 |
|
31 | 36 | def configure(self):
|
32 | 37 | if self.options.shared:
|
33 |
| - del self.options.fPIC |
34 |
| - del self.settings.compiler.libcxx |
35 |
| - del self.settings.compiler.cppstd |
| 38 | + self.options.rm_safe("fPIC") |
| 39 | + self.settings.rm_safe("compiler.cppstd") |
| 40 | + self.settings.rm_safe("compiler.libcxx") |
| 41 | + |
| 42 | + def layout(self): |
| 43 | + basic_layout(self, src_folder="src") |
36 | 44 |
|
37 | 45 | def requirements(self):
|
38 |
| - self.requires("libusb/1.0.24") |
| 46 | + self.requires("libusb/1.0.26") |
39 | 47 |
|
40 | 48 | def validate(self):
|
41 |
| - if self.settings.os == "Windows": |
| 49 | + if self.info.settings.os == "Windows": |
42 | 50 | raise ConanInvalidConfiguration("Windows is not supported yet in this recipe")
|
43 |
| - if self.settings.compiler == "clang": |
| 51 | + if self.info.settings.compiler == "clang": |
44 | 52 | raise ConanInvalidConfiguration("Clang doesn't support VLA")
|
45 | 53 |
|
46 | 54 | def build_requirements(self):
|
47 |
| - self.build_requires("gnu-config/cci.20201022") |
48 |
| - self.build_requires("pkgconf/1.7.4") |
| 55 | + self.tool_requires("gnu-config/cci.20210814") |
| 56 | + if not self.conf.get("tools.gnu:pkg_config", check_type=str): |
| 57 | + self.tool_requires("pkgconf/1.9.3") |
49 | 58 |
|
50 | 59 | def source(self):
|
51 |
| - tools.get(**self.conan_data["sources"][self.version], |
52 |
| - destination=self._source_subfolder, strip_root=True) |
53 |
| - |
54 |
| - @property |
55 |
| - def _user_info_build(self): |
56 |
| - return getattr(self, "user_info_build", None) or self.deps_user_info |
57 |
| - |
58 |
| - def _configure_autotools(self): |
59 |
| - if not self._env_build: |
60 |
| - self._env_build = AutoToolsBuildEnvironment(self) |
61 |
| - if self.options.shared: |
62 |
| - args = ["--disable-static", "--enable-shared"] |
63 |
| - else: |
64 |
| - args = ["--disable-shared", "--enable-static"] |
65 |
| - args.extend(["--disable-examples"]) |
66 |
| - self._env_build.configure(args=args) |
67 |
| - return self._env_build |
| 60 | + get(self, **self.conan_data["sources"][self.version], |
| 61 | + destination=self.source_folder, strip_root=True) |
| 62 | + |
| 63 | + def generate(self): |
| 64 | + env = VirtualBuildEnv(self) |
| 65 | + env.generate() |
| 66 | + tc = AutotoolsToolchain(self) |
| 67 | + tc.configure_args.append("--disable-examples") |
| 68 | + tc.generate() |
| 69 | + deps = PkgConfigDeps(self) |
| 70 | + deps.generate() |
| 71 | + |
| 72 | + def _patch_sources(self): |
| 73 | + for gnu_config in [ |
| 74 | + self.conf.get("user.gnu-config:config_guess", check_type=str), |
| 75 | + self.conf.get("user.gnu-config:config_sub", check_type=str), |
| 76 | + ]: |
| 77 | + if gnu_config: |
| 78 | + copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder) |
68 | 79 |
|
69 | 80 | def build(self):
|
70 |
| - shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, |
71 |
| - os.path.join(self._source_subfolder, "config.sub")) |
72 |
| - shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, |
73 |
| - os.path.join(self._source_subfolder, "config.guess")) |
74 |
| - with tools.chdir(self._source_subfolder): |
75 |
| - env_build = self._configure_autotools() |
76 |
| - env_build.make() |
| 81 | + self._patch_sources() |
| 82 | + with chdir(self, self.source_folder): |
| 83 | + autotools = Autotools(self) |
| 84 | + autotools.configure() |
| 85 | + autotools.make() |
77 | 86 |
|
78 | 87 | def package(self):
|
79 |
| - with tools.chdir(self._source_subfolder): |
80 |
| - env_build = self._configure_autotools() |
81 |
| - env_build.install() |
82 |
| - |
83 |
| - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") |
84 |
| - tools.rmdir(os.path.join(self.package_folder, "share")) |
85 |
| - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) |
86 |
| - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") |
| 88 | + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) |
| 89 | + with chdir(self, self.source_folder): |
| 90 | + autotools = Autotools(self) |
| 91 | + autotools.install() |
| 92 | + rmdir(self, os.path.join(self.package_folder, "share")) |
| 93 | + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) |
| 94 | + rm(self, "*.la", os.path.join(self.package_folder, "lib")) |
| 95 | + fix_apple_shared_install_name(self) |
87 | 96 |
|
88 | 97 | def package_info(self):
|
89 |
| - self.cpp_info.names["pkg_config"] = "libdc1394-{}".format(tools.Version(self.version).major) |
| 98 | + self.cpp_info.set_property("pkg_config_name", f"libdc1394-{Version(self.version).major}") |
90 | 99 | self.cpp_info.libs = ["dc1394"]
|
91 | 100 | if self.settings.os in ["Linux", "FreeBSD"]:
|
92 | 101 | self.cpp_info.system_libs.append("m")
|
93 |
| - elif tools.is_apple_os(self.settings.os): |
| 102 | + elif is_apple_os(self): |
94 | 103 | self.cpp_info.frameworks.extend(["CoreFoundation", "CoreServices", "IOKit"])
|
0 commit comments