OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2016 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2016 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Compiler wrapper for injecting extra libs at the end of the link | 6 """Compiler wrapper for injecting extra libs at the end of the link |
7 line. | 7 line. |
8 | 8 |
9 This is used rather than just setting LDFLAGS/LIBS becuase setting | 9 This is used rather than just setting LDFLAGS/LIBS becuase setting |
10 LIBS/LDFLAGS will effect both host and target builds. | 10 LIBS/LDFLAGS will effect both host and target builds. |
11 """ | 11 """ |
12 | 12 |
13 import os | 13 import os |
14 import subprocess | 14 import subprocess |
15 import sys | 15 import sys |
16 | 16 |
17 cmd = sys.argv[1:] | 17 cmd = sys.argv[1:] |
18 | 18 |
19 # Add extra libs when linking | 19 is_configuring = 'conftest.c' in cmd or 'conftest.pexe' in cmd |
20 is_linking = '-c' not in cmd and '-E' not in cmd | 20 is_linking = '-c' not in cmd and '-E' not in cmd |
21 if is_linking: | 21 is_shared = '-shared' in cmd |
22 cmd += os.environ['EXTRA_LIBS'].split() | 22 |
| 23 # Add extra libs when linking executables |
| 24 if is_linking and not is_shared: |
| 25 cmd += os.environ['WEBPORTS_EXTRA_LIBS'].split() |
| 26 |
| 27 if is_configuring: |
| 28 cmd.remove('-include') |
| 29 cmd.remove('spawn.h') |
23 | 30 |
24 sys.exit(subprocess.call(cmd)) | 31 sys.exit(subprocess.call(cmd)) |
OLD | NEW |