setup hook supplying a cmake toolchain file

This commit is contained in:
Wolfgang Thaller 2021-11-24 22:07:10 +01:00
parent 347a21596d
commit 90b7a3332d

View File

@ -2,7 +2,7 @@
description = "Cross compilation toolchain for classic Macs";
# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-21.05";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.multiversal_src.url = "github:autc04/multiversal";
inputs.multiversal_src.flake = false;
@ -46,6 +46,7 @@
retro68GccConfig = [ "--with-arch=m68k" "--with-cpu=m68000" ];
retro68 = true;
cmakeSystemName = "Retro68";
};
powerpc = {
system = "powerpc-macos";
@ -68,6 +69,7 @@
retro68BinutilsConfig = [ "--disable-plugins" ];
retro68GccConfig = [ "--disable-lto" ];
retro68 = true;
cmakeSystemName = "RetroPPC";
};
carbon = {
system = "powerpc-carbon";
@ -85,6 +87,7 @@
execFormat = { name = "unknown"; };
};
};
cmakeSystemName = "RetroCarbon";
};
isStatic = true;
@ -221,6 +224,7 @@
extraPackages = with pkgs.targetPackages; [
multiversal
libretro
retro68_setup_hook
];
}
else
@ -230,6 +234,27 @@
libcCrossChooser = name:
if name == "retro68" then null else prev.libcCrossChooser name;
retro68_setup_hook = let
systemName = pkgs.targetPlatform.cmakeSystemName;
toolchain = pkgs.writeTextFile {
name = "retro68-cmake-toolchain";
text = ''
set(CMAKE_SYSTEM_NAME ${systemName})
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_CROSSCOMPILING TRUE)
set( REZ "${pkgs.buildPackages.retro68_tools}/bin/Rez" )
set( REZ_INCLUDE_PATH "${pkgs.multiversal}/RIncludes" )
include(${self + "/cmake/add_application.cmake"})
'';
};
hook = pkgs.writeTextFile {
name = "retro68_setup_hook";
text = "export CMAKE_TOOLCHAIN_FILE=${toolchain}";
};
in pkgs.makeSetupHook { } hook;
# ----------- Retro68 core libraries -------------
# multiversal -- multiversal interfaces
@ -264,7 +289,7 @@
src = filterSrc (self + /libretro);
nativeBuildInputs = [ buildPackages.cmake ];
buildInputs = [ multiversal ];
buildInputs = [ multiversal retro68_setup_hook ];
buildCommand = ''
echo "Build command."