19
19
components = sys .argv [2 ].split (' ' )
20
20
components = [i for i in components if i ] # ignore extra whitespaces
21
21
enable_static = sys .argv [3 ]
22
+ llconfig = sys .argv [4 ]
22
23
23
24
f .write ("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
24
25
// file at the top-level directory of this distribution and at
@@ -44,69 +45,47 @@ def run(args):
44
45
sys .exit (1 )
45
46
return out
46
47
47
- for llconfig in sys .argv [4 :]:
48
- f .write ("\n " )
49
-
50
- out = run ([llconfig , '--host-target' ])
51
- arch , os = out .split ('-' , 1 )
52
- arch = 'x86' if arch == 'i686' or arch == 'i386' else arch
53
- if 'darwin' in os :
54
- os = 'macos'
55
- elif 'linux' in os :
56
- os = 'linux'
57
- elif 'freebsd' in os :
58
- os = 'freebsd'
59
- elif 'dragonfly' in os :
60
- os = 'dragonfly'
61
- elif 'android' in os :
62
- os = 'android'
63
- elif 'win' in os or 'mingw' in os :
64
- os = 'windows'
65
- cfg = [
66
- "target_arch = \" " + arch + "\" " ,
67
- "target_os = \" " + os + "\" " ,
68
- ]
69
-
70
- f .write ("#[cfg(all(" + ', ' .join (cfg ) + "))]\n " )
71
-
72
- version = run ([llconfig , '--version' ]).strip ()
73
-
74
- # LLVM libs
75
- if version < '3.5' :
76
- args = [llconfig , '--libs' ]
77
- else :
78
- args = [llconfig , '--libs' , '--system-libs' ]
79
- args .extend (components )
80
- out = run (args )
81
- for lib in out .strip ().replace ("\n " , ' ' ).split (' ' ):
82
- lib = lib .strip ()[2 :] # chop of the leading '-l'
83
- f .write ("#[link(name = \" " + lib + "\" " )
84
- # LLVM libraries are all static libraries
85
- if 'LLVM' in lib :
86
- f .write (", kind = \" static\" " )
87
- f .write (")]\n " )
88
-
89
- # llvm-config before 3.5 didn't have a system-libs flag
90
- if version < '3.5' :
91
- if os == 'win32' :
48
+ f .write ("\n " )
49
+
50
+ version = run ([llconfig , '--version' ]).strip ()
51
+
52
+ # LLVM libs
53
+ if version < '3.5' :
54
+ args = [llconfig , '--libs' ]
55
+ else :
56
+ args = [llconfig , '--libs' , '--system-libs' ]
57
+
58
+ args .extend (components )
59
+ out = run (args )
60
+ for lib in out .strip ().replace ("\n " , ' ' ).split (' ' ):
61
+ lib = lib .strip ()[2 :] # chop of the leading '-l'
62
+ f .write ("#[link(name = \" " + lib + "\" " )
63
+ # LLVM libraries are all static libraries
64
+ if 'LLVM' in lib :
65
+ f .write (", kind = \" static\" " )
66
+ f .write (")]\n " )
67
+
68
+ # llvm-config before 3.5 didn't have a system-libs flag
69
+ if version < '3.5' :
70
+ if os == 'win32' :
92
71
f .write ("#[link(name = \" imagehlp\" )]" )
93
72
94
- # LLVM ldflags
95
- out = run ([llconfig , '--ldflags' ])
96
- for lib in out .strip ().split (' ' ):
97
- if lib [:2 ] == "-l" :
98
- f .write ("#[link(name = \" " + lib [2 :] + "\" )]\n " )
99
-
100
- # C++ runtime library
101
- out = run ([llconfig , '--cxxflags' ])
102
- if enable_static == '1' :
103
- assert ('stdlib=libc++' not in out )
104
- f .write ("#[link(name = \" stdc++\" , kind = \" static\" )]\n " )
105
- else :
106
- if 'stdlib=libc++' in out :
73
+ # LLVM ldflags
74
+ out = run ([llconfig , '--ldflags' ])
75
+ for lib in out .strip ().split (' ' ):
76
+ if lib [:2 ] == "-l" :
77
+ f .write ("#[link(name = \" " + lib [2 :] + "\" )]\n " )
78
+
79
+ # C++ runtime library
80
+ out = run ([llconfig , '--cxxflags' ])
81
+ if enable_static == '1' :
82
+ assert ('stdlib=libc++' not in out )
83
+ f .write ("#[link(name = \" stdc++\" , kind = \" static\" )]\n " )
84
+ else :
85
+ if 'stdlib=libc++' in out :
107
86
f .write ("#[link(name = \" c++\" )]\n " )
108
- else :
87
+ else :
109
88
f .write ("#[link(name = \" stdc++\" )]\n " )
110
89
111
- # Attach everything to an extern block
112
- f .write ("extern {}\n " )
90
+ # Attach everything to an extern block
91
+ f .write ("extern {}\n " )
0 commit comments