1 # Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
17 f = open(sys.argv[1], 'wb')
19 components = sys.argv[2].split(' ')
20 components = [i for i in components if i] # ignore extra whitespaces
21 enable_static = sys.argv[3]
22 llconfig = sys.argv[4]
24 f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
25 // file at the top-level directory of this distribution and at
26 // http://rust-lang.org/COPYRIGHT.
28 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
29 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
30 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
31 // option. This file may not be copied, modified, or distributed
32 // except according to those terms.
34 // WARNING: THIS IS A GENERATED FILE, DO NOT MODIFY
35 // take a look at src/etc/mklldeps.py if you're interested
39 proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40 out, err = proc.communicate()
43 print("failed to run llconfig: args = `{}`".format(args))
50 version = run([llconfig, '--version']).strip()
54 args = [llconfig, '--libs']
56 args = [llconfig, '--libs', '--system-libs']
58 args.extend(components)
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
65 f.write(", kind = \"static\"")
68 # llvm-config before 3.5 didn't have a system-libs flag
71 f.write("#[link(name = \"imagehlp\")]")
74 out = run([llconfig, '--ldflags'])
75 for lib in out.strip().split(' '):
77 f.write("#[link(name = \"" + lib[2:] + "\")]\n")
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")
85 if 'stdlib=libc++' in out:
86 f.write("#[link(name = \"c++\")]\n")
88 f.write("#[link(name = \"stdc++\")]\n")
90 # Attach everything to an extern block
91 f.write("extern {}\n")