Commit bf2701a5 authored by Petr Hodina's avatar Petr Hodina Committed by Masum Reza
Browse files

xlink: init at 0-unstable-2025-14-03

parent d9a75b72
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6be6e8..057a056 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,12 +4,12 @@
 
 cmake_minimum_required(VERSION 3.2)
 
-include("cmake/HunterGate.cmake")
-HunterGate(
-    URL "https://github.com/cpp-pm/hunter/archive/9d9242b60d5236269f894efd3ddd60a9ca83dd7f.tar.gz"
-    SHA1 "16cc954aa723bccd16ea45fc91a858d0c5246376"
-    LOCAL # Local config for dependencies
-)
+# include("cmake/HunterGate.cmake")
+# HunterGate(
+#     URL "https://github.com/cpp-pm/hunter/archive/9d9242b60d5236269f894efd3ddd60a9ca83dd7f.tar.gz"
+#     SHA1 "16cc954aa723bccd16ea45fc91a858d0c5246376"
+#     LOCAL # Local config for dependencies
+# )
 
 ### Constants
 set(TARGET_NAME "XLink")
+85 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  pkg-config,
  libusb1,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "xlink";
  version = "0-unstable-2025-14-03";

  src = fetchFromGitHub {
    owner = "luxonis";
    repo = "XLink";
    rev = "fe8b5450f545a2ebf26dbc093e98c0265d7f4029";
    hash = "sha256-OTqJfTDudiNrdsDBe1Pg0T1dJcfneGXO/+AIbXpVfxk=";
  };

  outputs = [
    "out"
    "share"
  ];

  # Remove CMake Hunter package manager - needs network connection
  patches = [
    ./001-remove-hunter.patch
  ];

  nativeBuildInputs = [
    cmake
    pkg-config
  ];

  buildInputs = [
    libusb1
  ];

  cmakeFlags = [
    (lib.cmakeBool "XLINK_ENABLE_LIBUSB" true)
    (lib.cmakeBool "XLINK_BUILD_EXAMPLES" true)
    (lib.cmakeBool "XLINK_BUILD_TESTS" true)
    (lib.cmakeBool "XLINK_LIBUSB_SYSTEM" true)
    (lib.cmakeFeature "CMAKE_BUILD_TYPE" "Release")
  ];

  postInstall = ''
    mkdir -p $out/include
    mkdir -p $share/examples
    mkdir -p $share/tests

    cp -r $src/include/* $out/include/

    examples=(
      "boot_firmware"
      "list_devices"
      "boot_bootloader"
      "search_devices"
      "Makefile"
      "device_connect_reset"
    )

    tests=(
      "multiple_open_stream"
      "multithreading_search_test"
    )

    find $buildDir
    for file in "''${examples[@]}"; do
      cp examples/$file $share/examples/$file
    done
    for file in "''${tests[@]}"; do
      cp tests/$file $share/tests/$file
    done
  '';

  meta = {
    description = "XLink library for communication with Myriad VPUs";
    homepage = "https://github.com/luxonis/XLink";
    license = lib.licenses.asl20;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ phodina ];
  };
})