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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2014 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 """Converts a given gni file list to a gyp array
7
8 It only works on a file list, one file per line, no quotes, no commas.
9
10 The script will output on stdout a gyp array using <(DEPTH) relative paths.
11
12 Usage:
13 'sources': [
14 '<!@(python ../../../build/gni_to_gyp.py --root=<(DEPTH)
15 --filelist=<(DEPTH)/ensemble/renderer/transport_files.gni)',
16 ],
17
18 """
19
20 from optparse import OptionParser
21 import os
22 import sys
23
24 def ConfigurePaths(root, gni_file):
25 """Turns the passed in arguments into the correct gypi path strings."""
26 full_path_to_root = os.path.normpath(os.getcwd() + '/' + root)
27 full_path_to_gni = os.path.normpath(os.getcwd() + '/' + gni_file)
28 gni_relative = full_path_to_gni[len(full_path_to_root)+1:]
29 gni_relative = '"<(DEPTH)/' + os.path.dirname(gni_relative) + '/'
30 return (full_path_to_gni, gni_relative)
31
32 def main():
33 parser = OptionParser()
34 parser.add_option('--root', dest='root', help='Root level of source tree.' )
35 parser.add_option('--filelist', dest='filelist', help='gni file list.')
36 (options, args) = parser.parse_args()
37 (gni_file, depth_based_path) = ConfigurePaths(options.root, options.filelist)
38 files = open(gni_file)
39 gyp_output = ""
40 for file in files:
41 gyp_output += depth_based_path + file[:-1] + '"\n'
42 print gyp_output
43
44 if __name__ == '__main__':
45 try:
46 main()
47 sys.exit(0)
48 except Exception, e:
49 print >> sys.stderr, e
50 sys.exit(1)
OLDNEW
« 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