OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """This script gets a list of files from the given directory that |
| 7 matches a particular glob pattern. |
| 8 |
| 9 Normal shell globbing does not work with Visual Studio, even if it |
| 10 works in Makefiles. Thus we use this python wrapper to handle globbing |
| 11 in GYP and get a real list of files instead of a symbolic filename |
| 12 that has a "*" in it. |
| 13 |
| 14 Perhaps this can be built into gyp instead. |
| 15 """ |
| 16 |
| 17 import glob |
| 18 import os |
| 19 import sys |
| 20 |
| 21 def Main(argv): |
| 22 if len(argv) < 3: |
| 23 sys.stderr.write('Usage: %s <path> <glob_pattern>\n' % argv[0]) |
| 24 return 1 |
| 25 path = argv[1] |
| 26 glob_str = os.path.join(path, argv[2]) |
| 27 files = glob.glob(glob_str) |
| 28 if sys.platform.startswith('win'): |
| 29 # Add a \ so that gyp will have escaped slashes. |
| 30 matching = [ f.replace('\\', '\\\\') for f in files ] |
| 31 else: |
| 32 # Linux seems to need the abspath, while visual studio is okay with |
| 33 # a relative path. |
| 34 matching = [ os.path.abspath(f) for f in files ] |
| 35 |
| 36 sys.stdout.write(' '.join(matching) + '\n') |
| 37 return 0 |
| 38 |
| 39 if __name__ == '__main__': |
| 40 sys.exit(Main(sys.argv)) |
OLD | NEW |