chiark / gitweb /
nailing-cargo: -T / --target= support
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 May 2020 21:53:17 +0000 (22:53 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 May 2020 21:53:17 +0000 (22:53 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
nailing-cargo

index e17a15b7c349abbb557e62c82a3320a47d84acd7..fc70286b56fb7468de46571c8a03920c8c83ffa7 100755 (executable)
@@ -45,6 +45,10 @@ use strict;
 use POSIX;
 use Types::Serialiser;
 
+our %archmap = (
+#    RPI => 'arm-unknown-linux-gnueabihf',    xxx
+);
+
 BEGIN {
   $self = $0;  $self =~ s{^.*/(?=.)}{};
   my $deref = $0;
@@ -82,6 +86,7 @@ our $cargo_manifest_args;
 our @configs;
 our $verbose=1;
 our ($noact,$dump);
+our $target;
 
 sub read_or_enoent ($) {
   my ($fn) = @_;
@@ -332,6 +337,14 @@ sub addargs () {
       qw(--locked --target-dir=target);
   }
 
+  if (defined $target) {
+    if ($target =~ m{^[A-Z]}) {
+      $target = (cfg 'arch', $target) // $archmap{$target}
+       // die "$self: --target=$target alias specified; not in cfg or map\n";
+    }
+    push @ARGV, "--target=$target";
+  }
+}
 
 our $oot_absdir;
 our $build_absdir; # .../Build/<subdir>
@@ -524,6 +537,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
        $noact++;
       } elsif (s{^-D}{-}) {
        $dump++;
+      } elsif (s{^-T(.+)}{-}s) {
+       $target = $1;
       } elsif (s{^-([uU])}{-}) {
        $cargo_lock_update= $1=~m/[A-Z]/;
       } elsif (s{^-([mM])}{-}) {
@@ -532,6 +547,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
        die "$self: unknown short option(s) $_\n";
       }
     }
+  } elsif (s{^--target=}{}) {
+    $target = $_;
   } elsif (m{^--no-cargo-lock-update}) {
     $cargo_lock_update=0;
   } else {