]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
Adding a python script to enable RVCT 3.1 (ARM ARM compiler) to run in cygwin. The...
[mirror_edk2.git] / BaseTools / Bin / CYGWIN_NT-5.1-i686 / armcc_wrapper.py
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 #
9 # http://opensource.org/licenses/bsd-license.php
10 #
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #
14
15 #
16 # ARMCC tools do not support cygwin paths. Ths script converts cygwin paths to DOS paths
17 # in any arguments.
18 #
19 # armcc_wrapper.py ToolToExec [command line to convert]
20 #
21 # anthing with the / will be converted via cygpath cygwin call or manually.
22 # -I/cygpath/c/example is a special case as you can not pass -I to cygpath
23 #
24 # ExceptionList if a tool takes an argument with a / add it to the exception list
25 #
26 import sys
27 import os
28 import subprocess
29
30 #
31 # Convert using cygpath command line tool
32 # Currently not used, but just in case we need it in the future
33 #
34 def ConvertCygPathToDosViacygpath(CygPath):
35 p = subprocess.Popen("cygpath -m " + CygPath, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
36 return p.stdout.read().strip()
37
38 #
39 #
40 #
41 def ConvertCygPathToDos(CygPath):
42 if CygPath.find("/cygdrive/") == 0:
43 # convert /cygdrive/c/Xyz to c:/Xyz
44 DosPath = CygPath[10] + ':' + CygPath[11:]
45 else:
46 DosPath = CygPath
47
48 # need the extra \\ as we are making a string to pass to a command
49 return DosPath.replace('/','\\\\')
50
51
52 def main(argv):
53
54 # use 1st argument as name of tool to call
55 Command = sys.argv[1]
56
57 ExceptionList = ["/interwork"]
58
59 for arg in argv:
60 if arg.find('/') == -1:
61 # if we don't need to convert just add to the command line
62 Command = Command + ' ' + arg
63 elif arg in ExceptionList:
64 # if it is in the list, then don't do a cygpath
65 # assembler stuff after --apcs has the /.
66 Command = Command + ' ' + arg
67 else:
68 if ((arg[0] == '-') and (arg[1] == 'I' or arg[1] == 'i')):
69 CygPath = arg[0] + arg[1] + ConvertCygPathToDos(arg[2:])
70 else:
71 CygPath = ConvertCygPathToDos(arg)
72
73 Command = Command + ' ' + CygPath
74
75 # call the real tool with the converted paths
76 return subprocess.call(Command, shell=True)
77
78
79 if __name__ == "__main__":
80 try:
81 ret = main(sys.argv[2:])
82
83 except:
84 print "exiting: exception from " + sys.argv[0]
85 ret = 2
86
87 sys.exit(ret)
88