gnu: gst-kaldi-nnet2-online: Fix build.

* gnu/packages/machine-learning.scm (gst-kaldi-nnet2-online): Fix build.
  [arguments]<make-flags>: Improve style.
  <phases>: Migrate to gexps, improve style.
  Add configure CXXFLAGS for OPENFST_VER, fixes build.
  [native-inputs]: Improve style.

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Nicolas Graves 2025-04-24 01:08:11 +02:00 committed by Christopher Baines
parent 7ffc3aec70
commit c51c0f3d73
No known key found for this signature in database
GPG key ID: 5E28A33B0B84F577

View file

@ -3139,27 +3139,33 @@ written in C++.")
(list (list
#:tests? #f ; there are none #:tests? #f ; there are none
#:make-flags #:make-flags
'(list (string-append "SHELL=" (let ((kaldi (this-package-input "kaldi"))
(assoc-ref %build-inputs "bash") "/bin/bash") (bash (this-package-native-input "bash")))
(string-append "KALDI_ROOT=" #~(list (string-append "SHELL=" #$bash "/bin/bash")
(assoc-ref %build-inputs "kaldi-src")) (string-append "KALDI_ROOT=" #$(package-source kaldi))
(string-append "KALDILIBDIR=" (string-append "KALDILIBDIR=" #$kaldi "/lib")
(assoc-ref %build-inputs "kaldi") "/lib") "KALDI_FLAVOR=dynamic"))
"KALDI_FLAVOR=dynamic")
#:phases #:phases
'(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'chdir (add-after 'unpack 'chdir
(lambda _ (chdir "src"))) (lambda _ (chdir "src")))
(replace 'configure (replace 'configure
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let ((glib (assoc-ref inputs "glib"))) (let ((fst-version #$(package-version
(setenv "CXXFLAGS" "-fPIC") (this-package-input "openfst"))))
(setenv "CXXFLAGS"
(string-append
"-fPIC -DOPENFST_VER="
(string-join (string-split fst-version #\.) "0")))
(setenv "CPLUS_INCLUDE_PATH" (setenv "CPLUS_INCLUDE_PATH"
(string-append glib "/include/glib-2.0:" (string-join
glib "/lib/glib-2.0/include:" (append (map (lambda (dir)
(assoc-ref inputs "gstreamer") (search-input-directory inputs dir))
"/include/gstreamer-1.0:" '("/include/glib-2.0"
(getenv "CPLUS_INCLUDE_PATH")))) "/lib/glib-2.0/include"
"/include/gstreamer-1.0"))
(list (getenv "CPLUS_INCLUDE_PATH")))
":")))
(substitute* "Makefile" (substitute* "Makefile"
(("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "") (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "")
(("\\$\\(error Cannot find") "#")))) (("\\$\\(error Cannot find") "#"))))
@ -3167,17 +3173,14 @@ written in C++.")
(lambda* (#:key make-flags #:allow-other-keys) (lambda* (#:key make-flags #:allow-other-keys)
(apply invoke "make" "depend" make-flags))) (apply invoke "make" "depend" make-flags)))
(replace 'install (replace 'install
(lambda* (#:key outputs #:allow-other-keys) (lambda _
(let* ((out (assoc-ref outputs "out")) (install-file
(lib (string-append out "/lib/gstreamer-1.0"))) "libgstkaldinnet2onlinedecoder.so"
(install-file "libgstkaldinnet2onlinedecoder.so" lib))))))) (string-append #$output "/lib/gstreamer-1.0")))))))
(inputs (inputs
(list glib gstreamer jansson openfst kaldi)) (list glib gstreamer jansson openfst kaldi))
(native-inputs (native-inputs
`(("bash" ,bash) (list bash `(,glib "bin") pkg-config))
("glib:bin" ,glib "bin") ; glib-genmarshal
("kaldi-src" ,(package-source kaldi))
("pkg-config" ,pkg-config)))
(home-page "https://kaldi-asr.org/") (home-page "https://kaldi-asr.org/")
(synopsis "Gstreamer plugin for decoding speech") (synopsis "Gstreamer plugin for decoding speech")
(description "This package provides a GStreamer plugin that wraps (description "This package provides a GStreamer plugin that wraps