summaryrefslogtreecommitdiffstats
path: root/chromium/build/symlink.py
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
commit679147eead574d186ebf3069647b4c23e8ccace6 (patch)
treefc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/build/symlink.py
Initial import.
Diffstat (limited to 'chromium/build/symlink.py')
-rwxr-xr-xchromium/build/symlink.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/chromium/build/symlink.py b/chromium/build/symlink.py
new file mode 100755
index 00000000000..aade2f865c7
--- /dev/null
+++ b/chromium/build/symlink.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 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.
+
+"""Make a symlink and optionally touch a file (to handle dependencies)."""
+
+
+import errno
+import optparse
+import os.path
+import sys
+
+
+def Main(argv):
+ parser = optparse.OptionParser()
+ parser.add_option('-f', '--force', action='store_true')
+ parser.add_option('--touch')
+
+ options, args = parser.parse_args(argv[1:])
+ if len(args) < 2:
+ parser.error('at least two arguments required.')
+
+ target = args[-1]
+ sources = args[:-1]
+ for s in sources:
+ t = os.path.join(target, os.path.basename(s))
+ try:
+ os.symlink(s, t)
+ except OSError, e:
+ if e.errno == errno.EEXIST and options.force:
+ os.remove(t)
+ os.symlink(s, t)
+ else:
+ raise
+
+
+ if options.touch:
+ with open(options.touch, 'w') as f:
+ pass
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))