Subject: [PATCH v3 3/4] gnu: onnx: Use G-Expressions.

From: Andy Tai <[email-masked]>
Date: Sun, 10 Sep 2023 13:01:14 -0700

* gnu/packages/machine-learning.scm (onnx)[arguments]: Convert to list of G-Expressions.
---
 gnu/packages/machine-learning.scm | 88 ++++++++++++++++---------------
 1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index c1f5925b11..3c26eb4e64 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1078,50 +1078,52 @@ (define-public onnx
               (snippet '(delete-file-recursively "third_party"))))
     (build-system python-build-system)
     (arguments
-     '(#:phases (modify-phases %standard-phases
-                  (add-before 'build 'pass-cmake-arguments
-                    (lambda* (#:key outputs #:allow-other-keys)
-                      ;; Pass options to the CMake-based build process.
-                      (define out
-                        (assoc-ref outputs "out"))
-
-                      (define args
-                        ;; Copy arguments from 'cmake-build-system', plus ask
-                        ;; for shared libraries.
-                        (list "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
-                              (string-append "-DCMAKE_INSTALL_PREFIX=" out)
-                              "-DCMAKE_INSTALL_LIBDIR=lib"
-                              "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
-                              (string-append "-DCMAKE_INSTALL_RPATH=" out
-                                             "/lib")
-                              "-DCMAKE_VERBOSE_MAKEFILE=ON"
-                              "-DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
-                              "-DONNX_OPT_USE_SYSTEM_PROTOBUF=ON"
+     (list #:phases #~(modify-phases %standard-phases
+                        (add-before 'build 'pass-cmake-arguments
+                          (lambda* (#:key outputs #:allow-other-keys)
+                            ;; Pass options to the CMake-based build process.
+                            (define out
+                              (assoc-ref outputs "out"))
+
+                            (define args
+                              ;; Copy arguments from 'cmake-build-system', plus ask
+                              ;; for shared libraries.
+                              (list "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
+                               (string-append "-DCMAKE_INSTALL_PREFIX=" out)
+                               "-DCMAKE_INSTALL_LIBDIR=lib"
+                               "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
+                               (string-append "-DCMAKE_INSTALL_RPATH=" out
+                                              "/lib")
+                               "-DCMAKE_VERBOSE_MAKEFILE=ON"
+                               "-DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
+                               "-DONNX_OPT_USE_SYSTEM_PROTOBUF=ON"
                                ; force system copy use;
-                              "-DBUILD_SHARED_LIBS=ON"))
-
-                      ;; This environment variable is honored by 'setup.py',
-                      ;; which passes it down to 'cmake'.
-                      (setenv "CMAKE_ARGS" (string-join args))
-
-                      ;; This one is honored by 'setup.py' and passed to 'make
-                      ;; -j'.
-                      (setenv "MAX_JOBS"
-                              (number->string (parallel-job-count)))))
-                  (add-before 'check 'make-test-directory-writable
-                    (lambda _
-                      ;; Make things writable for tests.
-                      (setenv "HOME" (getcwd))
-                      (for-each make-file-writable
-                                (find-files "onnx/examples" "."
-                                            #:directories? #t))))
-                  (add-after 'install 'install-from-cmake
-                    (lambda _
-                      ;; Run "make install" in the build tree 'setup.py'
-                      ;; created for CMake so that libonnx.so,
-                      ;; libonnx_proto.so, etc. are installed.
-                      (invoke "make" "install"
-                              "-C" ".setuptools-cmake-build"))))))
+                               "-DBUILD_SHARED_LIBS=ON"))
+
+                            ;; This environment variable is honored by 'setup.py',
+                            ;; which passes it down to 'cmake'.
+                            (setenv "CMAKE_ARGS"
+                                    (string-join args))
+
+                            ;; This one is honored by 'setup.py' and passed to 'make
+                            ;; -j'.
+                            (setenv "MAX_JOBS"
+                                    (number->string (parallel-job-count)))))
+                        (add-before 'check 'make-test-directory-writable
+                          (lambda _
+                            ;; Make things writable for tests.
+                            (setenv "HOME"
+                                    (getcwd))
+                            (for-each make-file-writable
+                                      (find-files "onnx/examples" "."
+                                                  #:directories? #t))))
+                        (add-after 'install 'install-from-cmake
+                          (lambda _
+                            ;; Run "make install" in the build tree 'setup.py'
+                            ;; created for CMake so that libonnx.so,
+                            ;; libonnx_proto.so, etc. are installed.
+                            (invoke "make" "install" "-C"
+                                    ".setuptools-cmake-build"))))))
     (native-inputs
      (list cmake
            googletest
-- 
2.41.0