Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: build/gni_to_gyp.py

Issue 705663002: Add GYP_INCLUDE_FIRST/LAST to chromium.gyp_env (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: python script to allow gyp to read gni file lists Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698