1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, setuptools
5, setuptools-scm
6, pythonOlder
7, sdcc
8, amaranth
9, fx2
10, libusb1
11, aiohttp
12, pyvcd
13, bitarray
14, crcmod
15, yosys
16, icestorm
17, nextpnr
18}:
19
20buildPythonPackage rec {
21 pname = "glasgow";
22 version = "unstable-2021-12-12";
23 disabled = pythonOlder "3.7";
24 # python software/setup.py --version
25 realVersion = "0.1.dev1679+g${lib.substring 0 7 src.rev}";
26
27 src = fetchFromGitHub {
28 owner = "GlasgowEmbedded";
29 repo = "glasgow";
30 rev = "e640a778c446b7e9812727e73c560d12aeb41d7c";
31 sha256 = "EsQ9ZjalKDQ54JOonra4yPDI56cF5n86y/Rd798cZsU=";
32 };
33
34 nativeBuildInputs = [ setuptools-scm sdcc ];
35
36 propagatedBuildInputs = [
37 setuptools
38 amaranth
39 fx2
40 libusb1
41 aiohttp
42 pyvcd
43 bitarray
44 crcmod
45 ];
46
47 checkInputs = [ yosys icestorm nextpnr ];
48
49 enableParallelBuilding = true;
50
51 preBuild = ''
52 make -C firmware LIBFX2=${fx2}/share/libfx2
53 cp firmware/glasgow.ihex software/glasgow
54 cd software
55 export SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}"
56 '';
57
58 # installCheck tries to build_ext again
59 doInstallCheck = false;
60
61 checkPhase = ''
62 python -W ignore::DeprecationWarning test.py
63 '';
64
65 makeWrapperArgs = [
66 "--set" "YOSYS" "${yosys}/bin/yosys"
67 "--set" "ICEPACK" "${icestorm}/bin/icepack"
68 "--set" "NEXTPNR_ICE40" "${nextpnr}/bin/nextpnr-ice40"
69 ];
70
71 meta = with lib; {
72 description = "Software for Glasgow, a digital interface multitool";
73 homepage = "https://github.com/GlasgowEmbedded/Glasgow";
74 license = licenses.bsd0;
75 maintainers = with maintainers; [ emily thoughtpolice ];
76 };
77}