aboutsummaryrefslogtreecommitdiff
path: root/gn/packages/images.scm
blob: a6e8af45d100ac34a4f7b5ebf3225c56e55151dd (plain)
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
(define-module (gn packages images)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (guix git-download)
  #:use-module (gnu packages build-tools)
  #:use-module (gnu packages check)
  #:use-module (gnu packages chromium)
  #:use-module (gnu packages graph)
  #:use-module (gnu packages pdf)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-science)
  )

(define-public kaleido
  (package
    (inherit ungoogled-chromium)
    (name "kaleido")
    (version "0.2.1")
    (build-system gnu-build-system)
    (arguments
     (substitute-keyword-arguments (package-arguments ungoogled-chromium)
       ((#:modules modules %gnu-build-system-modules)
        `((srfi srfi-1)
          ,@modules))
       ((#:tests? _ #f) #f)             ; TODO: enable after successfully building.
       ((#:configure-flags flags)
        `(append
           ;; First we modify the inherited configure-flags.
           (fold delete ,flags
                 '(
                   "use_pulseaudio=true"
                   "link_pulseaudio=true"
                   "use_vaapi=true"
                   "rtc_use_pipewire=true"
                   "rtc_link_pipewire=true"
                   ))
           (list
             "import(\"//build/args/headless.gn\")"
             "enable_nacl=false"
             "is_component_build=false"
             "symbol_level=0"
             "blink_symbol_level=0"
             "is_debug=false"
             )
           ))
       ((#:phases phases)
        `(modify-phases ,phases
           (add-after 'unpack 'unpack-kaleido-source
             (lambda* (#:key inputs #:allow-other-keys)
               ;(invoke "tar" "xvf" (assoc-ref inputs "kaleido-source")
               ;        "--strip-components=1")
               (copy-recursively (assoc-ref inputs "kaleido-source") ".")
               ))
           (add-before 'configure 'prepare-kaleido-build-environment
             (lambda _
               ;; /repos/linux_scripts/build_kaleido_docker
               (with-output-to-file "repos/kaleido/version"
                 (lambda _
                   (format #t "~a~%" ,version)))
               ;(mkdir-p "out/Kaleido_linux")
               ;(with-output-to-file "out/Kaleido_linux/args.gn"
               ;  (lambda _
               ;    (format #t
               ;            "import(\"//build/args/headless.gn\")~@
               ;            enable_nacl=false~@
               ;            is_component_build=false~@
               ;            ~@
               ;            symbol_level=0~@
               ;            blink_symbol_level=0~@
               ;            is_debug=false~@
               ;            ~@
               ;            target_cpu=\"~a\"~%"
               ;            "x64")))   ; x86_64 -> x64, aarch64 -> arm64, armhf -> arm
               ))
           (replace 'configure
             (lambda* (#:key configure-flags #:allow-other-keys)
               (let ((args (string-join configure-flags " ")))
                 ;; Generate ninja build files.
                 (invoke "gn" "gen" "out/Release"
                         (string-append "--args=" args)
                         )

                 ;; Print the full list of supported arguments as well as
                 ;; their current status for convenience.
                 ;(format #t "Dumping configure flags...\n")
                 ;(invoke "gn" "args" "out/Kaleido_linux" "--list")
                 )))
           (replace 'build
             (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
               (mkdir-p "headless/app")
               (copy-recursively "repos/kaleido/cc" "headles/app")

               (invoke "ninja" "-C" "out/Release"
                       "-j" (if parallel-build?
                                (number->string (parallel-job-count))
                                "1")
                       "kaleido")

               (mkdir-p "repos/build/kaleido_minimal/bin")
               (install-file "out/Release/kaleido" "repos/build/kaleido_minimal/bin")
               (copy-recursively "out/Release/swiftshader/" "repos/build/kaleido_minimal/bin")
               (install-file "repos/kaleido/version" "repos/build/kaleido_minimal/")

               (invoke "python3" "setup.py" "package")
               (invoke "python3" "setup.py" "package_source")
               ))
           (replace 'check
             (lambda* (#:key tests? #:allow-other-keys)
               (when tests?
                 (with-directory-excursion "repos/kaleido/tests"
                   (invoke "pytest" "-s" "test_py/")))))
           ))
        ))
    (native-inputs
     `(
       ("gn" ,gn)
       ("poppler" ,poppler)
       ("python" ,python)
       ("python-pandas" ,python-pandas)
       ("python-plotly" ,python-plotly)
       ("python-pytest" ,python-pytest)
       ("kaleido-source"
        ,(origin
           (method git-fetch)
           (uri (git-reference
                  (url "https://github.com/plotly/Kaleido")
                  (commit (string-append "v" version))))
           (file-name (git-file-name name version))
           (sha256
            (base32 "0p7vddwha4bmb0ihbvjgqwhwa7xmm7xnh2hff5r2xzz64rjcz47x"))))
       ,@(package-native-inputs ungoogled-chromium)))
    (inputs
     `(
       ,@(package-inputs ungoogled-chromium)))
    (home-page "https://github.com/plotly/Kaleido")
    (synopsis "Static image export for web-based visualization libraries")
    (description "Kaleido is a library for generating static images (e.g. png,
svg, pdf, etc.) for web-based visualization libraries, with a particular focus
on eliminating external dependencies.  The project's initial focus is on the
export of @code{plotly.js} images from Python for use by @code{plotly.py}, but
it is designed to be relatively straight-forward to extend to other web-based
visualization libraries, and other programming languages.")
    (license license:expat)))