trying to build recent rust

LEPILLER JulienWed Nov 22 13:25:46+0100 2017

1016104

trying to build recent rust

more/packages/gnuzilla.scm

2929
  #:use-module (guix utils)
3030
  #:use-module (guix packages)
3131
  #:use-module (guix download)
32+
  #:use-module (guix build-system cargo)
3233
  #:use-module (guix build-system gnu)
3334
  #:use-module (more packages google)
34-
  #:use-module (gnu packages gnuzilla))
35+
  #:use-module (gnu packages assembly)
36+
  #:use-module (gnu packages autotools)
37+
  #:use-module (gnu packages base)
38+
  #:use-module (gnu packages bison)
39+
  #:use-module (gnu packages cmake)
40+
  #:use-module (gnu packages compression)
41+
  #:use-module (gnu packages cups)
42+
  #:use-module (gnu packages curl)
43+
  #:use-module (gnu packages databases)
44+
  #:use-module (gnu packages flex)
45+
  #:use-module (gnu packages fontutils)
46+
  #:use-module (gnu packages gl)
47+
  #:use-module (gnu packages glib)
48+
  #:use-module (gnu packages gnome)
49+
  #:use-module (gnu packages gnuzilla)
50+
  #:use-module (gnu packages gtk)
51+
  #:use-module (gnu packages icu4c)
52+
  #:use-module (gnu packages image)
53+
  #:use-module (gnu packages libcanberra)
54+
  #:use-module (gnu packages libevent)
55+
  #:use-module (gnu packages libffi)
56+
  #:use-module (gnu packages libreoffice)
57+
  #:use-module (gnu packages linux)
58+
  #:use-module (gnu packages perl)
59+
  #:use-module (gnu packages pkg-config)
60+
  #:use-module (gnu packages pulseaudio)
61+
  #:use-module (gnu packages python)
62+
  #:use-module (gnu packages rust)
63+
  #:use-module (gnu packages version-control)
64+
  #:use-module (gnu packages video)
65+
  #:use-module (gnu packages xdisorg)
66+
  #:use-module (gnu packages xorg))
