mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 23:17:15 +03:00
Make remapSourcePathPrefixHook potentially customizable
This commit is contained in:
parent
32ca849598
commit
8d6d973261
@ -1,9 +1,11 @@
|
||||
remapPathPrefix() {
|
||||
if [ -z "${cargoVendorDir-}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local remapArgs="--remap-path-prefix ${cargoVendorDir}=/sources"
|
||||
# We unfortunately cannot get away with *just* stripping a `/nix/store` prefix
|
||||
# since nix will still find references to the `<sha>-dirname` floating around
|
||||
# and decide that the binaries must depend on the source files themselves.
|
||||
# To get around this we actually have to strip the entire prefix of the vendored
|
||||
# directory (or provided input).
|
||||
local prefixToRemap=${1:?prefixToRemap not specified}
|
||||
local remapArgs="--remap-path-prefix ${prefixToRemap}=/sources"
|
||||
|
||||
if [ -n "${RUSTFLAGS}" ]; then
|
||||
export RUSTFLAGS="${RUSTFLAGS} ${remapArgs}"
|
||||
@ -18,6 +20,12 @@ remapPathPrefix() {
|
||||
fi
|
||||
}
|
||||
|
||||
remapPathPrefixToVendoredDir() {
|
||||
if [ -n "${cargoVendorDir-}" ]; then
|
||||
remapPathPrefix "${cargoVendorDir}"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "1" = "${doRemapSourcePathPrefix-}" ]; then
|
||||
postConfigureHooks+=(remapPathPrefix)
|
||||
postConfigureHooks+=(remapPathPrefixToVendoredDir)
|
||||
fi
|
||||
|
@ -17,7 +17,6 @@ pkgs.lib.makeScope myLib.newScope (self:
|
||||
|
||||
compilesFresh = callPackage ./compilesFresh.nix { };
|
||||
compilesFreshSimple = self.compilesFresh ./simple "simple";
|
||||
|
||||
compilesFreshOverlappingTargets = self.compilesFresh
|
||||
./overlapping-targets
|
||||
(builtins.concatStringsSep "\n" [
|
||||
@ -29,12 +28,11 @@ pkgs.lib.makeScope myLib.newScope (self:
|
||||
|
||||
customCargoTargetDirectory =
|
||||
let
|
||||
simple = myLib.buildWithCargo {
|
||||
simple = self.simple.overrideAttrs (old: {
|
||||
name = "customCargoTargetDirectory";
|
||||
doCopyTargetToOutput = false;
|
||||
src = ./simple;
|
||||
CARGO_TARGET_DIR = "some/nested/custom-cargo-dir";
|
||||
};
|
||||
});
|
||||
in
|
||||
pkgs.runCommand "smoke-simple" { } ''
|
||||
# does it run?
|
||||
@ -42,18 +40,16 @@ pkgs.lib.makeScope myLib.newScope (self:
|
||||
touch $out
|
||||
'';
|
||||
|
||||
smokeSimple =
|
||||
let
|
||||
simple = myLib.buildWithCargo {
|
||||
doCopyTargetToOutput = false;
|
||||
src = ./simple;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "smoke-simple" { } ''
|
||||
# does it run?
|
||||
${simple}/bin/simple
|
||||
touch $out
|
||||
'';
|
||||
simple = myLib.buildWithCargo {
|
||||
doCopyTargetToOutput = false;
|
||||
src = ./simple;
|
||||
};
|
||||
|
||||
smokeSimple = pkgs.runCommand "smoke-simple" { } ''
|
||||
# does it run?
|
||||
${self.simple}/bin/simple
|
||||
touch $out
|
||||
'';
|
||||
|
||||
smokeOverlappingTargets =
|
||||
let
|
||||
|
Loading…
Reference in New Issue
Block a user