GN: quiet alink spam on Mac

When building on Mac you see lots of spam about object files with no symbols when linking libskia.a.  This filters them out.

We have to do this in a Python script anyway, so I've consolidated into the existing gn/ar.py.

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4447

Change-Id: I9b18051ba687ec1fcf464a87a8a5929d29c70f24
Reviewed-on: https://skia-review.googlesource.com/4447
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2016-11-06 11:20:09 -05:00 committed by Skia Commit-Bot
parent 4b6b503c06
commit 44b36a2104
2 changed files with 17 additions and 10 deletions

View File

@ -582,15 +582,10 @@ toolchain("gcc_like") {
}
tool("alink") {
if (host_os == "win") {
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
ar_py = rebase_path("ar.py")
command = "$python $ar_py $ar {{output}} $rspfile"
} else {
# We'd use ar.py all the time, but Mac ar doesn't support @rspfile syntax. :(
command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}"
}
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
ar_py = rebase_path("ar.py")
command = "$python $ar_py $ar {{output}} $rspfile"
outputs = [
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
]

View File

@ -15,4 +15,16 @@ ar, output, rspfile = sys.argv[1:]
if os.path.exists(output):
os.remove(output)
sys.exit(subprocess.call([ar, "rcs", output, "@" + rspfile]))
if sys.platform != 'darwin':
sys.exit(subprocess.call([ar, "rcs", output, "@" + rspfile]))
# Mac ar doesn't support @rspfile syntax.
objects = open(rspfile).read().split()
# It also spams stderr with warnings about objects having no symbols.
pipe = subprocess.Popen([ar, "rcs", output] + objects, stderr=subprocess.PIPE)
_, err = pipe.communicate()
for line in err.splitlines():
if 'has no symbols' not in line:
sys.stderr.write(line + '\n')
sys.exit(pipe.returncode)