1
1
import os
2
- from conans import ConanFile , tools , AutoToolsBuildEnvironment
3
- from conans .errors import ConanInvalidConfiguration
4
2
5
- required_conan_version = ">=1.29.1"
3
+ from conan import ConanFile
4
+ from conan .tools .gnu import Autotools , AutotoolsToolchain
5
+ from conan .tools .files import copy , get , rmdir , rm
6
+ from conan .tools .layout import basic_layout
7
+ from conan .errors import ConanInvalidConfiguration
8
+
9
+ required_conan_version = ">=1.53.0"
6
10
7
11
class LibmnlConan (ConanFile ):
8
12
name = "libmnl"
@@ -14,50 +18,40 @@ class LibmnlConan(ConanFile):
14
18
settings = "os" , "compiler" , "build_type" , "arch"
15
19
options = {"shared" : [True , False ], "fPIC" : [True , False ]}
16
20
default_options = {"shared" : False , "fPIC" : True }
17
- _autotools = None
21
+ package_type = "library"
18
22
19
- @property
20
- def _source_subfolder (self ):
21
- return "source_subfolder"
23
+ def layout (self ):
24
+ basic_layout (self , src_folder = "src" )
22
25
23
26
def source (self ):
24
- tools .get (** self .conan_data ["sources" ][self .version ])
25
- extracted_dir = self .name + "-" + self .version
26
- os .rename (extracted_dir , self ._source_subfolder )
27
+ get (self , ** self .conan_data ["sources" ][self .version ], strip_root = True )
27
28
28
29
def configure (self ):
29
30
if self .settings .os != "Linux" :
30
31
raise ConanInvalidConfiguration ("libmnl is only supported on Linux" )
31
32
if self .options .shared :
32
- del self .options .fPIC
33
- del self .settings .compiler .libcxx
34
- del self .settings .compiler .cppstd
35
-
36
- def _configure_autotools (self ):
37
- if self ._autotools :
38
- return self ._autotools
39
- self ._autotools = AutoToolsBuildEnvironment (self )
40
- conf_args = []
41
- if self .options .shared :
42
- conf_args .extend (["--enable-shared" , "--disable-static" ])
43
- else :
44
- conf_args .extend (["--disable-shared" , "--enable-static" ])
45
- self ._autotools .configure (configure_dir = self ._source_subfolder , args = conf_args )
46
- return self ._autotools
33
+ self .options .rm_safe ("fPIC" )
34
+ self .settings .rm_safe ("compiler.libcxx" )
35
+ self .settings .rm_safe ("compiler.cppstd" )
36
+
37
+ def generate (self ):
38
+ tc = AutotoolsToolchain (self )
39
+ tc .generate ()
47
40
48
41
def build (self ):
49
- autotools = self ._configure_autotools ()
42
+ autotools = Autotools (self )
43
+ autotools .configure ()
50
44
autotools .make ()
51
45
52
46
def package (self ):
53
- self . copy ("COPYING" , dst = "licenses" , src = self ._source_subfolder )
54
- autotools = self . _configure_autotools ( )
47
+ copy (self , "COPYING" , src = self . source_folder , dst = os . path . join ( self .package_folder , "licenses" ) )
48
+ autotools = Autotools ( self )
55
49
autotools .install ()
56
50
57
- tools . remove_files_by_mask ( os .path .join (self .package_folder , "lib" ), "*.la" )
58
- tools . rmdir (os .path .join (self .package_folder , "share" ))
59
- tools . rmdir (os .path .join (self .package_folder , "etc" ))
60
- tools . rmdir (os .path .join (self .package_folder , "lib" , "pkgconfig" ))
51
+ rm ( self , "*.la" , os .path .join (self .package_folder , "lib" ))
52
+ rmdir (self , os .path .join (self .package_folder , "share" ))
53
+ rmdir (self , os .path .join (self .package_folder , "etc" ))
54
+ rmdir (self , os .path .join (self .package_folder , "lib" , "pkgconfig" ))
61
55
62
56
def package_info (self ):
63
57
self .cpp_info .libs = ["mnl" ]
0 commit comments