diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py index 77ddee4ad..48158fd1e 100755 --- a/scripts/cargo2android.py +++ b/scripts/cargo2android.py @@ -182,7 +182,7 @@ def test_base_name(path): def unquote(s): # remove quotes around str - if s and len(s) > 1 and s[0] == '"' and s[-1] == '"': + if s and len(s) > 1 and s[0] == s[-1] and s[0] in ('"', "'"): return s[1:-1] return s @@ -367,8 +367,9 @@ class Crate(object): """Find important rustc arguments to convert to Android.bp properties.""" self.line_num = line_num self.line = line - args = line.split() # Loop through every argument of rustc. + args = list(map(unquote, line.split())) i = 0 + # Loop through every argument of rustc. while i < len(args): arg = args[i] if arg == '--crate-name': @@ -387,8 +388,8 @@ class Crate(object): self.target = args[i] elif arg == '--cfg': i += 1 - if args[i].startswith('\'feature='): - self.features.append(unquote(args[i].replace('\'feature=', '')[:-1])) + if args[i].startswith('feature='): + self.features.append(unquote(args[i].replace('feature=', ''))) else: self.cfgs.append(args[i]) elif arg == '--extern': @@ -427,14 +428,17 @@ class Crate(object): elif arg == '--out-dir' or arg == '--color': # ignored i += 1 elif arg.startswith('--error-format=') or arg.startswith('--json='): - _ = arg # ignored + pass # ignored elif arg.startswith('--emit='): self.emit_list = arg.replace('--emit=', '') elif arg.startswith('--edition='): self.edition = arg.replace('--edition=', '') - elif arg.startswith('\'-Aclippy'): - # TODO: Consider storing these to include in the Android.bp. - _ = arg # ignored + elif arg.startswith('-Aclippy') or arg.startswith('-Wclippy'): + pass # TODO: Consider storing these to include in the Android.bp. + elif arg.startswith('-W'): + pass # ignored + elif arg.startswith('-D'): + pass # TODO: Consider storing these to include in the Android.bp. elif not arg.startswith('-'): # shorten imported crate main source paths like $HOME/.cargo/ # registry/src/github.com-1ecc6299db9ec823/memchr-2.3.3/src/lib.rs