From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 02 16:51:14 2017 Received: (at submit) by debbugs.gnu.org; 2 Aug 2017 20:51:14 +0000 Received: from localhost ([127.0.0.1]:38966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dd0bm-00013P-RG for submit@debbugs.gnu.org; Wed, 02 Aug 2017 16:51:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42479) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dd0bl-00013D-5O for submit@debbugs.gnu.org; Wed, 02 Aug 2017 16:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dd0bd-0005jC-PT for submit@debbugs.gnu.org; Wed, 02 Aug 2017 16:51:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:39038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dd0bd-0005j2-Ll for submit@debbugs.gnu.org; Wed, 02 Aug 2017 16:51:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dd0bb-0002KZ-Ig for guix-patches@gnu.org; Wed, 02 Aug 2017 16:51:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dd0bY-0005gF-FF for guix-patches@gnu.org; Wed, 02 Aug 2017 16:50:59 -0400 Received: from sender-of-o51.zoho.com ([135.84.80.216]:21111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dd0bY-0005f3-5R for guix-patches@gnu.org; Wed, 02 Aug 2017 16:50:56 -0400 Received: from localhost (port-92-200-8-102.dynamic.qsc.de [92.200.8.102]) by mx.zohomail.com with SMTPS id 1501707050897624.0211121645358; Wed, 2 Aug 2017 13:50:50 -0700 (PDT) From: Ricardo Wurmus To: guix-patches@gnu.org Subject: [PATCH] build: Add minify build system. Date: Wed, 2 Aug 2017 22:50:39 +0200 Message-Id: <20170802205039.6668-1-rekado@elephly.net> X-Mailer: git-send-email 2.13.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-ZohoMail: Z_26063301 SPT_1 Z_26062608 SPT_0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: submit Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/build-system/minify.scm: New file. * guix/build/minify-build-system: New file. * Makefile.am (MODULES): Add new files. * doc/guix.texi (Build Systems): Document minify-build-system. --- Makefile.am | 2 + doc/guix.texi | 15 +++++ guix/build-system/minify.scm | 127 +++++++++++++++++++++++++++++++++++++ guix/build/minify-build-system.scm | 72 +++++++++++++++++++++ 4 files changed, 216 insertions(+) create mode 100644 guix/build-system/minify.scm create mode 100644 guix/build/minify-build-system.scm diff --git a/Makefile.am b/Makefile.am index 0a7e375c2..91a9113d2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,7 @@ MODULES = \ guix/build-system/dub.scm \ guix/build-system/emacs.scm \ guix/build-system/font.scm \ + guix/build-system/minify.scm \ guix/build-system/asdf.scm \ guix/build-system/glib-or-gtk.scm \ guix/build-system/gnu.scm \ @@ -105,6 +106,7 @@ MODULES = \ guix/build/cmake-build-system.scm \ guix/build/dub-build-system.scm \ guix/build/emacs-build-system.scm \ + guix/build/minify-build-system.scm \ guix/build/font-build-system.scm \ guix/build/asdf-build-system.scm \ guix/build/git.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 0ea677387..4d8b7bac5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3575,6 +3575,21 @@ specified with the @code{#:glib} parameter. Both phases are executed after the @code{install} phase. @end defvr +@defvr {Scheme Variable} minify-build-system +This variable is exported by @code{(guix build-system minify)}. It +implements a minification procedure for simple JavaScript packages. + +It adds @code{uglify-js} to the set of inputs and uses it to compress +all JavaScript files in the @file{src} directory. A different minifier +package can be specified with the @code{#:uglify-js} parameter, but it +is expected that the package writes the minified code to the standard +output. + +When the input JavaScript files are not all located in the @file{src} +directory, the parameter @code{#:javascript-files} can be used to +specify a list of file names to feed to the minifier. +@end defvr + @defvr {Scheme Variable} ocaml-build-system This variable is exported by @code{(guix build-system ocaml)}. It implements a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists diff --git a/guix/build-system/minify.scm b/guix/build-system/minify.scm new file mode 100644 index 000000000..9af93333c --- /dev/null +++ b/guix/build-system/minify.scm @@ -0,0 +1,127 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Ricardo Wurmus +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build-system minify) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:use-module (srfi srfi-26) + #:export (%minify-build-system-modules + minify-build + minify-build-system)) + +;; Commentary: +;; +;; Standard minification procedure for JavaScript files. +;; +;; Code: + +(define %minify-build-system-modules + ;; Build-side modules imported by default. + `((guix build minify-build-system) + (ice-9 popen) + ,@%gnu-build-system-modules)) + +(define (default-uglify-js) + "Return the default package to minify JavaScript source files." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((lisp-mod (resolve-interface '(gnu packages lisp)))) + (module-ref lisp-mod 'uglify-js))) + +(define* (lower name + #:key source inputs native-inputs outputs system + (uglify-js (default-uglify-js)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:jdk #:ant #:zip #:inputs #:native-inputs)) + + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + ,@(standard-packages))) + (build-inputs `(("uglify-js" ,uglify-js) + ,@native-inputs)) + (outputs outputs) + (build minify-build) + (arguments (strip-keyword-arguments private-keywords arguments)))) + +(define* (minify-build store name inputs + #:key + (javascript-files #f) + (phases '(@ (guix build minify-build-system) + %standard-phases)) + (outputs '("out")) + (system (%current-system)) + search-paths + (guile #f) + (imported-modules %minify-build-system-modules) + (modules '((guix build minify-build-system) + (guix build utils)))) + "Build SOURCE with INPUTS." + (define builder + `(begin + (use-modules ,@modules) + (minify-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:javascript-files ,javascript-files + #:phases ,phases + #:outputs %outputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:inputs %build-inputs))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system #:graft? #f))))) + + (build-expression->derivation store name builder + #:inputs inputs + #:system system + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define minify-build-system + (build-system + (name 'minify) + (description "The trivial JavaScript minification build system") + (lower lower))) + +;;; minify.scm ends here diff --git a/guix/build/minify-build-system.scm b/guix/build/minify-build-system.scm new file mode 100644 index 000000000..3e20627bd --- /dev/null +++ b/guix/build/minify-build-system.scm @@ -0,0 +1,72 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016 Ricardo Wurmus +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build minify-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module ((guix build minify-build-system) #:prefix minify:) + #:use-module (guix build utils) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (ice-9 popen) + #:export (%standard-phases + minify-build)) + +;; Commentary: +;; +;; Builder-side code of the standard minification procedure for JavaScript +;; files. +;; +;; Code: + +(define* (minify file #:optional (install-directory "")) + (format #t "minifying ~a\n" file) + (let* ((base (basename file ".js")) + (installed (string-append install-directory base ".min.js")) + (minified (open-pipe* OPEN_READ "uglify-js" file))) + (call-with-output-file installed + (cut dump-port minified <>)) + #t)) + +(define* (build #:key javascript-files + #:allow-other-keys) + (let ((files (or javascript-files + (find-files "src" "\\.js$")))) + (mkdir-p "guix/build") + (every (cut minify <> "guix/build/") files))) + +(define* (install #:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (js (string-append out "/share/javascript/"))) + (mkdir-p js) + (for-each (cut install-file <> js) + (find-files "guix/build" "\\.min\\.js$"))) + #t) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'configure) + (replace 'build build) + (delete 'check) + (replace 'install install))) + +(define* (minify-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given JavaScript package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + +;;; minify-build-system.scm ends here -- 2.13.3 From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 03 12:25:03 2017 Received: (at 27924) by debbugs.gnu.org; 3 Aug 2017 16:25:03 +0000 Received: from localhost ([127.0.0.1]:40211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddIvm-0003Fy-DM for submit@debbugs.gnu.org; Thu, 03 Aug 2017 12:25:02 -0400 Received: from sender-of-o51.zoho.com ([135.84.80.216]:21053) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddIvk-0003FV-Rb for 27924@debbugs.gnu.org; Thu, 03 Aug 2017 12:25:01 -0400 Received: from localhost (141.80.245.114 [141.80.245.114]) by mx.zohomail.com with SMTPS id 1501777495994769.2677903460752; Thu, 3 Aug 2017 09:24:55 -0700 (PDT) References: <20170802205039.6668-1-rekado@elephly.net> User-agent: mu4e 0.9.18; emacs 25.2.1 From: Ricardo Wurmus To: 27924@debbugs.gnu.org Subject: [PATCH v2] build: Add minify build system. In-reply-to: <20170802205039.6668-1-rekado@elephly.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Thu, 03 Aug 2017 18:24:46 +0200 Message-ID: <87ini4pqk1.fsf@elephly.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-ZohoMailClient: External X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Ricardo Wurmus writes: > * guix/build-system/minify.scm: New file. > * guix/build/minify-build-system: New file. > * Makefile.am (MODULES): Add new files. > * doc/guix.texi (Build Systems): Document minify-build-system. [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: elephly.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [135.84.80.216 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [135.84.80.216 listed in wl.mailspike.net] 0.1 URIBL_SBL_A Contains URL's A record listed in the SBL blocklist [URIs: makefile.am] 0.6 URIBL_SBL Contains an URL's NS IP listed in the SBL blocklist [URIs: makefile.am] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: 27924 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Ricardo Wurmus writes: > * guix/build-system/minify.scm: New file. > * guix/build/minify-build-system: New file. > * Makefile.am (MODULES): Add new files. > * doc/guix.texi (Build Systems): Document minify-build-system. [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: makefile.am] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [135.84.80.216 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [135.84.80.216 listed in wl.mailspike.net] 0.1 URIBL_SBL_A Contains URL's A record listed in the SBL blocklist [URIs: makefile.am] 0.6 URIBL_SBL Contains an URL's NS IP listed in the SBL blocklist [URIs: makefile.am] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders --=-=-= Content-Type: text/plain Ricardo Wurmus writes: > * guix/build-system/minify.scm: New file. > * guix/build/minify-build-system: New file. > * Makefile.am (MODULES): Add new files. > * doc/guix.texi (Build Systems): Document minify-build-system. Attached is an updated version of the patch. After using the minify-build-system for a couple of packages I think this updated version is much more usable. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-build-Add-minify-build-system.patch Content-Transfer-Encoding: 8bit >From e9edd8d7be46fb11709cb1a4356d68bac693beb3 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Wed, 2 Aug 2017 22:49:30 +0200 Subject: [PATCH] build: Add minify build system. * guix/build-system/minify.scm: New file. * guix/build/minify-build-system: New file. * Makefile.am (MODULES): Add new files. * doc/guix.texi (Build Systems): Document minify-build-system. --- Makefile.am | 2 + doc/guix.texi | 15 +++++ guix/build-system/minify.scm | 127 +++++++++++++++++++++++++++++++++++++ guix/build/minify-build-system.scm | 73 +++++++++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 guix/build-system/minify.scm create mode 100644 guix/build/minify-build-system.scm diff --git a/Makefile.am b/Makefile.am index 0a7e375c2..91a9113d2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,7 @@ MODULES = \ guix/build-system/dub.scm \ guix/build-system/emacs.scm \ guix/build-system/font.scm \ + guix/build-system/minify.scm \ guix/build-system/asdf.scm \ guix/build-system/glib-or-gtk.scm \ guix/build-system/gnu.scm \ @@ -105,6 +106,7 @@ MODULES = \ guix/build/cmake-build-system.scm \ guix/build/dub-build-system.scm \ guix/build/emacs-build-system.scm \ + guix/build/minify-build-system.scm \ guix/build/font-build-system.scm \ guix/build/asdf-build-system.scm \ guix/build/git.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 2bb820b46..88bf0bb62 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3576,6 +3576,21 @@ specified with the @code{#:glib} parameter. Both phases are executed after the @code{install} phase. @end defvr +@defvr {Scheme Variable} minify-build-system +This variable is exported by @code{(guix build-system minify)}. It +implements a minification procedure for simple JavaScript packages. + +It adds @code{uglify-js} to the set of inputs and uses it to compress +all JavaScript files in the @file{src} directory. A different minifier +package can be specified with the @code{#:uglify-js} parameter, but it +is expected that the package writes the minified code to the standard +output. + +When the input JavaScript files are not all located in the @file{src} +directory, the parameter @code{#:javascript-files} can be used to +specify a list of file names to feed to the minifier. +@end defvr + @defvr {Scheme Variable} ocaml-build-system This variable is exported by @code{(guix build-system ocaml)}. It implements a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists diff --git a/guix/build-system/minify.scm b/guix/build-system/minify.scm new file mode 100644 index 000000000..9af93333c --- /dev/null +++ b/guix/build-system/minify.scm @@ -0,0 +1,127 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Ricardo Wurmus +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build-system minify) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:use-module (srfi srfi-26) + #:export (%minify-build-system-modules + minify-build + minify-build-system)) + +;; Commentary: +;; +;; Standard minification procedure for JavaScript files. +;; +;; Code: + +(define %minify-build-system-modules + ;; Build-side modules imported by default. + `((guix build minify-build-system) + (ice-9 popen) + ,@%gnu-build-system-modules)) + +(define (default-uglify-js) + "Return the default package to minify JavaScript source files." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((lisp-mod (resolve-interface '(gnu packages lisp)))) + (module-ref lisp-mod 'uglify-js))) + +(define* (lower name + #:key source inputs native-inputs outputs system + (uglify-js (default-uglify-js)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:jdk #:ant #:zip #:inputs #:native-inputs)) + + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + ,@(standard-packages))) + (build-inputs `(("uglify-js" ,uglify-js) + ,@native-inputs)) + (outputs outputs) + (build minify-build) + (arguments (strip-keyword-arguments private-keywords arguments)))) + +(define* (minify-build store name inputs + #:key + (javascript-files #f) + (phases '(@ (guix build minify-build-system) + %standard-phases)) + (outputs '("out")) + (system (%current-system)) + search-paths + (guile #f) + (imported-modules %minify-build-system-modules) + (modules '((guix build minify-build-system) + (guix build utils)))) + "Build SOURCE with INPUTS." + (define builder + `(begin + (use-modules ,@modules) + (minify-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:javascript-files ,javascript-files + #:phases ,phases + #:outputs %outputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:inputs %build-inputs))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system #:graft? #f))))) + + (build-expression->derivation store name builder + #:inputs inputs + #:system system + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define minify-build-system + (build-system + (name 'minify) + (description "The trivial JavaScript minification build system") + (lower lower))) + +;;; minify.scm ends here diff --git a/guix/build/minify-build-system.scm b/guix/build/minify-build-system.scm new file mode 100644 index 000000000..3580deda0 --- /dev/null +++ b/guix/build/minify-build-system.scm @@ -0,0 +1,73 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016 Ricardo Wurmus +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build minify-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module ((guix build minify-build-system) #:prefix minify:) + #:use-module (guix build utils) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (ice-9 popen) + #:export (%standard-phases + minify-build + minify)) + +;; Commentary: +;; +;; Builder-side code of the standard minification procedure for JavaScript +;; files. +;; +;; Code: + +(define* (minify file #:key target (directory "")) + (format #t "minifying ~a\n" file) + (let* ((base (basename file ".js")) + (installed (or target (string-append directory base ".min.js"))) + (minified (open-pipe* OPEN_READ "uglify-js" file))) + (call-with-output-file installed + (cut dump-port minified <>)) + #t)) + +(define* (build #:key javascript-files + #:allow-other-keys) + (let ((files (or javascript-files + (find-files "src" "\\.js$")))) + (mkdir-p "guix/build") + (every (cut minify <> #:directory "guix/build/") files))) + +(define* (install #:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (js (string-append out "/share/javascript/"))) + (mkdir-p js) + (for-each (cut install-file <> js) + (find-files "guix/build" "\\.min\\.js$"))) + #t) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'configure) + (replace 'build build) + (delete 'check) + (replace 'install install))) + +(define* (minify-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given JavaScript package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + +;;; minify-build-system.scm ends here -- 2.13.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 04 05:27:57 2017 Received: (at 27924-done) by debbugs.gnu.org; 4 Aug 2017 09:27:57 +0000 Received: from localhost ([127.0.0.1]:40874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddYtg-0001Y7-Q3 for submit@debbugs.gnu.org; Fri, 04 Aug 2017 05:27:56 -0400 Received: from sender-of-o51.zoho.com ([135.84.80.216]:21146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddYte-0001Xv-Ir; Fri, 04 Aug 2017 05:27:55 -0400 Received: from localhost (port-92-200-138-46.dynamic.qsc.de [92.200.138.46]) by mx.zohomail.com with SMTPS id 1501838870164607.5771228221234; Fri, 4 Aug 2017 02:27:50 -0700 (PDT) References: <87h8xopq9w.fsf@elephly.net> User-agent: mu4e 0.9.18; emacs 25.2.1 From: Ricardo Wurmus To: 27935-done@debbugs.gnu.org, 27924-done@debbugs.gnu.org Subject: Re: gnu: Add r-shiny. In-reply-to: <87h8xopq9w.fsf@elephly.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Fri, 04 Aug 2017 11:27:39 +0200 Message-ID: <87efsrptro.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 27924-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Ricardo Wurmus writes: > this patch series adds r-shiny and packages for the minified JavaScript > files that it bundles. > > For each of the minified JavaScript files that didn’t have corresponding > sources I tracked down the sources and created our own minified files > with the minify-build-system (see #27924). I have pushed a slightly modified version of the minify-build-system and of this r-shiny patch series. The reason is that my updates to CRAN packages accidentally introduced a dependency on r-crosstalk (in r-plotly), which depends on r-shiny. Rather than reverting the upgrade and potentially breaking dependent packages, I decided to go ahead and get r-shiny and r-crosstalk in. My apologies for the confusion and the breakage! -- Ricardo GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC https://elephly.net From unknown Sun Aug 10 02:40:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 01 Sep 2017 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator