1
+ from conan import ConanFile
2
+ from conan .errors import ConanInvalidConfiguration
3
+ from conan .tools .files import apply_conandata_patches , copy , export_conandata_patches , get , rm , rmdir
4
+ from conan .tools .gnu import Autotools , AutotoolsToolchain
5
+ from conan .tools .layout import basic_layout
1
6
import os
2
7
3
- from conans import ConanFile , AutoToolsBuildEnvironment , tools
4
- from conans .errors import ConanInvalidConfiguration
8
+ required_conan_version = ">=1.53.0"
5
9
6
- required_conan_version = ">=1.29.1"
7
10
8
11
class LibnumaConan (ConanFile ):
9
12
name = "libnuma"
10
13
description = "NUMA support for Linux."
11
14
license = "LGPL-2.1-or-later"
12
- topics = ("conan" , " numa" )
15
+ topics = ("numa" )
13
16
homepage = "https://github.com/numactl/numactl"
14
17
url = "https://github.com/conan-io/conan-center-index"
18
+
15
19
settings = "os" , "arch" , "compiler" , "build_type"
16
20
options = {
17
21
"shared" : [True , False ],
@@ -21,60 +25,47 @@ class LibnumaConan(ConanFile):
21
25
"shared" : False ,
22
26
"fPIC" : True ,
23
27
}
24
- exports_sources = "patches/**"
25
-
26
- _autotools = None
27
28
28
- @property
29
- def _source_subfolder (self ):
30
- return "source_subfolder"
29
+ def export_sources (self ):
30
+ export_conandata_patches (self )
31
31
32
32
def configure (self ):
33
- if self .settings .os != "Linux" :
34
- raise ConanInvalidConfiguration ("{} is only supported on Linux" .format (self .name ))
35
- del self .settings .compiler .libcxx
36
- del self .settings .compiler .cppstd
37
33
if self .options .shared :
38
34
del self .options .fPIC
35
+ self .settings .rm_safe ("compiler.cppstd" )
36
+ self .settings .rm_safe ("compiler.libcxx" )
39
37
40
- def _patch_sources (self ):
41
- for patch in self .conan_data .get ("patches" ,{}).get (self .version , []):
42
- tools .patch (** patch )
43
-
44
- def source (self ):
45
- tools .get (** self .conan_data ["sources" ][self .version ])
46
- os .rename ("numactl-" + self .version , self ._source_subfolder )
38
+ def layout (self ):
39
+ basic_layout (self , src_folder = "src" )
47
40
48
- def _configure_autotools (self ):
49
- if self ._autotools :
50
- return self . _autotools
41
+ def validate (self ):
42
+ if self .info . settings . os != "Linux" :
43
+ raise ConanInvalidConfiguration ( "libnuma is only supported on Linux" )
51
44
52
- self ._autotools = AutoToolsBuildEnvironment (self )
53
-
54
- args = []
55
- if self .options .shared :
56
- args .extend (["--disable-static" , "--enable-shared" ])
57
- else :
58
- args .extend (["--disable-shared" , "--enable-static" ])
45
+ def source (self ):
46
+ get (self , ** self .conan_data ["sources" ][self .version ],
47
+ destination = self .source_folder , strip_root = True )
59
48
60
- self ._autotools .configure (args = args , configure_dir = self ._source_subfolder )
61
- return self ._autotools
49
+ def generate (self ):
50
+ tc = AutotoolsToolchain (self )
51
+ tc .generate ()
62
52
63
53
def build (self ):
64
- self ._patch_sources ()
65
- autotools = self ._configure_autotools ()
54
+ apply_conandata_patches (self )
55
+ autotools = Autotools (self )
56
+ autotools .configure ()
66
57
autotools .make ()
67
58
68
59
def package (self ):
69
- self . copy ("LICENSE.LGPL2.1" , dst = "licenses" , src = self ._source_subfolder )
70
- autotools = self . _configure_autotools ( )
60
+ copy (self , "LICENSE.LGPL2.1" , src = self . source_folder , dst = os . path . join ( self .package_folder , "licenses" ) )
61
+ autotools = Autotools ( self )
71
62
autotools .install ()
72
- tools . rmdir (os .path .join (self .package_folder , "bin" ))
73
- tools . rmdir (os .path .join (self .package_folder , "lib" , "pkgconfig" ))
74
- tools . rmdir (os .path .join (self .package_folder , "share" ))
75
- tools . remove_files_by_mask ( os .path .join (self .package_folder , "lib" ), "*.la" )
63
+ rmdir (self , os .path .join (self .package_folder , "bin" ))
64
+ rmdir (self , os .path .join (self .package_folder , "lib" , "pkgconfig" ))
65
+ rmdir (self , os .path .join (self .package_folder , "share" ))
66
+ rm ( self , "*.la" , os .path .join (self .package_folder , "lib" ))
76
67
77
68
def package_info (self ):
69
+ self .cpp_info .set_property ("pkg_config_name" , "numa" )
78
70
self .cpp_info .libs = ["numa" ]
79
- self .cpp_info .names ["pkg_config" ] = "numa"
80
71
self .cpp_info .system_libs = ["dl" , "pthread" ]
0 commit comments