Fixes "argument list too long" problem on Linux by using the "find" command instead of re-implementing one in python.
R=pbos@webrtc.org TBR=andrew@webrtc.org BUG=b/15773179 Review URL: https://webrtc-codereview.appspot.com/18929004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6782 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -16,6 +16,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
IGNORE_PATTERNS = ['do_not_use', 'protoc']
|
||||||
|
|
||||||
def FindFiles(path, pattern):
|
def FindFiles(path, pattern):
|
||||||
"""Finds files matching |pattern| under |path|.
|
"""Finds files matching |pattern| under |path|.
|
||||||
@@ -35,9 +36,10 @@ def FindFiles(path, pattern):
|
|||||||
files = []
|
files = []
|
||||||
for root, _, filenames in os.walk(path):
|
for root, _, filenames in os.walk(path):
|
||||||
for filename in fnmatch.filter(filenames, pattern):
|
for filename in fnmatch.filter(filenames, pattern):
|
||||||
if 'do_not_use' not in filename and 'protoc' not in filename:
|
if filename not in IGNORE_PATTERNS:
|
||||||
# We use the relative path here to avoid "argument list too long"
|
# We use the relative path here to avoid "argument list too
|
||||||
# errors on Linux.
|
# long" errors on Linux. Note: This doesn't always work, so
|
||||||
|
# we use the find command on Linux.
|
||||||
files.append(os.path.relpath(os.path.join(root, filename)))
|
files.append(os.path.relpath(os.path.join(root, filename)))
|
||||||
return files
|
return files
|
||||||
|
|
||||||
@@ -58,23 +60,28 @@ def main(argv):
|
|||||||
os.remove(output_lib)
|
os.remove(output_lib)
|
||||||
|
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith('linux'):
|
||||||
objects = FindFiles(search_path, '*.o')
|
pattern = '*.o'
|
||||||
cmd = 'ar crs '
|
cmd = 'ar crs'
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
objects = FindFiles(search_path, '*.a')
|
pattern = '*.a'
|
||||||
cmd = 'libtool -static -v -o '
|
cmd = 'libtool -static -v -o '
|
||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
objects = FindFiles(search_path, '*.lib')
|
pattern = '*.lib'
|
||||||
cmd = 'lib /OUT:'
|
cmd = 'lib /OUT:'
|
||||||
else:
|
else:
|
||||||
sys.stderr.write('Platform not supported: %r\n\n' % sys.platform)
|
sys.stderr.write('Platform not supported: %r\n\n' % sys.platform)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cmd += output_lib + ' ' + ' '.join(objects)
|
if sys.platform.startswith('linux'):
|
||||||
|
cmd = ' '.join(['find', search_path, '-name "' + pattern + '"' +
|
||||||
|
' -and -not -name ' +
|
||||||
|
' -and -not -name '.join(IGNORE_PATTERNS) +
|
||||||
|
' -exec', cmd, output_lib, '{} +'])
|
||||||
|
else:
|
||||||
|
cmd = ' '.join([cmd, output_lib] + FindFiles(search_path, pattern))
|
||||||
print cmd
|
print cmd
|
||||||
subprocess.check_call(cmd, shell=True)
|
subprocess.check_call(cmd, shell=True)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main(sys.argv))
|
sys.exit(main(sys.argv))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user