lol

Merge pull request #144193 from Ericson2314/rust-build-support-org

build-support/rust: Organize

authored by

John Ericson and committed by
GitHub
ccd6afdd 3b0bff38

+50 -35
pkgs/build-support/rust/cargo-vendor-normalise.py pkgs/build-support/rust/fetch-cargo-tarball/cargo-vendor-normalise.py
pkgs/build-support/rust/default.nix pkgs/build-support/rust/build-rust-package/default.nix
+2 -2
pkgs/build-support/rust/fetchCargoTarball.nix pkgs/build-support/rust/fetch-cargo-tarball/default.nix
··· 9 9 postFixup = "wrapPythonPrograms"; 10 10 doInstallCheck = true; 11 11 installCheckPhase = '' 12 - # check that ./fetchcargo-default-config.toml is a fix point 13 - reference=${./fetchcargo-default-config.toml} 12 + # check that ../fetchcargo-default-config.toml is a fix point 13 + reference=${../fetchcargo-default-config.toml} 14 14 < $reference $out/bin/cargo-vendor-normalise > test; 15 15 cmp test $reference 16 16 '';
+37
pkgs/build-support/rust/lib/default.nix
··· 1 + { lib }: 2 + 3 + rec { 4 + # https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch 5 + toTargetArch = platform: 6 + if platform.isAarch32 then "arm" 7 + else platform.parsed.cpu.name; 8 + 9 + # https://doc.rust-lang.org/reference/conditional-compilation.html#target_os 10 + toTargetOs = platform: 11 + if platform.isDarwin then "macos" 12 + else platform.parsed.kernel.name; 13 + 14 + # Returns the name of the rust target, even if it is custom. Adjustments are 15 + # because rust has slightly different naming conventions than we do. 16 + toRustTarget = platform: let 17 + inherit (platform.parsed) cpu vendor kernel abi; 18 + cpu_ = platform.rustc.platform.arch or { 19 + "armv7a" = "armv7"; 20 + "armv7l" = "armv7"; 21 + "armv6l" = "arm"; 22 + "armv5tel" = "armv5te"; 23 + "riscv64" = "riscv64gc"; 24 + }.${cpu.name} or cpu.name; 25 + vendor_ = platform.rustc.platform.vendor or { 26 + "w64" = "pc"; 27 + }.${vendor.name} or vendor.name; 28 + in platform.rustc.config 29 + or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"; 30 + 31 + # Returns the name of the rust target if it is standard, or the json file 32 + # containing the custom target spec. 33 + toRustTargetSpec = platform: 34 + if (platform.rustc or {}) ? platform 35 + then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform) 36 + else toRustTarget platform; 37 + }
pkgs/build-support/rust/patch-registry-deps/pkg-config pkgs/build-support/rust/build-rust-package/patch-registry-deps/pkg-config
pkgs/build-support/rust/sysroot/Cargo.lock pkgs/build-support/rust/build-rust-package/sysroot/Cargo.lock
pkgs/build-support/rust/sysroot/cargo.py pkgs/build-support/rust/build-rust-package/sysroot/cargo.py
pkgs/build-support/rust/sysroot/default.nix pkgs/build-support/rust/build-rust-package/sysroot/default.nix
pkgs/build-support/rust/sysroot/update-lockfile.sh pkgs/build-support/rust/build-rust-package/sysroot/update-lockfile.sh
+9 -31
pkgs/development/compilers/rust/default.nix
··· 18 18 , CoreFoundation, Security, SystemConfiguration 19 19 , pkgsBuildTarget, pkgsBuildBuild 20 20 , makeRustPlatform 21 - }: rec { 22 - # https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch 23 - toTargetArch = platform: 24 - if platform.isAarch32 then "arm" 25 - else platform.parsed.cpu.name; 26 - 27 - # https://doc.rust-lang.org/reference/conditional-compilation.html#target_os 28 - toTargetOs = platform: 29 - if platform.isDarwin then "macos" 30 - else platform.parsed.kernel.name; 21 + }: 31 22 32 - # Returns the name of the rust target, even if it is custom. Adjustments are 33 - # because rust has slightly different naming conventions than we do. 34 - toRustTarget = platform: with platform.parsed; let 35 - cpu_ = platform.rustc.platform.arch or { 36 - "armv7a" = "armv7"; 37 - "armv7l" = "armv7"; 38 - "armv6l" = "arm"; 39 - "armv5tel" = "armv5te"; 40 - "riscv64" = "riscv64gc"; 41 - }.${cpu.name} or cpu.name; 42 - vendor_ = platform.rustc.platform.vendor or { 43 - "w64" = "pc"; 44 - }.${vendor.name} or vendor.name; 45 - in platform.rustc.config 46 - or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"; 23 + let 24 + # Use `import` to make sure no packages sneak in here. 25 + lib' = import ../../../build-support/rust/lib { inherit lib; }; 26 + in 27 + { 28 + lib = lib'; 47 29 48 - # Returns the name of the rust target if it is standard, or the json file 49 - # containing the custom target spec. 50 - toRustTargetSpec = platform: 51 - if (platform.rustc or {}) ? platform 52 - then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform) 53 - else toRustTarget platform; 30 + # Backwards compat before `lib` was factored out. 31 + inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec; 54 32 55 33 # This just contains tools for now. But it would conceivably contain 56 34 # libraries too, say if we picked some default/recommended versions from
+2 -2
pkgs/development/compilers/rust/make-rust-platform.nix
··· 7 7 inherit rustc cargo; 8 8 }; 9 9 10 - fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetchCargoTarball.nix { 10 + fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetch-cargo-tarball { 11 11 git = buildPackages.gitMinimal; 12 12 inherit cargo; 13 13 }; 14 14 15 - buildRustPackage = callPackage ../../../build-support/rust { 15 + buildRustPackage = callPackage ../../../build-support/rust/build-rust-package { 16 16 git = buildPackages.gitMinimal; 17 17 inherit stdenv cargoBuildHook cargoCheckHook cargoInstallHook cargoSetupHook 18 18 fetchCargoTarball importCargoLock rustc;