3567
3668
(define-public icecat-skia
3769
  (package

4375
    (arguments (substitute-keyword-arguments (package-arguments icecat)
4476
                 ((#:configure-flags flags)
4577
                  `(cons* "--enable-skia" ,flags))))))
78+
79+
;; FIXME: Needs to be parsed from url not package name.
80+
(define (package-name->crate-name name)
81+
  "Return the crate name of NAME."
82+
  (match (string-split name #\-)
83+
    (("rust" rest ...)
84+
     (string-join rest "-"))
85+
    (_ #f)))
86+
87+
(define* (replace-cargo-toml #:key inputs cargo-toml #:allow-other-keys)
88+
  "Replace Cargo.toml [dependencies] section with guix inputs."
89+
  ;; Make sure Cargo.toml is writeable when the crate uses git-fetch.
90+
  (chmod cargo-toml #o644)
91+
  (substitute* cargo-toml
92+
    ((".*32-sys.*") "
93+
")
94+
    ((".*winapi.*") "
95+
")
96+
    ((".*core-foundation.*") "
97+
"))
98+
  ;; Prepare one new directory with all the required dependencies.
99+
  ;; It's necessary to do this (instead of just using /gnu/store as the
100+
  ;; directory) because we want to hide the libraries in subdirectories
101+
  ;;   share/rust-source/... instead of polluting the user's profile root.
102+
  (mkdir "vendor")
103+
  (for-each
104+
    (match-lambda
105+
      ((name . path)
106+
       (let ((crate (package-name->crate-name name)))
107+
         (when (and crate path)
108+
           (match (string-split (basename path) #\-)
109+
             ((_ ... version)
110+
              (symlink (string-append path "/share/rust-source")
111+
                       (string-append "vendor/" (basename path)))))))))
112+
    inputs)
113+
  ;; Configure cargo to actually use this new directory.
114+
  (mkdir-p ".cargo")
115+
  (let ((port (open-file ".cargo/config" "w" #:encoding "utf-8")))
116+
    (display "
117+
[scrates-io]
118+
re = 'https://github.com/rust-lang/crates.io-index'
119+
rewith = 'vendored-sources'
120+
121+
[svendored-sources]
122+
diy = '" port)
123+
    (display (getcwd) port)
124+
    (display "/vendor" port)
125+
    (display "'
126+
" 
127+
    (close-port port)))
128+
  (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
129+
130+
  ;(setenv "CARGO_HOME" "/gnu/store")
131+
  ; (setenv "CMAKE_C_COMPILER" cc)
132+
  #t)
133+
134+
(define-public rust-for-mozilla
135+
  (package
136+
    (inherit rustc)
137+
    (arguments
138+
     (substitute-keyword-arguments (package-arguments rustc)
139+
       ((#:phases phases)
140+
        `(modify-phases ,phases
141+
           (replace 'check
142+
             (lambda _
143+
               #t))))))))
144+
145+
(define-public cargo-for-mozilla
146+
  (package
147+
    (inherit cargo)
148+
    (arguments
149+
     `(#:rustc ,rust-for-mozilla
150+
       ,@(package-arguments cargo)))))
151+
152+
(define-public rustc-1.17
153+
  (package
154+
    (inherit rust-for-mozilla)
155+
    (version "1.17.0")
156+
    (source (origin
157+
              (method url-fetch)
158+
              (uri (string-append
159+
                    "https://static.rust-lang.org/dist/"
160+
                    "rustc-" version "-src.tar.gz"))
161+
              (sha256
162+
               (base32
163+
                "11sg2y38x2psvc1gvhcd10fcszih2sljhnnfyqnlkwkmbf4s7asb"))
164+
            (modules '((guix build utils)))
165+
            (snippet
166+
             `(begin
167+
                (delete-file-recursively "src/llvm")
168+
                #t))))
169+
    (native-inputs
170+
     `(("bison" ,bison) ; For the tests
171+
       ("cmake" ,cmake)
172+
       ("flex" ,flex) ; For the tests
173+
       ("git" ,git)
174+
       ("procps" ,procps) ; For the tests
175+
       ("python-2" ,python-2)
176+
       ("rustc-bootstrap" ,rust-for-mozilla)
177+
       ("cargo" ,cargo-for-mozilla)
178+
       ("curl" ,curl)
179+
       ("which" ,which)))
180+
    (arguments
181+
     (substitute-keyword-arguments (package-arguments rustc)
182+
       ((#:phases phases)
183+
        `(modify-phases ,phases
184+
           (replace 'configure
185+
             (lambda* (#:key inputs outputs #:allow-other-keys)
186+
               (let* ((out (assoc-ref outputs "out"))
187+
                      (gcc (assoc-ref inputs "gcc"))
188+
                      (binutils (assoc-ref inputs "binutils"))
189+
                      (python (assoc-ref inputs "python-2"))
190+
                      (rustc (assoc-ref inputs "rustc-bootstrap"))
191+
                      (llvm (assoc-ref inputs "llvm"))
192+
                      (jemalloc (assoc-ref inputs "jemalloc"))
193+
                      (flags (list
194+
                              (string-append "--prefix=" out)
195+
                              (string-append "--datadir=" out "/share")
196+
                              (string-append "--infodir=" out "/share/info")
197+
                              (string-append "--default-linker=" gcc "/bin/gcc")
198+
                              (string-append "--default-ar=" binutils "/bin/ar")
199+
                              (string-append "--python=" python "/bin/python2")
200+
                              (string-append "--local-rust-root=" rustc)
201+
                              (string-append "--llvm-root=" llvm)
202+
                              (string-append "--jemalloc-root=" jemalloc "/lib")
203+
                              "--release-channel=stable"
204+
                              "--enable-rpath"
205+
                              "--enable-local-rust"
206+
                              "--disable-manage-submodules")))
207+
                 (substitute* "src/bootstrap/bootstrap.py"
208+
                   (("self.get_toml\\('cargo'\\)") 
209+
                    (string-append "\"" (assoc-ref inputs "cargo") "/bin/cargo\"")))
210+
                 ;; Rust uses a custom configure script (no autoconf).
211+
                 (zero? (apply system* "./configure" flags)))))
212+
           (delete 'patch-configure)))))))
213+
214+
(define-public rustc-1.18
215+
  (package
216+
    (inherit rustc-1.17)
217+
    (version "1.18.0")
218+
    (source (origin
219+
              (method url-fetch)
220+
              (uri (string-append
221+
                    "https://static.rust-lang.org/dist/"
222+
                    "rustc-" version "-src.tar.gz"))
223+
              (sha256
224+
               (base32
225+
                "11sg2y38x2psvc1gvhcd10fcszih2sljhnnfyqnlkwkmbf4s7asb"))
226+
            (modules '((guix build utils)))
227+
            (snippet
228+
             `(begin
229+
                (delete-file-recursively "src/llvm")
230+
                #t))))
231+
    (native-inputs
232+
     `(("bison" ,bison) ; For the tests
233+
       ("cmake" ,cmake)
234+
       ("flex" ,flex) ; For the tests
235+
       ("git" ,git)
236+
       ("procps" ,procps) ; For the tests
237+
       ("python-2" ,python-2)
238+
       ("rustc-bootstrap" ,rustc-1.17)
239+
       ("which" ,which)))))
240+
241+
(define-public rustc-1.19
242+
  (package
243+
    (inherit rustc-1.18)
244+
    (version "1.19.0")
245+
    (source (origin
246+
              (method url-fetch)
247+
              (uri (string-append
248+
                    "https://static.rust-lang.org/dist/"
249+
                    "rustc-" version "-src.tar.gz"))
250+
              (sha256
251+
               (base32
252+
                "11sg2y38x2psvc1gvhcd10fcszih2sljhnnfyqnlkwkmbf4s7asb"))
253+
            (modules '((guix build utils)))
254+
            (snippet
255+
             `(begin
256+
                (delete-file-recursively "src/llvm")
257+
                #t))))
258+
    (native-inputs
259+
     `(("bison" ,bison) ; For the tests
260+
       ("cmake" ,cmake)
261+
       ("flex" ,flex) ; For the tests
262+
       ("git" ,git)
263+
       ("procps" ,procps) ; For the tests
264+
       ("python-2" ,python-2)
265+
       ("rust-bootstrap" ,rustc-1.18)
266+
       ("which" ,which)))))
267+
268+
(define-public rustc-1.20
269+
  (package
270+
    (inherit rustc-1.19)
271+
    (version "1.20.0")
272+
    (source (origin
273+
              (method url-fetch)
274+
              (uri (string-append
275+
                    "https://static.rust-lang.org/dist/"
276+
                    "rustc-" version "-src.tar.gz"))
277+
              (sha256
278+
               (base32
279+
                "11sg2y38x2psvc1gvhcd10fcszih2sljhnnfyqnlkwkmbf4s7asb"))
280+
            (modules '((guix build utils)))
281+
            (snippet
282+
             `(begin
283+
                (delete-file-recursively "src/llvm")
284+
                #t))))
285+
    (native-inputs
286+
     `(("bison" ,bison) ; For the tests
287+
       ("cmake" ,cmake)
288+
       ("flex" ,flex) ; For the tests
289+
       ("git" ,git)
290+
       ("procps" ,procps) ; For the tests
291+
       ("python-2" ,python-2)
292+
       ("rustc-bootstrap" ,rustc-1.19)
293+
       ("which" ,which)))))
294+
295+
(define-public rustc-1.21
296+
  (package
297+
    (inherit rustc-1.20)
298+
    (version "1.21.0")
299+
    (source (origin
300+
              (method url-fetch)
301+
              (uri (string-append
302+
                    "https://static.rust-lang.org/dist/"
303+
                    "rustc-" version "-src.tar.gz"))
304+
              (sha256
305+
               (base32
306+
                "11sg2y38x2psvc1gvhcd10fcszih2sljhnnfyqnlkwkmbf4s7asb"))
307+
            (modules '((guix build utils)))
308+
            (snippet
309+
             `(begin
310+
                (delete-file-recursively "src/llvm")
311+
                #t))))
312+
    (native-inputs
313+
     `(("bison" ,bison) ; For the tests
314+
       ("cmake" ,cmake)
315+
       ("flex" ,flex) ; For the tests
316+
       ("git" ,git)
317+
       ("procps" ,procps) ; For the tests
318+
       ("python-2" ,python-2)
319+
       ("rustc-bootstrap" ,rustc-1.20)
320+
       ("which" ,which)))))
321+
322+
(define-public firefox
323+
  (package
324+
    (name "firefox")
325+
    (version "57.0")
326+
    (source (origin
327+
              (method url-fetch)
328+
              (uri (string-append "https://archive.mozilla.org/pub/firefox/"
329+
                                  "releases/" version "/source/firefox-"
330+
                                  version ".source.tar.xz"))
331+
              (sha256
332+
               (base32
333+
                "13xvxzpp5l3amrd6jcpnn7d1q7wpf80dsiw0qp4z51xyal0z0fk0"))
334+
      (modules '((guix build utils)))
335+
      (snippet
336+
       '(begin
337+
          (use-modules (ice-9 ftw))
338+
          ;; Remove bundled libraries that we don't use, since they may
339+
          ;; contain unpatched security flaws, they waste disk space and
340+
          ;; network bandwidth, and may cause confusion.
341+
          (for-each delete-file-recursively
342+
                    '(;; FIXME: Removing the bundled icu breaks configure.
343+
                      ;;   * The bundled icu headers are used in some places.
344+
                      ;;   * The version number is taken from the bundled copy.
345+
                      ;;"intl/icu"
346+
                      ;;
347+
                      ;; FIXME: A script from the bundled nspr is used.
348+
                      ;;"nsprpub"
349+
                      ;;
350+
                      ;; TODO: Use system media libraries.  Waiting for:
351+
                      ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
352+
                      ;;   * libogg
353+
                      ;;   * libtheora
354+
                      ;;   * libvorbis
355+
                      ;;   * libtremor (not yet in guix)
356+
                      ;;   * libopus
357+
                      ;;   * speex
358+
                      ;;   * soundtouch (not yet in guix)
359+
                      ;;
360+
                      ;; TODO: Use system harfbuzz.  Waiting for:
361+
                      ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=847568>
362+
                      ;;
363+
                      ;; TODO: Use system graphite2.
364+
                      ;;
365+
                      "modules/freetype2"
366+
                      "modules/zlib"
367+
                      "modules/libbz2"
368+
                      "ipc/chromium/src/third_party/libevent"
369+
                      "media/libjpeg"
370+
                      "media/libvpx"
371+
                      "security/nss"
372+
                      "gfx/cairo"
373+
                      "js/src/ctypes/libffi"
374+
                      "db/sqlite3"))
375+
          ;; Delete .pyc files, typically present in icecat source tarballs
376+
          (for-each delete-file (find-files "." "\\.pyc$"))
377+
          ;; Delete obj-* directories, sometimes present in icecat tarballs
378+
          (for-each delete-file-recursively
379+
                    (scandir "." (lambda (name)
380+
                                   (string-prefix? "obj-" name))))
381+
          #t))))
382+
    (build-system gnu-build-system)
383+
    (arguments
384+
     `(#:out-of-source? #t
385+
       #:tests? #f
386+
       #:make-flags (list "--disable-necko-wifi"
387+
                          "--disable-stylo"
388+
                          "--disable-crashreporter"
389+
                          "--disable-updater"
390+
                          "--disable-tests"; Remove if we want to test
391+
                          "--enable-application=browser"
392+
                          "--enable-optimize=-O2"
393+
                          "--with-pthreads"
394+
                          ;; use system libraries
395+
                          "--enable-system-hunspell"
396+
                          "--enable-startup-notification"
397+
                          "--enable-alsa" "--enable-pulseaudio"
398+
                          "--enable-system-sqlite"
399+
                          "--with-system-libevent"
400+
                          "--with-system-libvpx"
401+
                          "--with-system-nspr"
402+
                          "--with-system-nss"
403+
                          "--with-system-icu"
404+
                          "--with-system-graphite2"
405+
                          "--with-system-harfbuzz"
406+
                          "--enable-system-cairo"
407+
                          "--enable-system-ffi"
408+
                          "--enable-system-pixman"
409+
                          "--with-system-bz2"
410+
                          "--with-system-jpeg"
411+
                          "--with-system-png"
412+
                          "--with-system-zlib")
413+
       #:phases
414+
       (modify-phases %standard-phases
415+
         (replace
416+
          'configure
417+
          ;; configure does not work followed by both "SHELL=..." and
418+
          ;; "CONFIG_SHELL=..."; set environment variables instead
419+
          (lambda* (#:key outputs configure-flags #:allow-other-keys)
420+
            (let* ((out (assoc-ref outputs "out"))
421+
                   (bash (which "bash"))
422+
                   (abs-srcdir (getcwd))
423+
                   (srcdir (string-append "../" (basename abs-srcdir)))
424+
                   (flags `(,(string-append "--prefix=" out)
425+
                            ,(string-append "--with-l10n-base="
426+
                                            abs-srcdir "/l10n")
427+
                            ,@configure-flags)))
428+
              (setenv "SHELL" bash)
429+
              (setenv "CONFIG_SHELL" bash)
430+
              (setenv "AUTOCONF" (which "autoconf")) ; must be autoconf-2.13
431+
              (mkdir "../build")
432+
              (chdir "../build")
433+
              (format #t "build directory: ~s~%" (getcwd))
434+
              (format #t "configure flags: ~s~%" flags)
435+
              (zero? (apply system* bash
436+
                            (string-append srcdir "/configure")
437+
                            flags))))))))
438+
    (inputs
439+
     `(("alsa-lib" ,alsa-lib)
440+
       ("bzip2" ,bzip2)
441+
       ("cairo" ,cairo)
442+
       ("cups" ,cups)
443+
       ("dbus-glib" ,dbus-glib)
444+
       ("gdk-pixbuf" ,gdk-pixbuf)
445+
       ("glib" ,glib)
446+
       ("gtk+" ,gtk+)
447+
       ("gtk+-2" ,gtk+-2)
448+
       ("pango" ,pango)
449+
       ("freetype" ,freetype)
450+
       ("hunspell" ,hunspell)
451+
       ("libcanberra" ,libcanberra)
452+
       ("libgnome" ,libgnome)
453+
       ("libjpeg-turbo" ,libjpeg-turbo)
454+
       ("libxft" ,libxft)
455+
       ("libevent" ,libevent-2.0)
456+
       ("libxinerama" ,libxinerama)
457+
       ("libxscrnsaver" ,libxscrnsaver)
458+
       ("libxcomposite" ,libxcomposite)
459+
       ("libxt" ,libxt)
460+
       ("libffi" ,libffi)
461+
       ("ffmpeg" ,ffmpeg)
462+
       ("libvpx" ,libvpx)
463+
       ("icu4c" ,icu4c)
464+
       ("pixman" ,pixman)
465+
       ("pulseaudio" ,pulseaudio)
466+
       ("mesa" ,mesa)
467+
       ("nspr" ,nspr)
468+
       ("nss" ,nss)
469+
       ("sqlite" ,sqlite)
470+
       ("startup-notification" ,startup-notification)
471+
       ("unzip" ,unzip)
472+
       ("zip" ,zip)
473+
       ("zlib" ,zlib)))
474+
    (native-inputs
475+
     `(("perl" ,perl)
476+
       ("python" ,python-2) ; Python 3 not supported
477+
       ("python2-pysqlite" ,python2-pysqlite)
478+
       ("yasm" ,yasm)
479+
       ("pkg-config" ,pkg-config)
480+
       ("autoconf" ,autoconf-2.13)
481+
       ("which" ,which)
482+
       ("rust" ,rustc-1.21)))
483+
    (home-page "https://mozilla.org")
484+
    (synopsis "Web browser")
485+
    (description "")
486+
    (license (package-license icecat))))