This means that the user can pass non-option arguments to cargo (eg
for cargo run).
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
were cargo.
With `-C`, nailing-cargo will not add additional options
to the build command. With `-c` it will pass those options
were cargo.
With `-C`, nailing-cargo will not add additional options
to the build command. With `-c` it will pass those options
- at the end of the build command.
+ after the cargo subcommand (usages 1 and 2) or right
+ after the build command (usage 3).
+
The cargo options are in any case also passed in the
environment - see [Environment of the build command].
The cargo options are in any case also passed in the
environment - see [Environment of the build command].
our $lockfile = "../.nailing-cargo.lock";
our $lockfile = "../.nailing-cargo.lock";
our $cargo_subcmd;
our $command_is_cargo;
our $alt_cargo_lock;
our $cargo_subcmd;
our $command_is_cargo;
our $alt_cargo_lock;
if (!$cargo_lock_update) {
push @add, qw(--locked) unless subcmd_p('!locked');
if (defined($oot_dir) && !subcmd_p('!manifest-path')) {
if (!$cargo_lock_update) {
push @add, qw(--locked) unless subcmd_p('!locked');
if (defined($oot_dir) && !subcmd_p('!manifest-path')) {
- push @ARGV, "--manifest-path=${src_absdir}/Cargo.toml" if $pass_options;
+ my $cargotoml = "${src_absdir}/Cargo.toml";
+ push @args_preface, "--manifest-path=$cargotoml" if $pass_options;
push @add, qw(--target-dir=target) unless subcmd_p('!target-dir');
}
}
push @add, qw(--target-dir=target) unless subcmd_p('!target-dir');
}
}
push @add, "--offline" unless $online || subcmd_p('!offline');
push @add, "--offline" unless $online || subcmd_p('!offline');
- push @ARGV, @add if $pass_options;
+ push @args_preface, @add if $pass_options;
die if grep { m/ / } @add;
$ENV{NAILINGCARGO_CARGO_OPTIONS} = "@add";
die if grep { m/ / } @add;
$ENV{NAILINGCARGO_CARGO_OPTIONS} = "@add";
+
+ unshift @ARGV, @args_preface;
@ARGV || die;
if ($is_cargo) {
@ARGV || die;
if ($is_cargo) {
- my @cargo_and_opts = shift @ARGV;
+ @args_preface = shift @ARGV;
while (defined($_ = shift @ARGV)) {
if (!m{^-}) { unshift @ARGV, $_; last; }
if ($_ eq '--') { last; }
while (defined($_ = shift @ARGV)) {
if (!m{^-}) { unshift @ARGV, $_; last; }
if ($_ eq '--') { last; }
- push @cargo_and_opts, $_;
+ push @args_preface, $_;
}
@ARGV || die "$self: need cargo subcommand\n";
$cargo_subcmd //= $ARGV[0];
$pass_options //= 1;
}
@ARGV || die "$self: need cargo subcommand\n";
$cargo_subcmd //= $ARGV[0];
$pass_options //= 1;
- unshift @ARGV, @cargo_and_opts;
} else {
$cargo_subcmd //= '';
$pass_options //= 0;
}
} else {
$cargo_subcmd //= '';
$pass_options //= 0;
}
+ push @args_preface, shift @ARGV;
if (!ref($cargo_subcmd)) {
print STDERR " cargo_subcmd lookup $cargo_subcmd\n" if $dump;
if (!ref($cargo_subcmd)) {
print STDERR " cargo_subcmd lookup $cargo_subcmd\n" if $dump;