gogins / csound-extended

Extensions for Csound including algorithmic composition, Android app, and WebAssembly.
GNU Lesser General Public License v2.1
40 stars 1 forks source link

Run nudruz in Embeddable Common Lisp #163

Closed gogins closed 3 years ago

gogins commented 3 years ago

Currently nudruz can't run in Embeddable Common Lisp, this is caused by the use in nudruz of the no longer maintained clmath package. I will either provide my own version of this package, or remove this dependency.

gogins commented 3 years ago

While I'm at it, I'll try to improve the installation and configuration of nudruz.

gogins commented 3 years ago
While evaluating the form starting at line 13, column 0
  of #P"/home/mkg/csound-extended/nudruz/examples/tzplay.lisp":

debugger invoked on a SB-INT:SIMPLE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {1000560083}>:
  Couldn't load
  "/home/mkg/.cache/common-lisp/sbcl-2.0.1.debian-linux-x64/home/mkg/cmn/cmn-init.fasl":
  file does not exist.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [TRY-RECOMPILING              ] Recompile cmn-all and try loading it again
  1: [RETRY                        ] Retry
                                     loading FASL for #<CL-SOURCE-FILE "cmn" "cmn-all">.
  2: [ACCEPT                       ] Continue, treating
                                     loading FASL for #<CL-SOURCE-FILE "cmn" "cmn-all">
                                     as having been successful.
  3:                                 Retry ASDF operation.
  4: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
                                     configuration.
  5:                                 Retry ASDF operation.
  6:                                 Retry ASDF operation after resetting the
                                     configuration.
  7: [RETRY                        ] Retry EVAL of current toplevel form.
  8: [CONTINUE                     ] Ignore error and continue loading file "/home/mkg/csound-extended/nudruz/examples/tzplay.lisp".
  9: [ABORT                        ] Abort loading file "/home/mkg/csound-extended/nudruz/examples/tzplay.lisp".
 10:                                 Ignore runtime option --load "tzplay.lisp".
 11:                                 Skip rest of --eval and --load options.
 12:                                 Skip to toplevel READ/EVAL/PRINT loop.
 13: [EXIT                         ] Exit SBCL (calling #'EXIT, killing the process).

(LOAD "/home/mkg/.cache/common-lisp/sbcl-2.0.1.debian-linux-x64/home/mkg/cmn/cmn-init.fasl" :VERBOSE T :PRINT NIL :IF-DOES-NOT-EXIST T :EXTERNAL-FORMAT :DEFAULT)
0] (quit)
; 
; compilation unit aborted
;   caught 1 fatal ERROR condition
;   printed 9 notes
mkg@mkg-G55VW:~/csound-extended/nudruz/examples$ ls /home/mkg/.cache/common-lisp/sbcl-2.0.1.debian-linux-x64/home/mkg/cmn/cmn-all.fasl 
/home/mkg/.cache/common-lisp/sbcl-2.0.1.debian-linux-x64/home/mkg/cmn/cmn-all.fasl
gogins commented 3 years ago

Changed order of dependencies in nudruz.asd, placed (require :fomus) just above (require :nudruz) in all Lisp examples. This enables nudruz to load the first time and load the same way subsequent times. I changed :output to dac which assumes use of PulseAudio, but that will usually be the case, at lease while getting started.

All Lisp examples now play.

gogins commented 3 years ago

I am now getting a new ECL compilation error:

;;; Compiling (DEFUN VIEW-CMN ...).
;;; Error:
;;;   in file backend_cmn.lisp, position 6801
;;;   at (DEFUN VIEW-CMN ...)
;;;   * (CHANGE-FILENAME FILENAME :NAME NIL :EXT NIL) is not a legal function name.ASDF could not load nudruz because
COMPILE-FILE-ERROR while compiling #<cl-source-file "fomus" "backend_cmn">.
An error occurred during initialization:
COMPILE-FILE-ERROR while compiling #<cl-source-file "fomus" "backend_cmn">.
gogins commented 3 years ago

I think at least part of the issue is that :depends in an .asd file only really works if the dependency has an .asd file. CMN does not. I will try to find out of this is really a problem.

gogins commented 3 years ago

I think the problems are caused by the long history of this software, during which the standard way for Common Lisp software to load (which also compiles) dependencies has changed several times.

First we need to understand the terminology. A file that is loaded is a Lisp source code file that is immediately compiled to a matching fasl file. A module is a directory that contains several Lisp source code files. A package is a namespace for symbols that are defined in Lisp files. A system is usually one or more modules that comprise a package, and that the Lisp runtime knows how to load.

ASDF compiles systems into executable form. Usually this involves a package definition (often package.lisp, with a defpackage form)) and a system definition (.asd file, with a defsystem form)).

These days, there is Quicklisp, a package management system that locates systems on the internet, downloads them, uses ASDF to compile them, and loads them.

To use the my-dependency system then I could:

(load "my-dependency.lisp") (require :my-dependency) (asdf:load-system "my-dependency") (ql:quickload "my-dependency")

This gets more complicated because ASDF rewrites require to act like load-system.

In the past users of Lisp systems lacking .asd files wrote startup Lisp files that were hand-coded to load dependencies in the correct order. This is still the case in OpenMusic because it does not assume the existence of ASDF.

That now understood, CMN doesn't have a "package.lisp", it has a "cmn-init.lisp" that contains the defpackage forms. I suspect this is now leading to problems with ASDF.

gogins commented 3 years ago

Indeed, I think that CMN is trying to do too much of the work that ASDF assumes it will do.

gogins commented 3 years ago

Now getting "don't recognize component type PREBUILT-SYSTEM" when loading system .asd files.

This is too poorly documented and too much work, closing for now.