Fighting Cargo to avoid this has become too much hard work.
In particular, otherwise with workspaces we would have to edit all of
the member paths. And having done that the sources themselves claim
to be part of a different workspace, so it's all awful.
I have also seen some weird behaviours where cargo didn't work quite
right because the package wasn't convincing enough.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
With this enabled, in an out-of-tree build the `Cargo.lock` and
`Cargo.toml` are copied to the build directory along with a
- skeleton just big enough to fool cargo. After cargo has run, the
- resulting `Cargo.lock` is copied back to the source tree.
+ linkfarm, to fool cargo. After cargo has run, the resulting
+ `Cargo.lock` is copied back to the source tree.
Default is no update unless the whole point of the cargo
subcommand is to update `Cargo.lock`.
$pre = <<'END';
cd "$1"; shift;
mkdir -p -- "$1"; cd "$1"; shift;
- cp -- "$1"/Cargo.toml
+ clean () { find -lname "$1/*" -print0 | xargs -0r rm --; }; clean;
+ find "$1" -maxdepth 1 \! -name Cargo.lock -print0 | xargs -0r -I_ ln -sf -- _ .;
END
$pre .= <<'ENDLK' if stat_exists 'Cargo.lock', 'working cargo lockfile';
- "$1"/Cargo.lock
+ rm -f Cargo.lock;
+ cp -- "$1"/Cargo.lock .;
ENDLK
- $pre .= <<'ENDCP';
- .;
-ENDCP
$pre .= <<'ENDPRE';
shift;
- mkdir -p src; >src/lib.rs; >build.rs
ENDPRE
- $post = <<'ENDPOST';
- rm -r src Cargo.toml build.rs;
-ENDPOST
+# $post = <<'ENDCLEAN';
+# clean;
+#ENDCLEAN
}
my $addpath = (cfg_uc qw(oot path_add)) //
$use eq 'really' ? Types::Serialiser::true : Types::Serialiser::false;