]> git.lizzy.rs Git - rust.git/blob - src/etc/mklldeps.py
Link rustllvm statically, and distribute a static snapshot
[rust.git] / src / etc / mklldeps.py
1 # xfail-license
2
3 import os
4 import sys
5 import subprocess
6
7 components = sys.argv[1].split(' ')
8
9 print """// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
10 // file at the top-level directory of this distribution and at
11 // http://rust-lang.org/COPYRIGHT.
12 //
13 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
14 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
15 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
16 // option. This file may not be copied, modified, or distributed
17 // except according to those terms.
18
19 // WARNING: THIS IS A GENERATED FILE, DO NOT MODIFY
20 //          take a look at src/etc/mklldeps.py if you're interested
21 """
22
23 for llconfig in sys.argv[2:]:
24     print
25
26     proc = subprocess.Popen([llconfig, '--host-target'], stdout = subprocess.PIPE)
27     out, err = proc.communicate()
28     arch, os = out.split('-', 1)
29     arch = 'x86' if arch == 'i686' or arch == 'i386' else arch
30     if 'darwin' in os:
31         os = 'macos'
32     elif 'linux' in os:
33         os = 'linux'
34     elif 'freebsd' in os:
35         os = 'freebsd'
36     elif 'android' in os:
37         os = 'android'
38     elif 'win' in os or 'mingw' in os:
39         os = 'win32'
40     cfg = [
41         "target_arch = \"" + arch + "\"",
42         "target_os = \"" + os + "\"",
43     ]
44
45     print "#[cfg(" + ', '.join(cfg) + ")]"
46
47     args = [llconfig, '--libs']
48     args.extend(components)
49     proc = subprocess.Popen(args, stdout = subprocess.PIPE)
50     out, err = proc.communicate()
51
52     for lib in out.strip().split(' '):
53         lib = lib[2:] # chop of the leading '-l'
54         print "#[link(name = \"" + lib + "\", kind = \"static\")]"
55     if os == 'win32':
56         print "#[link(name = \"pthread\")]"
57         print "#[link(name = \"imagehlp\")]"
58     print "extern {}"