blob: c7ffb04f67755984f7ef11fb488ca2696c8c2641 [file] [log] [blame]
Mike Klein82364ba2016-10-24 16:49:15 -04001#!/usr/bin/env python
2#
3# Copyright 2016 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8import os
9import subprocess
10import sys
11
12# Equivalent to: rm -f $2 && $1 rcs $2 @$3
13
14ar, output, rspfile = sys.argv[1:]
15
16if os.path.exists(output):
17 os.remove(output)
Mike Klein44b36a22016-11-06 11:20:09 -050018
19if sys.platform != 'darwin':
20 sys.exit(subprocess.call([ar, "rcs", output, "@" + rspfile]))
21
22# Mac ar doesn't support @rspfile syntax.
23objects = open(rspfile).read().split()
24# It also spams stderr with warnings about objects having no symbols.
25pipe = subprocess.Popen([ar, "rcs", output] + objects, stderr=subprocess.PIPE)
26_, err = pipe.communicate()
27for line in err.splitlines():
28 if 'has no symbols' not in line:
29 sys.stderr.write(line + '\n')
30sys.exit(pipe.returncode)