root/rpcs3.scm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
(define-module (hidamari-blue rpcs3)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system cmake)
  #:use-module ((guix licenses) #:renamer (symbol-prefix-proc 'license:))
  #:use-module (gnu packages)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages base)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages fonts)
  #:use-module (gnu packages image)
  #:use-module (gnu packages games)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages video)
  #:use-module (gnu packages mp3)
  #:use-module (gnu packages xiph)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages xorg)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages serialization)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages perl))

;;; status: - compiles, but linking of unbundled libraries fails
;;;         - most libraries should be unbundled
;;;         - the original repo uses git submodules of projects that don't have proper releases
;;;           or are fixed to old versions (guidelines-support-library).
;;;           Some of the linked versions might be wrong and incompatible with the rpcs3 release.
;;;         - All of the metadata field should be filled out
;;;         - llvm 4 should be packaged since building without llvm is not recommended.

(define-public asmjit
  (let ((commit "673dcefaa048c5f5a2bf8b85daf8f7b9978d018a"))
    (package
     (name "asmjit")
     (version commit)
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/asmjit/asmjit")
                    (commit commit)))
              (sha256 (base32 "1r0xivh7sc5xfyf5zzymik8vpy2ni6zd5yrw2083ddfyp94vdrf1"))))
     (arguments '(;; too lazy to package them
                  #:tests?
                  #f
                  #:configure-flags (list "-DASMJIT_BUILD_TEST=FALSE")))
     (build-system cmake-build-system)
     (description "")
     (synopsis "")
     (home-page "")
     (license license:zlib))))

(define-public guidelines-support-library      ;gsl
  ;; outdated commit required where the header is still named gsl.h
  ;; in the latest version it's just #include <gsl>
  (let ((commit "fc5fce4f4f8d64fbda523d1b0d55115f5ca68774"))
    (package
     ;; Not to be confused with gnu-scientific-library
     ;; this one even is by microsoft
     (name "guidelines-support-library")
     (version commit)
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/Microsoft/GSL")
                    (commit commit)))
              (sha256 (base32 "0c5wh5n1cl16firw5s8rf9mzyzxcpbpq4na48dkiidwffx8c2rba"))))

     (arguments '(#:phases
                  (modify-phases %standard-phases
                                 (delete 'check)
                                 (add-after 'unpack 'remove-tests
                                            (lambda _
                                              ;; needs further local git cloning
                                              ;; unconvinient to package and I'm too lazy rn
                                              (substitute* "CMakeLists.txt"
                                                           (("enable_testing\\(\\)")
                                                            ""))
                                              (substitute* "CMakeLists.txt"
                                                           (("add_subdirectory\\(tests\\)")
                                                            ""))))
                                 (replace 'install
                                          (lambda* (#:key outputs #:allow-other-keys)
                                            (let ((out (assoc-ref outputs "out")))
                                              (mkdir-p (string-append out "/include"))
                                              ;; (mkdir-p (string-append out "/lib"))
                                              (copy-recursively "../source/include"
                                                                (string-append out "/include"))
                                              ;; (copy-recursively "lib"
                                              ;;                   (string-append out "/lib"))
                                              ))))))
     (build-system cmake-build-system)
     (description "")
     (synopsis "")
     (home-page "")
     (license license:expat))))

(define-public hidapi
  (let ((commit "ca39ce8939e490ffcadb38ff978447aac1c17662"))
    (package
     (name "hidapi")
     (version commit)
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/RPCS3/hidapi")
                    (commit commit)))
              (sha256 (base32 "0qr3chakvbxgph1v87m7qvd02lsl541fpymvz9l7m7xiyb0ch9kl"))))
     (arguments '(;; too lazy to package them
                  #:tests?
                  #f
                  #:phases (modify-phases %standard-phases
                                          (add-before 'configure 'bootstrap
                                                      (lambda _
                                                        (zero? (system* "./bootstrap")))))))
     (build-system gnu-build-system)
     (inputs `(("eudev" ,eudev)
               ("libusb" ,libusb)))
     (native-inputs `(("autoconf" ,autoconf)
                      ("automake" ,automake)
                      ("libtool" ,libtool)
                      ("pkg-config" ,pkg-config)))
     (description "")
     (synopsis "")
     (home-page "")
     (license (list license:gpl3+
                    ;; also possible to be used under bsd license
                    ;; probably for compatability with rpcs3 which is gpl2
                    )))))

