about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCosima Neidahl <opna2608@protonmail.com>2024-06-02 07:09:31 +0200
committerGitHub <noreply@github.com>2024-06-02 07:09:31 +0200
commit0b5c90b5b991e8b93df3f80239501d38c9630816 (patch)
treeb93aebc8b4305dab3d224c3728265abe06b58e98
parent6634a0509e9e81e980b129435fbbec518ab246d0 (diff)
parentcefebba4ff3cacca41353656ce9641f6deb93c6c (diff)
Merge pull request #314875 from OPNA2608/fix/box64-loongarch-dynrec
box64: LoongArch dynarec, modernisations, formatting
-rw-r--r--pkgs/applications/emulators/box64/default.nix104
1 files changed, 62 insertions, 42 deletions
diff --git a/pkgs/applications/emulators/box64/default.nix b/pkgs/applications/emulators/box64/default.nix
index 6d15889ee50c8..5a6e87b0644aa 100644
--- a/pkgs/applications/emulators/box64/default.nix
+++ b/pkgs/applications/emulators/box64/default.nix
@@ -1,16 +1,23 @@
-{ lib
-, stdenv
-, fetchFromGitHub
-, gitUpdater
-, cmake
-, python3
-, withDynarec ? (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isRiscV64)
-, runCommand
-, hello-x86_64
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  gitUpdater,
+  cmake,
+  python3,
+  withDynarec ? (
+    stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isRiscV64 || stdenv.hostPlatform.isLoongArch64
+  ),
+  runCommand,
+  hello-x86_64,
 }:
 
-# Currently only supported on ARM & RISC-V
-assert withDynarec -> (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isRiscV64);
+# Currently only supported on specific archs
+assert
+  withDynarec
+  -> (
+    stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isRiscV64 || stdenv.hostPlatform.isLoongArch64
+  );
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "box64";
@@ -28,23 +35,27 @@ stdenv.mkDerivation (finalAttrs: {
     python3
   ];
 
-  cmakeFlags = [
-    "-DNOGIT=ON"
-
-    # Arch mega-option
-    "-DARM64=${lib.boolToString stdenv.hostPlatform.isAarch64}"
-    "-DRV64=${lib.boolToString stdenv.hostPlatform.isRiscV64}"
-    "-DPPC64LE=${lib.boolToString (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian)}"
-    "-DLARCH64=${lib.boolToString stdenv.hostPlatform.isLoongArch64}"
-  ] ++ lib.optionals stdenv.hostPlatform.isx86_64 [
-    # x86_64 has no arch-specific mega-option, manually enable the options that apply to it
-    "-DLD80BITS=ON"
-    "-DNOALIGN=ON"
-  ] ++ [
-    # Arch dynarec
-    "-DARM_DYNAREC=${lib.boolToString (withDynarec && stdenv.hostPlatform.isAarch64)}"
-    "-DRV64_DYNAREC=${lib.boolToString (withDynarec && stdenv.hostPlatform.isRiscV64)}"
-  ];
+  cmakeFlags =
+    [
+      (lib.cmakeBool "NOGIT" true)
+
+      # Arch mega-option
+      (lib.cmakeBool "ARM64" stdenv.hostPlatform.isAarch64)
+      (lib.cmakeBool "RV64" stdenv.hostPlatform.isRiscV64)
+      (lib.cmakeBool "PPC64LE" (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian))
+      (lib.cmakeBool "LARCH64" stdenv.hostPlatform.isLoongArch64)
+    ]
+    ++ lib.optionals stdenv.hostPlatform.isx86_64 [
+      # x86_64 has no arch-specific mega-option, manually enable the options that apply to it
+      (lib.cmakeBool "LD80BITS" true)
+      (lib.cmakeBool "NOALIGN" true)
+    ]
+    ++ [
+      # Arch dynarec
+      (lib.cmakeBool "ARM_DYNAREC" (withDynarec && stdenv.hostPlatform.isAarch64))
+      (lib.cmakeBool "RV64_DYNAREC" (withDynarec && stdenv.hostPlatform.isRiscV64))
+      (lib.cmakeBool "LARCH64_DYNAREC" (withDynarec && stdenv.hostPlatform.isLoongArch64))
+    ];
 
   installPhase = ''
     runHook preInstall
@@ -71,24 +82,33 @@ stdenv.mkDerivation (finalAttrs: {
   '';
 
   passthru = {
-    updateScript = gitUpdater {
-      rev-prefix = "v";
-    };
-    tests.hello = runCommand "box64-test-hello" {
-      nativeBuildInputs = [ finalAttrs.finalPackage ];
-    } ''
-      # There is no actual "Hello, world!" with any of the logging enabled, and with all logging disabled it's hard to
-      # tell what problems the emulator has run into.
-      BOX64_NOBANNER=0 BOX64_LOG=1 box64 ${hello-x86_64}/bin/hello --version | tee $out
-    '';
+    updateScript = gitUpdater { rev-prefix = "v"; };
+    tests.hello =
+      runCommand "box64-test-hello" { nativeBuildInputs = [ finalAttrs.finalPackage ]; }
+        # There is no actual "Hello, world!" with any of the logging enabled, and with all logging disabled it's hard to
+        # tell what problems the emulator has run into.
+        ''
+          BOX64_NOBANNER=0 BOX64_LOG=1 box64 ${lib.getExe hello-x86_64} --version | tee $out
+        '';
   };
 
-  meta = with lib; {
+  meta = {
     homepage = "https://box86.org/";
     description = "Lets you run x86_64 Linux programs on non-x86_64 Linux systems";
-    license = licenses.mit;
-    maintainers = with maintainers; [ gador OPNA2608 ];
+    changelog = "https://github.com/ptitSeb/box64/releases/tag/v${finalAttrs.version}";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [
+      gador
+      OPNA2608
+    ];
     mainProgram = "box64";
-    platforms = [ "x86_64-linux" "aarch64-linux" "riscv64-linux" "powerpc64le-linux" "loongarch64-linux" "mips64el-linux" ];
+    platforms = [
+      "x86_64-linux"
+      "aarch64-linux"
+      "riscv64-linux"
+      "powerpc64le-linux"
+      "loongarch64-linux"
+      "mips64el-linux"
+    ];
   };
 })