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

Unified Diff: third_party/liblouis/copy_tables.py

Issue 1145243006: Port chromevox build to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@externs
Patch Set: Workaround hardlink related spuroius rebuild issue by using a stamp file (not ideal). Created 5 years, 5 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 | « third_party/liblouis/BUILD.gn ('k') | third_party/liblouis/liblouis_list_tables.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/liblouis/copy_tables.py
diff --git a/third_party/liblouis/copy_tables.py b/third_party/liblouis/copy_tables.py
new file mode 100755
index 0000000000000000000000000000000000000000..8cab92e3b65b518844070c4affd32adef9b4c6b0
--- /dev/null
+++ b/third_party/liblouis/copy_tables.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# Copyright 2015 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.
+
+'''Copies the liblouis braille translation tables to a destination.'''
+
+import liblouis_list_tables
+import optparse
+import os
+import shutil
+
+
+def LinkOrCopyFiles(sources, dest_dir):
+ def LinkOrCopyOneFile(src, dst):
+ if os.path.exists(dst):
+ os.unlink(dst)
+ try:
+ os.link(src, dst)
+ except:
+ shutil.copy(src, dst)
+
+ if not os.path.exists(dest_dir):
+ os.makedirs(dest_dir)
+ for source in sources:
+ LinkOrCopyOneFile(source, os.path.join(dest_dir, os.path.basename(source)))
+
+
+def WriteDepfile(depfile, infiles):
+ stampfile = depfile + '.stamp'
+ with open(stampfile, 'w'):
+ os.utime(stampfile, None)
+ content = '%s: %s' % (stampfile, ' '.join(infiles))
+ open(depfile, 'w').write(content)
+
+
+
+def main():
+ parser = optparse.OptionParser(description=__doc__)
+ parser.add_option('-D', '--directory', dest='directories',
+ action='append', help='Where to search for table files')
+ parser.add_option('-e', '--extra_file', dest='extra_files', action='append',
+ default=[], help='Extra liblouis table file to process')
+ parser.add_option('-d', '--dest_dir', action='store', metavar='DIR',
+ help=('Destination directory. Used when translating ' +
+ 'input paths to output paths and when copying '
+ 'files.'))
+ parser.add_option('--depfile', metavar='FILENAME',
+ help=('Store .d style dependencies in FILENAME and touch '
+ 'FILENAME.stamp after copying the files'))
+ options, args = parser.parse_args()
+
+ if len(args) != 1:
+ parser.error('Expecting exactly one argument')
+ if not options.directories:
+ parser.error('At least one --directory option must be specified')
+ if not options.dest_dir:
+ parser.error('At least one --dest_dir option must be specified')
+ files = liblouis_list_tables.GetTableFiles(args[0], options.directories,
+ options.extra_files)
+ LinkOrCopyFiles(files, options.dest_dir)
+ if options.depfile:
+ WriteDepfile(options.depfile, files)
+
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « third_party/liblouis/BUILD.gn ('k') | third_party/liblouis/liblouis_list_tables.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698