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

Unified Diff: ios/chrome/tools/build/ios_generate_forwarding_headers.py

Issue 1711953003: Adds the OCHamcrest library to the iOS build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix outputs. Created 4 years, 10 months 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 | « DEPS ('k') | ios/ios.gyp » ('j') | ios/third_party/ochamcrest/OWNERS » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/tools/build/ios_generate_forwarding_headers.py
diff --git a/ios/chrome/tools/build/ios_generate_forwarding_headers.py b/ios/chrome/tools/build/ios_generate_forwarding_headers.py
new file mode 100755
index 0000000000000000000000000000000000000000..24cf1fd33c92ac106a0f3082b4aa34d0c0582d63
--- /dev/null
+++ b/ios/chrome/tools/build/ios_generate_forwarding_headers.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright 2016 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.
+
+import argparse
+import datetime
+import os
+import sys
+
+COPYRIGHT = """// Copyright {0} 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.\n
+""".format(datetime.date.today().year)
+
+def filter_header_files(inputs):
+ return [filename for filename in inputs if filename.endswith('.h')]
+
+def get_output_filename(input_filename, dest_dir):
+ return os.path.join(dest_dir, os.path.basename(input_filename))
+
+def list_outputs(inputs, dest_dir):
+ outputs = []
+ for filename in filter_header_files(inputs):
+ outputs.append(get_output_filename(filename, dest_dir))
+ return ' '.join(outputs)
+
+def generate_headers(inputs, dest_dir):
baxley 2016/02/20 01:11:51 Would it make any sense to rm the dest_dir? I know
rohitrao (ping after 24h) 2016/02/20 01:18:52 I can't arbitrarily remove dest_dir because then w
+ for filename in filter_header_files(inputs):
+ forwarding_header = get_output_filename(filename, dest_dir)
+ if not os.path.isfile(forwarding_header):
+ with open(forwarding_header, 'w') as header:
+ header.write(COPYRIGHT)
+ header.write('#import "{0}"\n'.format(filename))
+
+def DoMain(argv):
+ parser = argparse.ArgumentParser(description='Generate forwarding headers.')
+ parser.add_argument('-o', '--list-outputs', action='store_true',
+ help='List output files and exit.')
+ parser.add_argument('-d', '--dest-dir', type=str, required=True,
+ help=('Output directory for forwarding headers.'))
+ parser.add_argument('filenames', metavar='filename', type=str, nargs='+',
+ help='Input filenames.')
+
+ args = parser.parse_args(argv)
+ if args.list_outputs:
+ return list_outputs(args.filenames, args.dest_dir)
baxley 2016/02/20 01:11:51 Does this list get printed?
rohitrao (ping after 24h) 2016/02/20 01:18:52 No, it never gets printed anywhere =) It actually
+ if args.dest_dir:
+ if not os.path.isdir(args.dest_dir):
+ os.makedirs(args.dest_dir)
+ generate_headers(args.filenames, args.dest_dir)
+ return
+ print >>sys.stderr, 'Neither -o nor -d passed, unsure what to do.'
+
+if __name__ == '__main__':
+ DoMain(sys.argv[1:])
« no previous file with comments | « DEPS ('k') | ios/ios.gyp » ('j') | ios/third_party/ochamcrest/OWNERS » ('J')

Powered by Google App Engine
This is Rietveld 408576698