python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / libvgm / default.nix
blobf7c85b292a6630c2b81fc6e6b45074bd62be805f
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , unstableGitUpdater
5 , cmake
6 , libiconv
7 , zlib
8 , enableShared ? true
10 , enableAudio ? true
11 , withWaveWrite ? true
12 , withWinMM ? stdenv.hostPlatform.isWindows
13 , withDirectSound ? stdenv.hostPlatform.isWindows
14 , withXAudio2 ? stdenv.hostPlatform.isWindows
15 , withWASAPI ? stdenv.hostPlatform.isWindows
16 , withOSS ? stdenv.hostPlatform.isFreeBSD
17 , withSADA ? stdenv.hostPlatform.isSunOS
18 , withALSA ? stdenv.hostPlatform.isLinux
19 , alsa-lib
20 , withPulseAudio ? stdenv.hostPlatform.isLinux
21 , libpulseaudio
22 , withCoreAudio ? stdenv.hostPlatform.isDarwin
23 , CoreAudio
24 , AudioToolbox
25 , withLibao ? true
26 , libao
28 , enableEmulation ? true
29 , withAllEmulators ? true
30 , emulators ? [ ]
32 , enableLibplayer ? true
34 , enableTools ? false
37 assert enableTools -> enableAudio && enableEmulation && enableLibplayer;
39 let
40   inherit (lib) optional optionals;
41   onOff = val: if val then "ON" else "OFF";
43 stdenv.mkDerivation rec {
44   pname = "libvgm";
45   version = "unstable-2022-08-02";
47   src = fetchFromGitHub {
48     owner = "ValleyBell";
49     repo = "libvgm";
50     rev = "0e349256338144205303a1495ddc788a854be1eb";
51     sha256 = "FNNPiIfBUxkwgEbiFebPGn6ZIxv3ypDefcOzC6r94hE=";
52   };
54   outputs = [
55     "out"
56     "dev"
57   ] ++ optional enableTools "bin";
59   nativeBuildInputs = [
60     cmake
61   ];
63   propagatedBuildInputs = [
64     libiconv
65     zlib
66   ] ++ optionals withALSA [
67     alsa-lib
68   ] ++ optionals withPulseAudio [
69     libpulseaudio
70   ] ++ optionals withCoreAudio [
71     CoreAudio
72     AudioToolbox
73   ] ++ optionals withLibao [
74     libao
75   ];
77   cmakeFlags = [
78     "-DBUILD_LIBAUDIO=${onOff enableAudio}"
79     "-DBUILD_LIBEMU=${onOff enableEmulation}"
80     "-DBUILD_LIBPLAYER=${onOff enableLibplayer}"
81     "-DBUILD_TESTS=${onOff enableTools}"
82     "-DBUILD_PLAYER=${onOff enableTools}"
83     "-DBUILD_VGM2WAV=${onOff enableTools}"
84     "-DLIBRARY_TYPE=${if enableShared then "SHARED" else "STATIC"}"
85     "-DUSE_SANITIZERS=ON"
86   ] ++ optionals enableAudio [
87     "-DAUDIODRV_WAVEWRITE=${onOff withWaveWrite}"
88     "-DAUDIODRV_WINMM=${onOff withWinMM}"
89     "-DAUDIODRV_DSOUND=${onOff withDirectSound}"
90     "-DAUDIODRV_XAUDIO2=${onOff withXAudio2}"
91     "-DAUDIODRV_WASAPI=${onOff withWASAPI}"
92     "-DAUDIODRV_OSS=${onOff withOSS}"
93     "-DAUDIODRV_SADA=${onOff withSADA}"
94     "-DAUDIODRV_ALSA=${onOff withALSA}"
95     "-DAUDIODRV_PULSE=${onOff withPulseAudio}"
96     "-DAUDIODRV_APPLE=${onOff withCoreAudio}"
97     "-DAUDIODRV_LIBAO=${onOff withLibao}"
98   ] ++ optionals enableEmulation ([
99     "-DSNDEMU__ALL=${onOff withAllEmulators}"
100   ] ++ optionals (!withAllEmulators)
101     (lib.lists.forEach emulators (x: "-DSNDEMU_${x}=ON"))
102   ) ++ optionals enableTools [
103     "-DUTIL_CHARCNV_ICONV=ON"
104     "-DUTIL_CHARCNV_WINAPI=${onOff stdenv.hostPlatform.isWindows}"
105   ];
107   passthru.updateScript = unstableGitUpdater {
108     url = "https://github.com/ValleyBell/libvgm.git";
109   };
111   meta = with lib; {
112     homepage = "https://github.com/ValleyBell/libvgm";
113     description = "More modular rewrite of most components from VGMPlay";
114     license =
115       if (enableEmulation && (withAllEmulators || (lib.lists.any (core: core == "WSWAN_ALL") emulators))) then
116         licenses.unfree # https://github.com/ValleyBell/libvgm/issues/43
117       else
118         licenses.gpl2Only;
119     maintainers = with maintainers; [ OPNA2608 ];
120     platforms = platforms.all;
121   };