3
3
from conan import ConanFile
4
4
from conan .errors import ConanInvalidConfiguration
5
5
from conan .tools .build import cross_building
6
- from conan .tools .env import Environment , VirtualBuildEnv , VirtualRunEnv
6
+ from conan .tools .env import VirtualBuildEnv , VirtualRunEnv
7
7
from conan .tools .files import get , rmdir , export_conandata_patches , apply_conandata_patches , copy , chdir , replace_in_file , rm
8
- from conan .tools .gnu import AutotoolsToolchain , Autotools
9
- from conan .tools .microsoft import unix_path , is_msvc
10
- from conan .tools .scm import Version
8
+ from conan .tools .gnu import AutotoolsToolchain , Autotools , AutotoolsDeps
9
+ from conan .tools .layout import basic_layout
10
+ from conan .tools .microsoft import unix_path , is_msvc , check_min_vs
11
11
12
12
required_conan_version = ">=1.33.0"
13
13
@@ -22,8 +22,16 @@ class LibIdnConan(ConanFile):
22
22
23
23
package_type = "library"
24
24
settings = "os" , "arch" , "compiler" , "build_type"
25
- options = {"shared" : [True , False ], "fPIC" : [True , False ], "threads" : [True , False ]}
26
- default_options = {"shared" : False , "fPIC" : True , "threads" : True }
25
+ options = {
26
+ "shared" : [True , False ],
27
+ "fPIC" : [True , False ],
28
+ "threads" : [True , False ],
29
+ }
30
+ default_options = {
31
+ "shared" : False ,
32
+ "fPIC" : True ,
33
+ "threads" : True ,
34
+ }
27
35
28
36
@property
29
37
def _settings_build (self ):
@@ -39,8 +47,11 @@ def config_options(self):
39
47
def configure (self ):
40
48
if self .options .shared :
41
49
self .options .rm_safe ("fPIC" )
42
- del self .settings .compiler .libcxx
43
- del self .settings .compiler .cppstd
50
+ self .settings .rm_safe ("compiler.libcxx" )
51
+ self .settings .rm_safe ("compiler.cppstd" )
52
+
53
+ def layout (self ):
54
+ basic_layout (self , src_folder = "src" )
44
55
45
56
def requirements (self ):
46
57
self .requires ("libiconv/1.17" )
@@ -55,7 +66,7 @@ def build_requirements(self):
55
66
if not self .conf .get ("tools.microsoft.bash:path" , check_type = str ):
56
67
self .tool_requires ("msys2/cci.latest" )
57
68
if is_msvc (self ):
58
- self .tool_requires ("automake /1.16.5 " )
69
+ self .tool_requires ("cccl /1.3 " )
59
70
60
71
def source (self ):
61
72
get (self , ** self .conan_data ["sources" ][self .version ], strip_root = True )
@@ -67,36 +78,25 @@ def generate(self):
67
78
env = VirtualRunEnv (self )
68
79
env .generate (scope = "build" )
69
80
tc = AutotoolsToolchain (self )
70
- tc .libs = []
71
81
if not self .options .shared :
72
82
tc .defines .append ("LIBIDN_STATIC" )
83
+ env = tc .environment ()
73
84
if is_msvc (self ):
74
- if Version (self .settings .compiler .version ) >= "12" :
85
+ env .define ("CC" , "cccl" )
86
+ env .define ("CXX" , "cccl" )
87
+ env .define ("LD" , "cccl" )
88
+ if check_min_vs (self , 180 , raise_invalid = False ):
75
89
tc .extra_cflags .append ("-FS" )
76
- tc .extra_ldflags += ["-L{}" .format (p .replace ("\\ " , "/" )) for p in self .deps_cpp_info .lib_paths ]
77
90
yes_no = lambda v : "yes" if v else "no"
78
91
tc .configure_args += [
79
92
"--enable-threads={}" .format (yes_no (self .options .threads )),
80
- "--with-libiconv-prefix={}" .format (unix_path (self , self .dependencies ["libiconv" ].cpp_info . libdirs [ 0 ] )), # FIXME
93
+ "--with-libiconv-prefix={}" .format (unix_path (self , self .dependencies ["libiconv" ].package_folder )),
81
94
"--disable-nls" ,
82
95
"--disable-rpath" ,
83
96
]
84
- tc .generate ()
85
-
86
- if is_msvc (self ):
87
- env = Environment ()
88
- automake_conf = self .dependencies .build ["automake" ].conf_info
89
- compile_wrapper = unix_path (self , automake_conf .get ("user.automake:compile-wrapper" , check_type = str ))
90
- ar_wrapper = unix_path (self , automake_conf .get ("user.automake:lib-wrapper" , check_type = str ))
91
- env .define ("CC" , f"{ compile_wrapper } cl -nologo" )
92
- env .define ("CXX" , f"{ compile_wrapper } cl -nologo" )
93
- env .define ("LD" , "link -nologo" )
94
- env .define ("AR" , f'{ ar_wrapper } "lib -nologo"' )
95
- env .define ("NM" , "dumpbin -symbols" )
96
- env .define ("OBJDUMP" , ":" )
97
- env .define ("RANLIB" , ":" )
98
- env .define ("STRIP" , ":" )
99
- env .vars (self ).save_script ("conanbuild_msvc" )
97
+ tc .generate (env )
98
+ deps = AutotoolsDeps (self )
99
+ deps .generate ()
100
100
101
101
def _patch_sources (self ):
102
102
apply_conandata_patches (self )
@@ -106,6 +106,12 @@ def _patch_sources(self):
106
106
else :
107
107
ssize = "signed long int"
108
108
replace_in_file (self , os .path .join (self .source_folder , "lib" , "stringprep.h" ), "ssize_t" , ssize )
109
+ if self .settings .os == "Windows" :
110
+ # Otherwise tries to create a symlink from GNUmakefile to itself, which fails on Windows
111
+ replace_in_file (self , os .path .join (self .source_folder , "configure" ),
112
+ '"$GNUmakefile") CONFIG_LINKS="$CONFIG_LINKS $GNUmakefile:$GNUmakefile" ;;' , "" )
113
+ replace_in_file (self , os .path .join (self .source_folder , "configure" ),
114
+ 'ac_config_links="$ac_config_links $GNUmakefile:$GNUmakefile"' , "" )
109
115
110
116
def build (self ):
111
117
self ._patch_sources ()
0 commit comments