]>
Commit | Line | Data |
---|---|---|
f7496d71 LG |
1 | #!/usr/bin/env python\r |
2 | #\r | |
3 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
4 | #\r | |
2e351cbe | 5 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
f7496d71 LG |
6 | #\r |
7 | \r | |
8 | #\r | |
9 | # ARMCC tools do not support cygwin paths. Ths script converts cygwin paths to DOS paths\r | |
10 | # in any arguments.\r | |
11 | #\r | |
12 | # armcc_wrapper.py ToolToExec [command line to convert]\r | |
13 | #\r | |
fb0b35e0 | 14 | # anything with the / will be converted via cygpath cygwin call or manually.\r |
f7496d71 LG |
15 | # -I/cygpath/c/example is a special case as you can not pass -I to cygpath\r |
16 | #\r | |
17 | # ExceptionList if a tool takes an argument with a / add it to the exception list\r | |
18 | #\r | |
72443dd2 | 19 | from __future__ import print_function\r |
f7496d71 LG |
20 | import sys\r |
21 | import os\r | |
22 | import subprocess\r | |
23 | import pipes\r | |
24 | \r | |
25 | #\r | |
26 | # Convert using cygpath command line tool\r | |
27 | # Currently not used, but just in case we need it in the future\r | |
28 | #\r | |
29 | def ConvertCygPathToDosViacygpath(CygPath):\r | |
30 | p = subprocess.Popen("cygpath -m " + pipes.quote(CygPath), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)\r | |
31 | return p.stdout.read().strip()\r | |
32 | \r | |
33 | #\r | |
34 | #\r | |
35 | #\r | |
36 | def ConvertCygPathToDos(CygPath):\r | |
37 | if CygPath.find("/cygdrive/") == 0:\r | |
38 | # convert /cygdrive/c/Xyz to c:/Xyz\r | |
39 | DosPath = CygPath[10] + ':' + CygPath[11:]\r | |
40 | else:\r | |
41 | DosPath = CygPath\r | |
42 | \r | |
43 | # pipes.quote will add the extra \\ for us.\r | |
ccaa7754 | 44 | return DosPath.replace('/', '\\')\r |
f7496d71 LG |
45 | \r |
46 | \r | |
47 | # we receive our options as a list, but we will be passing them to the shell as a line\r | |
48 | # this means we have to requote things as they will get one round of unquoting.\r | |
49 | # we can't set "shell=False" because we are running commands from the PATH and\r | |
50 | # if you don't use the shell you don't get a PATH search.\r | |
51 | def main(argv):\r | |
52 | \r | |
53 | # use 1st argument as name of tool to call\r | |
54 | Command = pipes.quote(sys.argv[1]);\r | |
55 | \r | |
56 | ExceptionList = ["/interwork"]\r | |
57 | \r | |
58 | for arg in argv:\r | |
59 | if arg.find('/') == -1:\r | |
60 | # if we don't need to convert just add to the command line\r | |
61 | Command = Command + ' ' + pipes.quote(arg)\r | |
62 | elif arg in ExceptionList:\r | |
63 | # if it is in the list, then don't do a cygpath\r | |
64 | # assembler stuff after --apcs has the /.\r | |
65 | Command = Command + ' ' + pipes.quote(arg)\r | |
66 | else:\r | |
67 | if ((arg[0] == '-') and (arg[1] == 'I' or arg[1] == 'i')):\r | |
68 | CygPath = arg[0] + arg[1] + ConvertCygPathToDos(arg[2:])\r | |
69 | else:\r | |
70 | CygPath = ConvertCygPathToDos(arg)\r | |
71 | \r | |
72 | Command = Command + ' ' + pipes.quote(CygPath)\r | |
73 | \r | |
74 | # call the real tool with the converted paths\r | |
75 | return subprocess.call(Command, shell=True)\r | |
76 | \r | |
77 | \r | |
78 | if __name__ == "__main__":\r | |
79 | try:\r | |
80 | ret = main(sys.argv[2:])\r | |
81 | \r | |
82 | except:\r | |
72443dd2 | 83 | print("exiting: exception from " + sys.argv[0])\r |
f7496d71 LG |
84 | ret = 2\r |
85 | \r | |
86 | sys.exit(ret)\r | |
87 | \r |