c2a: Support customizing rustc

The current cargo2android.py doesn't work well w/ `--cargo_bin`. It would use the full path rustc(/<HOME>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc) instead of basename(`rustc`). The `RUSTC_PAT` and `RUSTC_VV_CMD_ARGS` regex doesn't match the full path.

This CL uses `(.*\/)?` to match the path if it exists.

Change-Id: If5e4060410c1cd45ad6c9612ebe856552aa14d08
This commit is contained in:
Sim Sun
2023-06-21 13:58:24 -07:00
parent f87641a7ea
commit ecff5ddc84

View File

@@ -118,13 +118,13 @@ DRY_RUN_NOTE = (
'See --help for other flags, and more usage notes in this script.\n')
# Cargo -v output of a call to rustc.
RUSTC_PAT = re.compile('^ +Running `rustc (.*)`$')
RUSTC_PAT = re.compile('^ +Running `(.*\/)?rustc (.*)`$')
# Cargo -vv output of a call to rustc could be split into multiple lines.
# Assume that the first line will contain some CARGO_* env definition.
RUSTC_VV_PAT = re.compile('^ +Running `.*CARGO_.*=.*$')
# The combined -vv output rustc command line pattern.
RUSTC_VV_CMD_ARGS = re.compile('^ *Running `.*CARGO_.*=.* rustc (.*)`$')
RUSTC_VV_CMD_ARGS = re.compile('^ *Running `.*CARGO_.*=.* (.*\/)?rustc (.*)`$')
# Cargo -vv output of a "cc" or "ar" command; all in one line.
CC_AR_VV_PAT = re.compile(r'^\[([^ ]*)[^\]]*\] running:? "(cc|ar)" (.*)$')
@@ -1567,7 +1567,7 @@ class Runner(object):
if not line.endswith('`\n') or (new_rustc.count('`') % 2) != 0:
return new_rustc
if RUSTC_VV_CMD_ARGS.match(new_rustc):
args = RUSTC_VV_CMD_ARGS.match(new_rustc).group(1)
args = RUSTC_VV_CMD_ARGS.match(new_rustc).group(2)
self.add_crate(Crate(self, outf_name).parse(n, args))
else:
self.assert_empty_vv_line(new_rustc)
@@ -1632,7 +1632,7 @@ class Runner(object):
continue
new_rustc = ''
if RUSTC_PAT.match(line):
args_line = RUSTC_PAT.match(line).group(1)
args_line = RUSTC_PAT.match(line).group(2)
self.add_crate(Crate(self, outf_name).parse(n, args_line))
self.assert_empty_vv_line(rustc_line)
elif rustc_line or RUSTC_VV_PAT.match(line):