From 1436bb9968fd14f2b992b2150c83d9b671d3a75e Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Fri, 29 Mar 2019 22:16:55 -0700 Subject: [PATCH 1/3] mspdebug: enableParallelBuilding and minor cleanup --- pkgs/development/misc/msp430/mspdebug.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix index 3c7ff00151a..f8abc15de57 100644 --- a/pkgs/development/misc/msp430/mspdebug.nix +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -1,10 +1,15 @@ -{ stdenv, fetchFromGitHub, libusb-compat-0_1, readline ? null }: +{ stdenv +, fetchFromGitHub +, libusb-compat-0_1 +, readline ? null +, enableReadline ? true +}: -let +assert enableReadline -> readline != null; + +stdenv.mkDerivation rec { version = "0.25"; -in stdenv.mkDerivation { pname = "mspdebug"; - inherit version; src = fetchFromGitHub { owner = "dlbeer"; repo = "mspdebug"; @@ -12,9 +17,11 @@ in stdenv.mkDerivation { sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"; }; - buildInputs = [ libusb-compat-0_1 readline ]; - makeFlags = [ "PREFIX=$(out)" "INSTALL=install" ] ++ - (if readline == null then [ "WITHOUT_READLINE=1" ] else []); + buildInputs = [ libusb-compat-0_1 ] + ++ stdenv.lib.optional enableReadline readline; + installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; + makeFlags = stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1"; + enableParallelBuilding = true; meta = with stdenv.lib; { description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs"; From ceef1d2f27b4e1be6d6e3a49ed72c4c7501087df Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 2 Jul 2019 13:46:54 -0700 Subject: [PATCH 2/3] mspdebug: fix darwin build --- pkgs/development/misc/msp430/mspdebug.nix | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix index f8abc15de57..181907a5544 100644 --- a/pkgs/development/misc/msp430/mspdebug.nix +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -3,8 +3,11 @@ , libusb-compat-0_1 , readline ? null , enableReadline ? true +, hidapi ? null +, pkg-config ? null }: +assert stdenv.isDarwin -> hidapi != null && pkg-config != null; assert enableReadline -> readline != null; stdenv.mkDerivation rec { @@ -17,11 +20,24 @@ stdenv.mkDerivation rec { sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"; }; - buildInputs = [ libusb-compat-0_1 ] - ++ stdenv.lib.optional enableReadline readline; - installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; - makeFlags = stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1"; enableParallelBuilding = true; + nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin pkg-config; + buildInputs = [ libusb-compat-0_1 ] + ++ stdenv.lib.optional stdenv.isDarwin hidapi + ++ stdenv.lib.optional enableReadline readline; + + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + # TODO: remove once a new 0.26+ release is made + substituteInPlace drivers/tilib_api.c --replace .so ${stdenv.hostPlatform.extensions.sharedLibrary} + + # Makefile only uses pkg-config if it detects homebrew + substituteInPlace Makefile --replace brew true + ''; + + installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; + makeFlags = [ "UNAME_S=$(unameS)" ] ++ + stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1"; + unameS = stdenv.lib.optionalString stdenv.isDarwin "Darwin"; meta = with stdenv.lib; { description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs"; From 5ba76e94ec8d4d90f1f38b2ac9a2f5800fee0173 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sat, 30 Mar 2019 15:54:39 -0700 Subject: [PATCH 3/3] mspdebug: optional runtime dependency on TI libmsp430 --- pkgs/development/misc/msp430/mspdebug.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix index 181907a5544..471dd5b3122 100644 --- a/pkgs/development/misc/msp430/mspdebug.nix +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -1,14 +1,18 @@ { stdenv , fetchFromGitHub +, autoPatchelfHook , libusb-compat-0_1 , readline ? null , enableReadline ? true , hidapi ? null , pkg-config ? null +, mspds ? null +, enableMspds ? false }: assert stdenv.isDarwin -> hidapi != null && pkg-config != null; assert enableReadline -> readline != null; +assert enableMspds -> mspds != null; stdenv.mkDerivation rec { version = "0.25"; @@ -21,7 +25,8 @@ stdenv.mkDerivation rec { }; enableParallelBuilding = true; - nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin pkg-config; + nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin pkg-config + ++ stdenv.lib.optional (enableMspds && stdenv.isLinux) autoPatchelfHook; buildInputs = [ libusb-compat-0_1 ] ++ stdenv.lib.optional stdenv.isDarwin hidapi ++ stdenv.lib.optional enableReadline readline; @@ -34,6 +39,15 @@ stdenv.mkDerivation rec { substituteInPlace Makefile --replace brew true ''; + # TODO: wrap with MSPDEBUG_TILIB_PATH env var instead of these rpath fixups in 0.26+ + runtimeDependencies = stdenv.lib.optional enableMspds mspds; + postFixup = stdenv.lib.optionalString (enableMspds && stdenv.isDarwin) '' + # autoPatchelfHook only works on linux so... + for dep in $runtimeDependencies; do + install_name_tool -add_rpath $dep/lib $out/bin/$pname + done + ''; + installFlags = [ "PREFIX=$(out)" "INSTALL=install" ]; makeFlags = [ "UNAME_S=$(unameS)" ] ++ stdenv.lib.optional (!enableReadline) "WITHOUT_READLINE=1";