From: Ian Jackson Date: Sat, 25 Jul 2020 15:49:36 +0000 (+0100) Subject: Make a shallow symlink farm X-Git-Tag: nailing-cargo/1.0.0~81 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b801615aca61808526735a34c52fe3c74e640e76;p=nailing-cargo.git Make a shallow symlink farm 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 --- diff --git a/README.md b/README.md index 672ddd4..eb516de 100644 --- a/README.md +++ b/README.md @@ -302,8 +302,8 @@ Options 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`. diff --git a/nailing-cargo b/nailing-cargo index 8eb65ec..354f1e7 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -510,21 +510,19 @@ sub oot_massage_cmdline () { $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;