guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#42885] [PATCH 0/4] gnu: calibre: Update to 4.22.0.


From: Ricardo Wurmus
Subject: [bug#42885] [PATCH 0/4] gnu: calibre: Update to 4.22.0.
Date: Thu, 14 Jan 2021 21:49:58 +0100
User-agent: mu4e 1.4.13; emacs 27.1

Arun Isaac <arunisaac@systemreboot.net> writes:

> I got a minimal swc (attached in my previous mail) working. This minimal
> swc works for compiling typescript to javascript. But, I haven't figured
> out how to use it to build web components.

We can also try esbuild.

> This is blocking packaging
> mathjax v3, and thus calibre. I feel that if calibre can go ahead
> without mathjax v3, it should. Then, we can close this issue and open a
> separate one for web components and mathjax.

I’ve been trying to package mathjax v3 for a while, but didn’t get far
enough to present anything yet.  Here’s what I have:

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index 8434836c6f..e6ff5d619d 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -27,6 +27,7 @@
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages lisp-xyz)
+  #:use-module (gnu packages node)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages web)
   #:use-module (guix packages)
@@ -270,6 +271,95 @@ of wicked-good-xpath together with xmldom.")
       (license (list license:expat
                      license:lgpl2.0)))))
 
+(define-public js-mathjax-3
+  (package
+    (name "js-mathjax")
+    (version "3.1.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://github.com/mathjax/MathJax-src";)
+              (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0kqcb6pl0zfs4hf8zqb4l50kkfq7isv35vpy05m0lg0yr9w0w4ai"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match))
+         (set-path-environment-variable
+          "PATH" '("bin") (map (match-lambda
+                                 ((_ . input)
+                                  input))
+                               %build-inputs))
+         (copy-recursively (assoc-ref %build-inputs "source")
+                           "source")
+         (chdir "source")
+
+         ;; TODO: we can't build this because it depends on
+         ;; speech-rule-engine.
+         ;;(delete-file-recursively "ts/a11y")
+         (delete-file-recursively "components/src/a11y")
+         
+         ;;(delete-file-recursively "components/src/sre")
+         ;; This file copies a11y files, which we don't build (see above).
+         (delete-file "components/src/node-main/copy.json")
+
+         (substitute* '("components/bin/build"
+                        "components/bin/pack"
+                        "components/bin/copy"
+                        "components/bin/makeAll")
+           (("/usr/bin/env node")
+            (which "node")))
+
+         ;; Make the compiled files of the context menu available. 
+         (mkdir-p "mj-context-menu/js")
+         (copy-recursively (string-append (assoc-ref %build-inputs 
"js-context-menu")
+                                          "/share/javascript/context-menu")
+                           "mj-context-menu/js")
+
+         (let ((esbuild (string-append (assoc-ref %build-inputs "esbuild")
+                                       "/bin/esbuild"))
+               (node (string-append (assoc-ref %build-inputs "node")
+                                    "/bin/node"))
+               (target (string-append %output "/share/javascript/mathjax")))
+
+           ;; Transpile TypeScript
+           (apply invoke esbuild
+                  "--bundle"
+                  "--tsconfig=tsconfig.json"
+                  "--platform=node"
+                  "--outdir=js"
+                  (find-files "ts" "\\.ts$"))
+
+           (setenv "HOME" "/tmp")
+           (with-directory-excursion "components"
+             ;; This requires network access
+             (substitute* "bin/makeAll"
+               (("processDir\\(fulldir, webpackLib\\);") ""))
+             (invoke node "bin/makeAll" "src"))
+
+           ;; Build components
+           (invoke esbuild
+                   "components/src/tex-chtml-full/tex-chtml-full.js"
+                   "--bundle"
+                   "--minify"
+                   "--platform=node"
+                   (string-append "--outfile=" target "/es5/mml-chtml.js"))))))
+    (native-inputs
+     `(("esbuild" ,esbuild)
+       ("node" ,node-10.22)
+       ("js-context-menu" ,js-context-menu)))
+    (home-page "https://www.mathjax.org/";)
+    (synopsis "TODO")
+    (description "TODO")
+    (license license:asl2.0)))
+
 (define-public js-respond
   (package
     (name "js-respond")

-- 
Ricardo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]