(define-public optional-cpp
  (let ((commit "f27e79084a9176672ed1eae50b3397fa8035d50d"))
    (package
     (name "optional-cpp")
     (version commit)
     (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/akrzemi1/Optional")
                    (commit commit)))
              (sha256 (base32 "0wf57ns22qmdsxgv4w60pjm1ap42p7l3q20rw61ghdy47l738f8j"))))
     (build-system cmake-build-system)
     (description "")
     (synopsis "")
     (home-page "")
     (license license:zlib))))

(define-public rpcs3
  (package
   (name "rpcs3")
   (version "0.0.4")
   (source
    (origin
     (method url-fetch)
     (uri (string-append "https://github.com/RPCS3/rpcs3/archive/v"
                         version ".tar.gz"))
     (sha256 (base32 "0qqp8fpymyzhdqaji57xh0xxwhp899h2n1a045cggdcxr523dlzs"))))
   (build-system cmake-build-system)
   (arguments
    `(#:tests?
      #f
      #:configure-flags
      (list "-DUSE_SYSTEM_LIBPNG=ON"
            "-DUSE_SYSTEM_FFMPEG=ON"
            "-DWITHOUT_LLVM=ON"         ;TODO package llvm4
            ;; "-DUSE_VULKAN=OFF"
            )
      #:phases
      (modify-phases %standard-phases
                     (add-after 'unpack 'remove-3rd-party
                                (lambda _
                                  ;; don't build bundled hidapi
                                  (substitute* "CMakeLists.txt"
                                               (("include_directories\\(3rdparty/hidapi/hidapi\\)")
                                                ""))
                                  (substitute* "CMakeLists.txt"
                                               (("add_subdirectory\\(3rdparty/hidapi/linux\\)")
                                                ""))

                                  ;; lazy as insert of some define we need
                                  (substitute* "rpcs3/CMakeLists.txt"
                                               (("add_definitions\\(-DGLX_GLXEXT_PROTOTYPES\\)")

                                                "add_definitions(-DGLX_GLXEXT_PROTOTYPES)
add_definitions(-DPUGIXML_SOURCE=1)"))

                                  ;; use system asmjit
                                  (substitute* "rpcs3/CMakeLists.txt"
                                               (("\\$\\{RPCS3_SRC_DIR\\}/\\.\\./asmjit/src/asmjit")
                                                (string-append (assoc-ref %build-inputs "asmjit") "/include/asmjit")))
                                  ;; don't compile bundled asmjit
                                  (substitute* "rpcs3/CMakeLists.txt"
                                               (("\\\"\\$\\{RPCS3_SRC_DIR\\}/\\.\\./asmjit/src/asmjit/\\*\\.cpp\\\"")
                                                ""))
                                  ;; use system optional-cpp
                                  (substitute* "rpcs3/CMakeLists.txt"
                                               (("\\$\\{RPCS3_SRC_DIR\\}/\\.\\./3rdparty/Optional")
                                                (string-append (assoc-ref %build-inputs "optional-cpp") "/include/akrzemi1")))
                                  ;; use system hidapi
                                  (substitute* "rpcs3/CMakeLists.txt"
                                               (("\\$\\{RPCS3_SRC_DIR\\}/\\.\\./3rdparty/hidapi/hidapi")
                                                (string-append (assoc-ref %build-inputs "hidapi") "/include/hidapi")))

                                  ;; lazy ass insert of unbundled libraries link instructions
                                  (substitute* "rpcs3/CMakeLists.txt"
                                               (("target_link_libraries\\(rpcs3 libavformat\\.so libavcodec\\.so libavutil\\.so libswscale\\.so\\)")
                                                "
target_link_libraries(rpcs3 libasmjit.so libyaml-cpp.so libpugixml.a)
target_link_libraries(rpcs3 libavformat.so libavcodec.so libavutil.so libswscale.so)"))

                                  #t)))))
   (inputs `(("asmjit" ,asmjit)
             ("boost" ,boost)
             ("cereal" ,cereal)
             ("eudev" ,eudev)
             ("ffmpeg" ,ffmpeg)
             ("glew" ,glew)
             ("guidelines-support-library" ,guidelines-support-library)
             ("hidapi" ,hidapi)
             ;; ("llvm" ,llvm) ; upgrade to llvm-4
             ("libpng" ,libpng)
             ("libusb" ,libusb)
             ("libvorbis" ,libvorbis)
             ("mesa" ,mesa)
             ("openal" ,openal)
             ("optional-cpp" ,optional-cpp)
             ("pugixml" ,pugixml)
             ("qt" ,qt)
             ("yaml-cpp" ,yaml-cpp)
             ("zlib" ,zlib)))
   (native-inputs `(("pkg-config" ,pkg-config)))
   (synopsis "")
   (description "")
   (home-page "")
   (license license:gpl2+)))