Index: build/gni_to_gyp.py |
diff --git a/build/gni_to_gyp.py b/build/gni_to_gyp.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..8ea7c6bc75fcd2d145c2256be0a2b8509a5bff7d |
--- /dev/null |
+++ b/build/gni_to_gyp.py |
@@ -0,0 +1,50 @@ |
+#!/usr/bin/python |
+# Copyright 2014 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. |
+ |
+"""Converts a given gni file list to a gyp array |
+ |
+It only works on a file list, one file per line, no quotes, no commas. |
+ |
+The script will output on stdout a gyp array using <(DEPTH) relative paths. |
+ |
+Usage: |
+'sources': [ |
+ '<!@(python ../../../build/gni_to_gyp.py --root=<(DEPTH) |
+ --filelist=<(DEPTH)/ensemble/renderer/transport_files.gni)', |
+], |
+ |
+""" |
+ |
+from optparse import OptionParser |
+import os |
+import sys |
+ |
+def ConfigurePaths(root, gni_file): |
+ """Turns the passed in arguments into the correct gypi path strings.""" |
+ full_path_to_root = os.path.normpath(os.getcwd() + '/' + root) |
+ full_path_to_gni = os.path.normpath(os.getcwd() + '/' + gni_file) |
+ gni_relative = full_path_to_gni[len(full_path_to_root)+1:] |
+ gni_relative = '"<(DEPTH)/' + os.path.dirname(gni_relative) + '/' |
+ return (full_path_to_gni, gni_relative) |
+ |
+def main(): |
+ parser = OptionParser() |
+ parser.add_option('--root', dest='root', help='Root level of source tree.' ) |
+ parser.add_option('--filelist', dest='filelist', help='gni file list.') |
+ (options, args) = parser.parse_args() |
+ (gni_file, depth_based_path) = ConfigurePaths(options.root, options.filelist) |
+ files = open(gni_file) |
+ gyp_output = "" |
+ for file in files: |
+ gyp_output += depth_based_path + file[:-1] + '"\n' |
+ print gyp_output |
+ |
+if __name__ == '__main__': |
+ try: |
+ main() |
+ sys.exit(0) |
+ except Exception, e: |
+ print >> sys.stderr, e |
+ sys.exit(1) |