From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFOMp-0001tG-Gf for guix-patches@gnu.org; Mon, 29 May 2017 13:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFOMm-0006Mf-Jk for guix-patches@gnu.org; Mon, 29 May 2017 13:22:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:40943) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dFOMm-0006MR-Gf for guix-patches@gnu.org; Mon, 29 May 2017 13:22:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dFOMm-0000gB-Ac for guix-patches@gnu.org; Mon, 29 May 2017 13:22:04 -0400 Subject: bug#27132: [PATCH 6/6] gnu: Add uglify-js. Resent-Message-ID: From: Ricardo Wurmus Date: Mon, 29 May 2017 19:21:31 +0200 Message-Id: <20170529172131.20954-6-rekado@elephly.net> In-Reply-To: <20170529172131.20954-1-rekado@elephly.net> References: <20170529172131.20954-1-rekado@elephly.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 27132@debbugs.gnu.org Cc: Ricardo Wurmus * gnu/packages/lisp.scm (uglify-js): New variable. --- gnu/packages/lisp.scm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm index 959d4c534..2980b7004 100644 --- a/gnu/packages/lisp.scm +++ b/gnu/packages/lisp.scm @@ -1341,3 +1341,50 @@ compressor. It works on data produced by @code{parse-js} to generate a @item remove some unreachable code @end itemize\n") (license license:zlib)))) + +(define-public uglify-js + (package + (inherit sbcl-cl-uglify-js) + (name "uglify-js") + (build-system trivial-build-system) + (arguments + `(#:modules ((guix build utils)) + #:builder + (let* ((bin (string-append (assoc-ref %outputs "out") "/bin/")) + (script (string-append bin "uglify-js"))) + (use-modules (guix build utils)) + (mkdir-p bin) + (with-output-to-file script + (lambda _ + (format #t "#!~a/bin/sbcl --script + (require :asdf) + (push (truename \"~a/lib/sbcl\") asdf:*central-registry*)" + (assoc-ref %build-inputs "sbcl") + (assoc-ref %build-inputs "sbcl-cl-uglify-js")) + ;; FIXME: cannot use progn here because otherwise it fails to + ;; find cl-uglify-js. + (for-each + write + '(;; Quiet, please! + (let ((*standard-output* (make-broadcast-stream)) + (*error-output* (make-broadcast-stream))) + (asdf:load-system :cl-uglify-js)) + (let ((file (cadr *posix-argv*))) + (if file + (format t "~a" + (cl-uglify-js:ast-gen-code + (cl-uglify-js:ast-mangle + (cl-uglify-js:ast-squeeze + (with-open-file (in file) + (parse-js:parse-js in)))) + :beautify nil)) + (progn + (format *error-output* + "Please provide a JavaScript file.~%") + (sb-ext:exit :code 1)))))))) + (chmod script #o755) + #t))) + (inputs + `(("sbcl" ,sbcl) + ("sbcl-cl-uglify-js" ,sbcl-cl-uglify-js))) + (synopsis "JavaScript compressor"))) -- 2.12.2