-h --help Print this message
--doc --man --manual Display complete manual (in w3m)
--leave-nailed Leave the nailed Cargo.toml in place
- --just-linkfarm | --clean-linkfarm | --keep-linkfarm (default)
+ -E | --edits-sources Allow source edits
+ --linkfarm[=no|shallow|git|full] (default varies, usually "no")
+ --just-linkfarm | --clean-linkfarm | --keep-linkfarm (default is keep)
+ --[no-]preclean-build[=no|src|full] (default is no)
--just-run Run the command, don't do cargo stuff
--no-nail Do not nail, just run the command.
--no-cargo-lock-manip Do not manipulate Cargo.lock.
our $just_linkfarm;
our $leave_nailed;
our $oot_clean;
+our $oot_preclean;
our $do_nail=1;
our $do_cargo_lock=1;
our $do_lock=1;
update =>[qw( lock-update !target online )],
fetch =>[qw( online !target-dir )],
fmt =>[qw( !locked !target !offline !target-dir edits )],
+ miri =>[qw( !locked !offline linkfarm-shallow )],
+ publish =>[qw( !offline linkfarm-gitclean )],
+ upgrades =>[qw( !locked !target-dir )],
);
our @subcmd_xprops = qw(!manifest-path);
$online //= 1 if subcmd_p('online');
$online //= 0;
+ if (subcmd_p('linkfarm-gitclean')) {
+ $linkfarm_depth //= 'git';
+ $oot_preclean //= 'src';
+ }
+
$cargo_lock_update //= subcmd_p('lock-update');
- $linkfarm_depth //= $cargo_lock_update ? 'shallow' : '';
+ $linkfarm_depth //=
+ subcmd_p('linkfarm-shallow') ? 'shallow' :
+ $cargo_lock_update ? 'shallow' :
+ '';
+
+ $oot_preclean //= 'no';
our @add;
bld="$1"; shift; sd="$1"; shift; src="$1"; shift;
cd "$bld"; mkdir -p -- "$sd"; cd "$sd";
END_BOTH
+ if ($oot_preclean ne 'no') {
+ $pre.= "find . -maxdepth 1 ! -path .";
+ $pre.= " ! -path ./target" if $oot_preclean ne 'full';
+ $pre.= " -print0 | xargs -0r rm -r --;"
+ }
if ($linkfarm_depth eq 'shallow') {
$pre.= <<'END_SHALLOW';
clean () { find -lname "$src/*" -print0 | xargs -0r rm --; }; clean;
$not_a_nailing_opt->() unless m{^-};
$not_a_nailing_opt->() if $_ eq '--';
+ my $edits_sources = sub {
+ $linkfarm_depth = 'copy-edit';
+ };
+
if ($_ eq '---') { # usage 2 or 3
if (!@ARGV) {
die "$self: --- must be followed by build command\n" unless $noact;
} elsif (s{^-D}{-}) {
$dump++;
} elsif (s{^-E}{-}) {
- $linkfarm_depth = 'copy-edit';
+ $edits_sources->();
} elsif (s{^-T(.+)}{-}s) {
$target = $1;
} elsif (s{^-([oO])}{-}) {
$online = $1 eq 'on';
} elsif (m{^--just-linkfarm(?:=(shallow|git|full))?$}) {
$just_linkfarm = 1;
- $linkfarm_depth = 1 if $1;
+ $linkfarm_depth = $1 if $1;
$cargo_lock_update= 1; # will set $linkfarm_detph to 1 by default
} elsif (m{^--linkfarm(?:=(no|shallow|git|full))?$}) {
$linkfarm_depth = $1 || 'git';
} elsif (m{^--edits?-sources?$}) {
- $linkfarm_depth = 'copy-edit';
+ $edits_sources->();
} elsif (m{^--just-run$}) {
$do_nail = $do_cargo_lock = $do_lock = 0;
} elsif (m{^--(clean|keep)-linkfarm$}) {
$oot_clean = $1 eq 'clean';
- } elsif (m{^--(no)?-nail$}) {
+ } elsif (m{^--(no-)?preclean-build$}) {
+ $oot_preclean = $1 ? 'no' : 'src';
+ } elsif (m{^--preclean-build=(no|src|full)$}) {
+ $oot_preclean = $1;
+ } elsif (m{^--(no-)?nail$}) {
$do_nail = !$1;
- } elsif (m{^--(no)?-cargo-lock-manip$}) {
+ } elsif (m{^--(no-)?cargo-lock-manip$}) {
$do_cargo_lock = !$1;
- } elsif (m{^--(no)?-concurrency-lock$}) {
+ } elsif (m{^--(no-)?concurrency-lock$}) {
$do_lock = !$1;
} elsif (m{^--leave-nailed$}) {
$leave_nailed = 1;
if ($is_cargo) {
@args_preface = shift @ARGV;
while (defined($_ = shift @ARGV)) {
- if (!m{^-}) { unshift @ARGV, $_; last; }
+ if (!m{^-|^\+}) { unshift @ARGV, $_; last; }
if ($_ eq '--') { last; }
push @args_preface, $_;
}
subdir => $subdir,
oot_dir => $oot_dir,
oot_absdir => $oot_absdir,
- build_absdir => $build_absdir });
+ build_absdir => $build_absdir,
+ linkfarm_depth => $linkfarm_depth,
+ oot_preclean => $oot_preclean, });
' or die $@;
}