diff options
author | Ryan Mulligan <ryan@ryantm.com> | 2020-06-28 21:10:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 21:10:10 -0700 |
commit | cbb7c81ac6a8e42c59d7f2233de7e28f32f47900 (patch) | |
tree | 7307b6fa6a07e07a243efade1373d7565dced7e6 /pkgs/development/misc | |
parent | 6d501a1161037803bab7cdb03ef54ff6ecfd9df7 (diff) | |
parent | 5ba76e94ec8d4d90f1f38b2ac9a2f5800fee0173 (diff) |
Merge pull request #58598 from AerialX/mspdebug-parallel
mspdebug: darwin fixes and enableParallelBuilding
Diffstat (limited to 'pkgs/development/misc')
-rw-r--r-- | pkgs/development/misc/msp430/mspdebug.nix | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/pkgs/development/misc/msp430/mspdebug.nix b/pkgs/development/misc/msp430/mspdebug.nix index 3c7ff00151a4d..471dd5b312292 100644 --- a/pkgs/development/misc/msp430/mspdebug.nix +++ b/pkgs/development/misc/msp430/mspdebug.nix @@ -1,10 +1,22 @@ -{ stdenv, fetchFromGitHub, libusb-compat-0_1, readline ? null }: +{ stdenv +, fetchFromGitHub +, autoPatchelfHook +, libusb-compat-0_1 +, readline ? null +, enableReadline ? true +, hidapi ? null +, pkg-config ? null +, mspds ? null +, enableMspds ? false +}: -let +assert stdenv.isDarwin -> hidapi != null && pkg-config != null; +assert enableReadline -> readline != null; +assert enableMspds -> mspds != null; + +stdenv.mkDerivation rec { version = "0.25"; -in stdenv.mkDerivation { pname = "mspdebug"; - inherit version; src = fetchFromGitHub { owner = "dlbeer"; repo = "mspdebug"; @@ -12,9 +24,34 @@ in stdenv.mkDerivation { sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c"; }; - buildInputs = [ libusb-compat-0_1 readline ]; - makeFlags = [ "PREFIX=$(out)" "INSTALL=install" ] ++ - (if readline == null then [ "WITHOUT_READLINE=1" ] else []); + enableParallelBuilding = true; + 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; + + 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 + ''; + + # 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"; + unameS = stdenv.lib.optionalString stdenv.isDarwin "Darwin"; meta = with stdenv.lib; { description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs"; |