lemoa: inline the cross compilation fix
This commit is contained in:
@@ -52,63 +52,63 @@ let
|
||||
typelibPath = pkgs: lib.concatStringsSep ":" (builtins.map (p: "${lib.getLib p}/lib/girepository-1.0") pkgs);
|
||||
|
||||
# `cargo` which adds the correct env vars and `--target` flag when invoked from meson build scripts
|
||||
crossCargo = let
|
||||
inherit (final.pkgsBuildHost) cargo;
|
||||
inherit (final.rust.envVars) setEnv rustHostPlatformSpec;
|
||||
in (final.pkgsBuildBuild.writeShellScriptBin "cargo" ''
|
||||
targetDir=target
|
||||
isFlavored=
|
||||
outDir=
|
||||
profile=
|
||||
# crossCargo = let
|
||||
# inherit (final.pkgsBuildHost) cargo;
|
||||
# inherit (final.rust.envVars) setEnv rustHostPlatformSpec;
|
||||
# in (final.pkgsBuildBuild.writeShellScriptBin "cargo" ''
|
||||
# targetDir=target
|
||||
# isFlavored=
|
||||
# outDir=
|
||||
# profile=
|
||||
|
||||
cargoArgs=("$@")
|
||||
nextIsOutDir=
|
||||
nextIsProfile=
|
||||
nextIsTargetDir=
|
||||
for arg in "''${cargoArgs[@]}"; do
|
||||
if [[ -n "$nextIsOutDir" ]]; then
|
||||
nextIsOutDir=
|
||||
outDir="$arg"
|
||||
elif [[ -n "$nextIsProfile" ]]; then
|
||||
nextIsProfile=
|
||||
profile="$arg"
|
||||
elif [[ -n "$nextIsTargetDir" ]]; then
|
||||
nextIsTargetDir=
|
||||
targetDir="$arg"
|
||||
elif [[ "$arg" = "build" ]]; then
|
||||
isFlavored=1
|
||||
elif [[ "$arg" = "--out-dir" ]]; then
|
||||
nextIsOutDir=1
|
||||
elif [[ "$arg" = "--profile" ]]; then
|
||||
nextIsProfile=1
|
||||
elif [[ "$arg" = "--release" ]]; then
|
||||
profile=release
|
||||
elif [[ "$arg" = "--target-dir" ]]; then
|
||||
nextIsTargetDir=1
|
||||
fi
|
||||
done
|
||||
# cargoArgs=("$@")
|
||||
# nextIsOutDir=
|
||||
# nextIsProfile=
|
||||
# nextIsTargetDir=
|
||||
# for arg in "''${cargoArgs[@]}"; do
|
||||
# if [[ -n "$nextIsOutDir" ]]; then
|
||||
# nextIsOutDir=
|
||||
# outDir="$arg"
|
||||
# elif [[ -n "$nextIsProfile" ]]; then
|
||||
# nextIsProfile=
|
||||
# profile="$arg"
|
||||
# elif [[ -n "$nextIsTargetDir" ]]; then
|
||||
# nextIsTargetDir=
|
||||
# targetDir="$arg"
|
||||
# elif [[ "$arg" = "build" ]]; then
|
||||
# isFlavored=1
|
||||
# elif [[ "$arg" = "--out-dir" ]]; then
|
||||
# nextIsOutDir=1
|
||||
# elif [[ "$arg" = "--profile" ]]; then
|
||||
# nextIsProfile=1
|
||||
# elif [[ "$arg" = "--release" ]]; then
|
||||
# profile=release
|
||||
# elif [[ "$arg" = "--target-dir" ]]; then
|
||||
# nextIsTargetDir=1
|
||||
# fi
|
||||
# done
|
||||
|
||||
extraFlags=()
|
||||
# extraFlags=()
|
||||
|
||||
# not all subcommands support flavored arguments like `--target`
|
||||
if [ -n "$isFlavored" ]; then
|
||||
# pass the target triple to cargo so it will cross compile
|
||||
# and fix so it places outputs in the same directory as non-cross, see: <https://doc.rust-lang.org/cargo/guide/build-cache.html>
|
||||
extraFlags+=(
|
||||
--target "${rustHostPlatformSpec}"
|
||||
-Z unstable-options
|
||||
)
|
||||
if [ -z "$outDir" ]; then
|
||||
extraFlags+=(
|
||||
--out-dir "$targetDir"/''${profile:-debug}
|
||||
)
|
||||
fi
|
||||
fi
|
||||
# # not all subcommands support flavored arguments like `--target`
|
||||
# if [ -n "$isFlavored" ]; then
|
||||
# # pass the target triple to cargo so it will cross compile
|
||||
# # and fix so it places outputs in the same directory as non-cross, see: <https://doc.rust-lang.org/cargo/guide/build-cache.html>
|
||||
# extraFlags+=(
|
||||
# --target "${rustHostPlatformSpec}"
|
||||
# -Z unstable-options
|
||||
# )
|
||||
# if [ -z "$outDir" ]; then
|
||||
# extraFlags+=(
|
||||
# --out-dir "$targetDir"/''${profile:-debug}
|
||||
# )
|
||||
# fi
|
||||
# fi
|
||||
|
||||
exec ${setEnv} "${lib.getExe cargo}" "$@" "''${extraFlags[@]}"
|
||||
'').overrideAttrs {
|
||||
inherit (cargo) meta;
|
||||
};
|
||||
# exec ${setEnv} "${lib.getExe cargo}" "$@" "''${extraFlags[@]}"
|
||||
# '').overrideAttrs {
|
||||
# inherit (cargo) meta;
|
||||
# };
|
||||
in with final; {
|
||||
# binutils = prev.binutils.override {
|
||||
# # fix that resulting binary files would specify build #!sh as their interpreter.
|
||||
@@ -295,7 +295,7 @@ in with final; {
|
||||
# ];
|
||||
# });
|
||||
|
||||
lemoa = prev.lemoa.override { cargo = crossCargo; };
|
||||
# lemoa = prev.lemoa.override { cargo = crossCargo; };
|
||||
|
||||
# libsForQt5 = prev.libsForQt5.overrideScope (self: super: {
|
||||
# # 2025/07/27: upstreaming is blocked on qtsvg
|
||||
|
@@ -33,6 +33,12 @@ stdenv.mkDerivation rec {
|
||||
hash = "sha256-ALoxT+RLL4omJ7quWDJVdXgevaO8i8q/29FFFudIRV4=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace src/meson.build --replace-fail \
|
||||
"'target' / rust_target / meson.project_name()" \
|
||||
"'target' / '${stdenv.hostPlatform.rust.cargoShortTarget}' / rust_target / meson.project_name()"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo
|
||||
desktop-file-utils
|
||||
@@ -49,6 +55,8 @@ stdenv.mkDerivation rec {
|
||||
openssl
|
||||
];
|
||||
|
||||
env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
|
||||
|
||||
passthru.updateScript = gitUpdater {
|
||||
rev-prefix = "v";
|
||||
};
|
||||
|
Reference in New Issue
Block a user