Index: build/toolchain/gcc_solink_wrapper.py |
diff --git a/build/toolchain/gcc_solink_wrapper.py b/build/toolchain/gcc_solink_wrapper.py |
index 45c489d25bd8e12a886c36235b2f2e639835cd6b..7db638df2d1b0ccc0b4758f0c593ecfa06d68c73 100755 |
--- a/build/toolchain/gcc_solink_wrapper.py |
+++ b/build/toolchain/gcc_solink_wrapper.py |
@@ -1,5 +1,5 @@ |
#!/usr/bin/env python |
-# Copyright 2015 The Chromium Authors. All rights reserved. |
+# Copyright 2016 The Chromium Authors. All rights reserved. |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
@@ -12,31 +12,17 @@ does not have a POSIX-like shell (e.g. Windows). |
import argparse |
import os |
-import re |
import subprocess |
import sys |
- |
-# When running on a Windows host and using a toolchain whose tools are |
-# actually wrapper scripts (i.e. .bat files on Windows) rather than binary |
-# executables, the "command" to run has to be prefixed with this magic. |
-# The GN toolchain definitions take care of that for when GN/Ninja is |
-# running the tool directly. When that command is passed in to this |
-# script, it appears as a unitary string but needs to be split up so that |
-# just 'cmd' is the actual command given to Python's subprocess module. |
-BAT_PREFIX = 'cmd /c call ' |
- |
-def CommandToRun(command): |
- if command[0].startswith(BAT_PREFIX): |
- command = command[0].split(None, 3) + command[1:] |
- return command |
+import wrapper_utils |
def CollectSONAME(args): |
"""Replaces: readelf -d $sofile | grep SONAME""" |
toc = '' |
- readelf = subprocess.Popen(CommandToRun([args.readelf, '-d', args.sofile]), |
- stdout=subprocess.PIPE, bufsize=-1) |
+ readelf = subprocess.Popen(wrapper_utils.CommandToRun( |
+ [args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, bufsize=-1) |
for line in readelf.stdout: |
if 'SONAME' in line: |
toc += line |
@@ -46,7 +32,7 @@ def CollectSONAME(args): |
def CollectDynSym(args): |
"""Replaces: nm --format=posix -g -D $sofile | cut -f1-2 -d' '""" |
toc = '' |
- nm = subprocess.Popen(CommandToRun([ |
+ nm = subprocess.Popen(wrapper_utils.CommandToRun([ |
args.nm, '--format=posix', '-g', '-D', args.sofile]), |
stdout=subprocess.PIPE, bufsize=-1) |
for line in nm.stdout: |
@@ -96,12 +82,21 @@ def main(): |
required=True, |
help='Final output shared object file', |
metavar='FILE') |
+ parser.add_argument('--rspfile', |
+ help='Response file', |
+ metavar='FILE') |
+ parser.add_argument('--whitelist', action='store_true', |
+ help='Indicates that whitelisting should be performed.') |
parser.add_argument('command', nargs='+', |
help='Linking command') |
args = parser.parse_args() |
+ if args.whitelist: |
+ whitelist_file = '%s.whitelist' % args.output |
+ wrapper_utils.CombineWhitelists(args.rspfile, whitelist_file) |
+ |
# First, run the actual link. |
- result = subprocess.call(CommandToRun(args.command)) |
+ result = subprocess.call(wrapper_utils.CommandToRun(args.command)) |
if result != 0: |
return result |
@@ -116,7 +111,7 @@ def main(): |
# Finally, strip the linked shared object file (if desired). |
if args.strip: |
- result = subprocess.call(CommandToRun([args.strip, '--strip-unneeded', |
+ result = subprocess.call(wrapper_utils.CommandToRun([args.strip, '--strip-unneeded', |
'-o', args.output, args.sofile])) |
return result |