summaryrefslogtreecommitdiff
path: root/gyp/link.py
blob: f8d98074e277774b93d355f10095c688630a5293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python

import sys
import os
from merge_static_libs import MergeLibs

args = sys.argv[1:]

out_lib = ''
in_libs = []
flags = []

i = 0
l = len(args)
while i < l:
    arg = args[i]

    if arg[0:2] == '-l':
        flags.append(arg)
    elif arg[0:2] == '-L':
        flags.append(arg)
    elif arg == '-arch':
        i += 1
    elif arg == '-framework':
        i += 1
        flags.append(arg + ' ' + args[i])
    elif arg == '-o':
        i += 1
        out_lib = args[i]
    elif arg[0] != '-':
        in_libs.append(arg)
    else:
        print 'Ignored linker directive: ' + arg

    i += 1

flags.reverse()
unique_flags = []
for flag in flags:
    if flag not in unique_flags:
        unique_flags.append(flag)
unique_flags.reverse()

with open(out_lib + '.ldflags', 'w+') as f:
    f.write(' '.join(unique_flags));

MergeLibs(in_libs, out_lib)