2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2019-03-30 05:16:55 +00:00
|
|
|
, fetchFromGitHub
|
2019-03-30 22:54:39 +00:00
|
|
|
, autoPatchelfHook
|
2019-03-30 05:16:55 +00:00
|
|
|
, libusb-compat-0_1
|
|
|
|
, readline ? null
|
|
|
|
, enableReadline ? true
|
2019-07-02 21:46:54 +01:00
|
|
|
, hidapi ? null
|
|
|
|
, pkg-config ? null
|
2019-03-30 22:54:39 +00:00
|
|
|
, mspds ? null
|
|
|
|
, enableMspds ? false
|
2019-03-30 05:16:55 +00:00
|
|
|
}:
|
2019-03-26 18:19:09 +00:00
|
|
|
|
2019-07-02 21:46:54 +01:00
|
|
|
assert stdenv.isDarwin -> hidapi != null && pkg-config != null;
|
2019-03-30 05:16:55 +00:00
|
|
|
assert enableReadline -> readline != null;
|
2019-03-30 22:54:39 +00:00
|
|
|
assert enableMspds -> mspds != null;
|
2019-03-30 05:16:55 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-03-26 18:19:09 +00:00
|
|
|
version = "0.25";
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "mspdebug";
|
2019-03-26 18:19:09 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "dlbeer";
|
|
|
|
repo = "mspdebug";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0prgwb5vx6fd4bj12ss1bbb6axj2kjyriyjxqrzd58s5jyyy8d3c";
|
|
|
|
};
|
|
|
|
|
2019-07-02 21:46:54 +01:00
|
|
|
enableParallelBuilding = true;
|
2021-01-23 17:15:07 +00:00
|
|
|
nativeBuildInputs = lib.optional stdenv.isDarwin pkg-config
|
|
|
|
++ lib.optional (enableMspds && stdenv.isLinux) autoPatchelfHook;
|
2019-03-30 05:16:55 +00:00
|
|
|
buildInputs = [ libusb-compat-0_1 ]
|
2021-01-23 17:15:07 +00:00
|
|
|
++ lib.optional stdenv.isDarwin hidapi
|
|
|
|
++ lib.optional enableReadline readline;
|
2019-07-02 21:46:54 +01:00
|
|
|
|
2021-01-23 17:15:07 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
2019-07-02 21:46:54 +01:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2019-03-30 22:54:39 +00:00
|
|
|
# TODO: wrap with MSPDEBUG_TILIB_PATH env var instead of these rpath fixups in 0.26+
|
2021-01-23 17:15:07 +00:00
|
|
|
runtimeDependencies = lib.optional enableMspds mspds;
|
|
|
|
postFixup = lib.optionalString (enableMspds && stdenv.isDarwin) ''
|
2019-03-30 22:54:39 +00:00
|
|
|
# autoPatchelfHook only works on linux so...
|
|
|
|
for dep in $runtimeDependencies; do
|
|
|
|
install_name_tool -add_rpath $dep/lib $out/bin/$pname
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2019-03-30 05:16:55 +00:00
|
|
|
installFlags = [ "PREFIX=$(out)" "INSTALL=install" ];
|
2019-07-02 21:46:54 +01:00
|
|
|
makeFlags = [ "UNAME_S=$(unameS)" ] ++
|
2021-01-23 17:15:07 +00:00
|
|
|
lib.optional (!enableReadline) "WITHOUT_READLINE=1";
|
|
|
|
unameS = lib.optionalString stdenv.isDarwin "Darwin";
|
2019-03-26 18:19:09 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-03-26 18:19:09 +00:00
|
|
|
description = "A free programmer, debugger, and gdb proxy for MSP430 MCUs";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://dlbeer.co.nz/mspdebug/";
|
2019-03-26 18:19:09 +00:00
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ aerialx ];
|
|
|
|
};
|
|
|
|
}
|