|
7 | 7 |
|
8 | 8 | args = [os.environ['RUST_ANDROID_GRADLE_CC'], os.environ['RUST_ANDROID_GRADLE_CC_LINK_ARG']] + sys.argv[1:]
|
9 | 9 |
|
10 |
| -# The `gcc` library is not included starting from NDK version 23. |
11 |
| -# Work around by using `unwind` replacement. |
12 |
| -ndk_major_version = os.environ['CARGO_NDK_MAJOR_VERSION'] |
13 |
| -if ndk_major_version.isdigit(): |
14 |
| - if 23 <= int(ndk_major_version): |
15 |
| - for i, arg in enumerate(args): |
16 |
| - if arg == "-lgcc": |
17 |
| - args[i] = "-lunwind" |
| 10 | +def update_in_place(arglist): |
| 11 | + # The `gcc` library is not included starting from NDK version 23. |
| 12 | + # Work around by using `unwind` replacement. |
| 13 | + ndk_major_version = os.environ['CARGO_NDK_MAJOR_VERSION'] |
| 14 | + if ndk_major_version.isdigit(): |
| 15 | + if 23 <= int(ndk_major_version): |
| 16 | + for i, arg in enumerate(arglist): |
| 17 | + if arg.startswith('-lgcc'): |
| 18 | + # This is one way to preserve line endings. |
| 19 | + arg[:len('-lgcc')] = '-lunwind' |
| 20 | + arglist[i] = arg |
| 21 | + |
| 22 | +update_in_place(args) |
| 23 | + |
| 24 | +for arg in args: |
| 25 | + if arg.startswith('@'): |
| 26 | + fileargs = open(arg[1:], 'r').read().splitlines(keepends=True) |
| 27 | + update_in_place(fileargs) |
| 28 | + open(arg[1:], 'w').write(''.join(args)) |
| 29 | + |
| 30 | + print('>>>') |
| 31 | + print(open(arg[1:], 'r').read()) |
| 32 | + print('<<<') |
| 33 | + |
18 | 34 |
|
19 | 35 | # This only appears when the subprocess call fails, but it's helpful then.
|
20 | 36 | printable_cmd = ' '.join(pipes.quote(arg) for arg in args)
|
|
0 commit comments