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 ):
@@ -12,83 +17,91 @@ class Libdc1394Conan(ConanFile):
12
17
url = "https://github.com/conan-io/conan-center-index"
13
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
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
+ }
22
31
23
32
@property
24
- def _source_subfolder (self ):
25
- return "source_subfolder"
33
+ def _user_info_build (self ):
34
+ return getattr ( self , "user_info_build" , self . deps_user_info )
26
35
27
36
def config_options (self ):
28
37
if self .settings .os == "Windows" :
29
38
del self .options .fPIC
30
39
31
40
def configure (self ):
32
41
if self .options .shared :
33
- del self .options .fPIC
34
- del self .settings .compiler .libcxx
35
- del self .settings .compiler .cppstd
42
+ self .options .rm_safe ("fPIC" )
43
+ self .settings .rm_safe ("compiler.cppstd" )
44
+ self .settings .rm_safe ("compiler.libcxx" )
45
+
46
+ def layout (self ):
47
+ basic_layout (self , src_folder = "src" )
36
48
37
49
def requirements (self ):
38
- self .requires ("libusb/1.0.24 " )
50
+ self .requires ("libusb/1.0.26 " )
39
51
40
52
def validate (self ):
41
- if self .settings .os == "Windows" :
53
+ if self .info . settings .os == "Windows" :
42
54
raise ConanInvalidConfiguration ("Windows is not supported yet in this recipe" )
43
- if self .settings .compiler == "clang" :
55
+ if self .info . settings .compiler == "clang" :
44
56
raise ConanInvalidConfiguration ("Clang doesn't support VLA" )
45
57
46
58
def build_requirements (self ):
47
- self .build_requires ("gnu-config/cci.20201022" )
48
- self .build_requires ("pkgconf/1.7.4" )
59
+ self .tool_requires ("gnu-config/cci.20210814" )
60
+ if not self .conf .get ("tools.gnu:pkg_config" , check_type = str ):
61
+ self .tool_requires ("pkgconf/1.9.3" )
49
62
50
63
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
64
+ get (self , ** self .conan_data ["sources" ][self .version ],
65
+ destination = self .source_folder , strip_root = True )
66
+
67
+ def generate (self ):
68
+ env = VirtualBuildEnv (self )
69
+ env .generate ()
70
+ tc = AutotoolsToolchain (self )
71
+ tc .configure_args .append ("--disable-examples" )
72
+ tc .generate ()
73
+ deps = PkgConfigDeps (self )
74
+ deps .generate ()
75
+
76
+ def _patch_sources (self ):
77
+ for gnu_config in [
78
+ self .conf .get ("user.gnu-config:config_guess" , check_type = str ),
79
+ self .conf .get ("user.gnu-config:config_sub" , check_type = str ),
80
+ ]:
81
+ if gnu_config :
82
+ copy (self , os .path .basename (gnu_config ), src = os .path .dirname (gnu_config ), dst = self .source_folder )
68
83
69
84
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 ()
85
+ self ._patch_sources ()
86
+ with chdir (self , self .source_folder ):
87
+ autotools = Autotools (self )
88
+ autotools .configure ()
89
+ autotools .make ()
77
90
78
91
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" )
92
+ copy ( self , "COPYING" , src = self . source_folder , dst = os . path . join (self .package_folder , "licenses" ))
93
+ with chdir ( self , self .source_folder ):
94
+ autotools = Autotools ( self )
95
+ autotools . install ()
96
+ rmdir ( self , os . path . join ( self .package_folder , "share" ) )
97
+ rmdir (self , os .path .join (self .package_folder , "lib" , "pkgconfig " ))
98
+ rm ( self , "*.la" , os .path .join (self .package_folder , "lib" ))
99
+ fix_apple_shared_install_name ( self )
87
100
88
101
def package_info (self ):
89
- self .cpp_info .names [ "pkg_config" ] = "libdc1394-{}" . format ( tools . Version (self .version ).major )
102
+ self .cpp_info .set_property ( "pkg_config_name" , f "libdc1394-{ Version (self .version ).major } " )
90
103
self .cpp_info .libs = ["dc1394" ]
91
104
if self .settings .os in ["Linux" , "FreeBSD" ]:
92
105
self .cpp_info .system_libs .append ("m" )
93
- elif tools . is_apple_os (self . settings . os ):
106
+ elif is_apple_os (self ):
94
107
self .cpp_info .frameworks .extend (["CoreFoundation" , "CoreServices" , "IOKit" ])
0 commit comments