[ARM] Split large widening MVE loads
[llvm-core.git] / utils / gn / build / symlink_or_copy.py
bloba8f6c1b322beaaf88c69565d08082af5cf398929
1 #!/usr/bin/env python
3 """Symlinks, or on Windows copies, an existing file to a second location.
5 Overwrites the target location if it exists.
6 Updates the mtime on a stamp file when done."""
8 import argparse
9 import errno
10 import os
11 import sys
14 def main():
15 parser = argparse.ArgumentParser(description=__doc__)
16 parser.add_argument('--stamp', required=True,
17 help='name of a file whose mtime is updated on run')
18 parser.add_argument('source')
19 parser.add_argument('output')
20 args = parser.parse_args()
22 # FIXME: This should not check the host platform but the target platform
23 # (which needs to be passed in as an arg), for cross builds.
24 if sys.platform != 'win32':
25 try:
26 os.makedirs(os.path.dirname(args.output))
27 except OSError as e:
28 if e.errno != errno.EEXIST:
29 raise
30 try:
31 os.symlink(args.source, args.output)
32 except OSError as e:
33 if e.errno == errno.EEXIST:
34 os.remove(args.output)
35 os.symlink(args.source, args.output)
36 else:
37 raise
38 else:
39 import shutil
40 output = args.output + ".exe"
41 source = args.source + ".exe"
42 shutil.copyfile(os.path.join(os.path.dirname(output), source), output)
44 open(args.stamp, 'w') # Update mtime on stamp file.
47 if __name__ == '__main__':
48 sys.exit(main())