diff options
author | Philip McGrath <philip@philipmcgrath.com> | 2021-12-16 21:02:41 -0500 |
---|---|---|
committer | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2021-12-24 01:37:45 +0100 |
commit | 2d6d881eb3c7fec1ad28c3e639c35777f19b0a6f (patch) | |
tree | d6d4a1c2721d45e8c616a4560cdebd627b98467c /gnu/packages/node.scm | |
parent | ba744faeb104a1132d9f6ed04fc296b23bc09334 (diff) | |
download | guix-2d6d881eb3c7fec1ad28c3e639c35777f19b0a6f.tar.gz |
gnu: node: Avoid duplicating build phases.
* gnu/packages/node.scm (node)[arguments]: Split 'patch-files phase into 'patch-hardcoded-program-references and 'delete-problematic-tests. Adapt 'patch-hardcoded-program-references and 'configure to work unmodified on node-lts, but don't try to share 'delete-problematic-tests, because those details seem to change too much between node versions. (node, node-lts)[inputs]: Use bash-minimal rather than bash. (node-lts)[arguments]: Inherit 'patch-hardcoded-program-references, and 'configure phases from the bootstrap node. Remove the 'patch-files phase, keeping its remaining non-inherited work in a new 'replace-llhttp-sources phase. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Diffstat (limited to 'gnu/packages/node.scm')
-rw-r--r-- | gnu/packages/node.scm | 107 |
1 files changed, 35 insertions, 72 deletions
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm index 6b543acf6f..1635df5b1a 100644 --- a/gnu/packages/node.scm +++ b/gnu/packages/node.scm @@ -10,6 +10,7 @@ ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net> +;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -106,14 +107,22 @@ #:test-target "test-ci-js" #:phases (modify-phases %standard-phases - (add-before 'configure 'patch-files + (add-before 'configure 'patch-hardcoded-program-references (lambda* (#:key inputs #:allow-other-keys) + ;; Fix hardcoded /bin/sh references. - (substitute* '("lib/child_process.js" - "lib/internal/v8_prof_polyfill.js" - "test/parallel/test-child-process-spawnsync-shell.js" - "test/parallel/test-stdio-closed.js" - "test/sequential/test-child-process-emfile.js") + (substitute* + (let ((common + '("lib/child_process.js" + "lib/internal/v8_prof_polyfill.js" + "test/parallel/test-child-process-spawnsync-shell.js" + "test/parallel/test-stdio-closed.js" + "test/sequential/test-child-process-emfile.js")) + ;; not in bootstap node: + (sigxfsz "test/parallel/test-fs-write-sigxfsz.js")) + (if (file-exists? sigxfsz) + (cons sigxfsz common) + common)) (("'/bin/sh'") (string-append "'" (assoc-ref inputs "bash") "/bin/sh'"))) @@ -123,7 +132,10 @@ "test/parallel/test-child-process-exec-env.js") (("'/usr/bin/env'") (string-append "'" (assoc-ref inputs "coreutils") - "/bin/env'"))) + "/bin/env'"))))) + (add-after 'patch-hardcoded-program-references + 'delete-problematic-tests + (lambda* (#:key inputs #:allow-other-keys) ;; FIXME: These tests fail in the build container, but they don't ;; seem to be indicative of real problems in practice. @@ -218,9 +230,16 @@ (setenv "CXX" ,(cxx-for-target)) (setenv "PKG_CONFIG" ,(pkg-config-for-target)) (apply invoke - (search-input-file (or native-inputs inputs) - "/bin/python") - "configure" flags)))) + (let ((inpts (or native-inputs inputs))) + (with-exception-handler + (lambda (e) + (if (search-error? e) + (search-input-file inpts "/bin/python3") + (raise-exception e))) + (lambda () + (search-input-file inpts "/bin/python")))) + "configure" + flags)))) (add-after 'patch-shebangs 'patch-npm-shebang (lambda* (#:key outputs #:allow-other-keys) (let* ((bindir (string-append (assoc-ref outputs "out") @@ -256,7 +275,7 @@ (variable "NODE_PATH") (files '("lib/node_modules"))))) (inputs - (list bash + (list bash-minimal coreutils c-ares http-parser @@ -705,65 +724,8 @@ source files.") libuv "/lib:" zlib "/lib" "'],")))))) - (replace 'configure - ;; Node's configure script is actually a python script, so we can't - ;; run it with bash. - (lambda* (#:key outputs (configure-flags '()) native-inputs inputs - #:allow-other-keys) - (let* ((prefix (assoc-ref outputs "out")) - (xflags ,(if (%current-target-system) - `'("--cross-compiling" - ,(string-append - "--dest-cpu=" - (match (%current-target-system) - ((? (cut string-prefix? "arm" <>)) - "arm") - ((? (cut string-prefix? "aarch64" <>)) - "arm64") - ((? (cut string-prefix? "i686" <>)) - "ia32") - ((? (cut string-prefix? "x86_64" <>)) - "x64") - ((? (cut string-prefix? "powerpc64" <>)) - "ppc64") - (_ "unsupported")))) - ''())) - (flags (cons - (string-append "--prefix=" prefix) - (append xflags configure-flags)))) - (format #t "build directory: ~s~%" (getcwd)) - (format #t "configure flags: ~s~%" flags) - ;; Node's configure script expects the CC environment variable to - ;; be set. - (setenv "CC_host" "gcc") - (setenv "CXX_host" "g++") - (setenv "CC" ,(cc-for-target)) - (setenv "CXX" ,(cxx-for-target)) - (setenv "PKG_CONFIG" ,(pkg-config-for-target)) - (apply invoke - (search-input-file (or native-inputs inputs) - "/bin/python3") - "configure" flags)))) - (replace 'patch-files + (replace 'delete-problematic-tests (lambda* (#:key inputs #:allow-other-keys) - ;; Fix hardcoded /bin/sh references. - (substitute* '("lib/child_process.js" - "lib/internal/v8_prof_polyfill.js" - "test/parallel/test-child-process-spawnsync-shell.js" - "test/parallel/test-fs-write-sigxfsz.js" - "test/parallel/test-stdio-closed.js" - "test/sequential/test-child-process-emfile.js") - (("'/bin/sh'") - (string-append "'" (assoc-ref inputs "bash") "/bin/sh'"))) - - ;; Fix hardcoded /usr/bin/env references. - (substitute* '("test/parallel/test-child-process-default-options.js" - "test/parallel/test-child-process-env.js" - "test/parallel/test-child-process-exec-env.js") - (("'/usr/bin/env'") - (string-append "'" (assoc-ref inputs "coreutils") - "/bin/env'"))) - ;; FIXME: These tests fail in the build container, but they don't ;; seem to be indicative of real problems in practice. (for-each delete-file @@ -802,8 +764,9 @@ source files.") ;; TODO: Regenerate certs instead. (for-each delete-file '("test/parallel/test-tls-passphrase.js" - "test/parallel/test-tls-server-verify.js")) - + "test/parallel/test-tls-server-verify.js")))) + (add-after 'delete-problematic-tests 'replace-llhttp-sources + (lambda* (#:key inputs #:allow-other-keys) ;; Replace pre-generated llhttp sources (let ((llhttp (assoc-ref inputs "llhttp"))) (copy-file (string-append llhttp "/src/llhttp.c") @@ -830,7 +793,7 @@ source files.") python util-linux)) (inputs - (list bash + (list bash-minimal coreutils c-ares-for-node icu4c-67 |