cross compile for windows and macOS
This commit is contained in:
parent
13893e96a9
commit
b02581e62d
2 changed files with 61 additions and 36 deletions
91
default.nix
91
default.nix
|
@ -1,5 +1,4 @@
|
||||||
{
|
{ lib,
|
||||||
lib,
|
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
nix-gitignore,
|
nix-gitignore,
|
||||||
bash,
|
bash,
|
||||||
|
@ -11,43 +10,63 @@
|
||||||
pkg-config,
|
pkg-config,
|
||||||
libxkbcommon,
|
libxkbcommon,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
stdenv,
|
||||||
|
targetPackages ? pkgs,
|
||||||
}: let
|
}: let
|
||||||
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
|
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
|
||||||
src = nix-gitignore.gitignoreSource [] ./.;
|
src = nix-gitignore.gitignoreSource [] ./.;
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "zenyx";
|
pname = "zenyx";
|
||||||
inherit src version;
|
inherit src version;
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
nativeBuildInputs = [
|
|
||||||
makeWrapper
|
|
||||||
pkg-config
|
|
||||||
];
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
wayland
|
|
||||||
vulkan-loader
|
|
||||||
libxkbcommon
|
|
||||||
libGL
|
|
||||||
libxkbcommon
|
|
||||||
xorg.libXcursor
|
|
||||||
xorg.libXrandr
|
|
||||||
xorg.libXi
|
|
||||||
xorg.libX11
|
|
||||||
xorg.libxcb
|
|
||||||
bash
|
|
||||||
dav1d
|
|
||||||
];
|
|
||||||
doCheck = false;
|
|
||||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
|
|
||||||
|
|
||||||
fixupPhase = ''
|
nativeBuildInputs = [
|
||||||
wrapProgram $out/bin/${pname} --set PATH ${bash}/bin:\$PATH --set LD_LIBRARY_PATH ${pkgs.lib.makeLibraryPath buildInputs}
|
pkg-config
|
||||||
'';
|
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||||
|
targetPackages.darwin.apple_sdk.frameworks.CoreServices
|
||||||
|
];
|
||||||
|
|
||||||
meta = {
|
buildInputs = with targetPackages; [
|
||||||
description = "Test";
|
dav1d
|
||||||
license = lib.licenses.mit;
|
] ++ lib.optionals (stdenv.targetPlatform.isLinux || stdenv.targetPlatform.isWindows) [
|
||||||
platforms = lib.platforms.linux;
|
vulkan-loader
|
||||||
mainProgram = "zenyx";
|
] ++ lib.optionals stdenv.targetPlatform.isLinux [
|
||||||
};
|
makeWrapper
|
||||||
}
|
wayland
|
||||||
|
libxkbcommon
|
||||||
|
libGL
|
||||||
|
xorg.libXcursor
|
||||||
|
xorg.libXrandr
|
||||||
|
xorg.libXi
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libxcb
|
||||||
|
bash
|
||||||
|
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||||
|
makeWrapper
|
||||||
|
darwin.apple_sdk.frameworks.Cocoa
|
||||||
|
darwin.apple_sdk.frameworks.Metal
|
||||||
|
darwin.apple_sdk.frameworks.CoreVideo
|
||||||
|
darwin.apple_sdk.frameworks.QuartzCore
|
||||||
|
];
|
||||||
|
|
||||||
|
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER =
|
||||||
|
lib.optionalString stdenv.targetPlatform.isWindows "${stdenv.cc.targetPrefix}gcc";
|
||||||
|
|
||||||
|
NIX_LDFLAGS = lib.optionalString stdenv.targetPlatform.isDarwin "-framework CoreFoundation";
|
||||||
|
|
||||||
|
postInstall = lib.optionalString stdenv.targetPlatform.isLinux ''
|
||||||
|
wrapProgram $out/bin/${pname} \
|
||||||
|
--prefix PATH : ${lib.makeBinPath [ bash ]} \
|
||||||
|
--set LD_LIBRARY_PATH ${lib.makeLibraryPath buildInputs}
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Cross-platform WSYWIG Game Engine";
|
||||||
|
license = lib.licenses.mit;
|
||||||
|
platforms = lib.platforms.all;
|
||||||
|
mainProgram = "zenyx";
|
||||||
|
};
|
||||||
|
}
|
|
@ -48,6 +48,12 @@
|
||||||
packages = {
|
packages = {
|
||||||
inherit (pkgs) zenyx;
|
inherit (pkgs) zenyx;
|
||||||
default = pkgs.zenyx;
|
default = pkgs.zenyx;
|
||||||
|
windows = let
|
||||||
|
pkgsCross = import nixpkgs {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
crossSystem = nixpkgs.lib.systems.examples.mingwW64;
|
||||||
|
};
|
||||||
|
in pkgsCross.callPackage ./default.nix {};
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue