Skip to content

Commit

Permalink
Document how to use buildapp for building clingon apps
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Oct 11, 2023
1 parent d064028 commit 6d8658a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
50 changes: 50 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,13 @@ sbcl --eval '(ql:quickload :clingon.intro)' \
This will produce a new binary called =clingon-intro= in the directory
of the =clingon.intro= system.

This approach uses the [[https://asdf.common-lisp.dev/asdf/Predefined-operations-of-ASDF.html][ASDF program-op operation]] in combination with
=:entry-point= and =:build-pathname= in order to produce the resulting
binary.

If you want to build your apps using [[https://www.xach.com/lisp/buildapp/][buildapp]], please check the
/Buildapp/ section from this document.

** Testing it out on the command-line

Time to check things up on the command-line.
Expand Down Expand Up @@ -1679,6 +1686,49 @@ app with Zsh completions support.

[[./images/clingon-zsh-completions.gif]]

* Buildapp

The demo =clingon= apps from this repo are usually built using [[https://asdf.common-lisp.dev/][ASDF]]
with =:build-operation= set to =program-op= and the respective
=:entry-point= and =:build-pathname= specified in the system
definition. See the included =clingon.demo.asd= and
=clingon.intro.asd= systems for examples.

You can also use [[https://www.xach.com/lisp/buildapp/][buildapp]] for building the =clingon= apps.

This command will build the =clingon-demo= CLI app using =buildapp=.

#+begin_src shell
$ buildapp \
--output clingon-demo \
--asdf-tree ~/quicklisp/dists/quicklisp/software/ \
--load-system clingon.demo \
--entry main \
--eval '(defun main (argv) (let ((app (clingon.demo::top-level/command))) (clingon:run app (rest argv))))'
#+end_src

Another approach to building apps using =buildapp= is to create a
=main= entrypoint in your application, similarly to the way you create
one for use with ASDF and =:entry-point=. This function can be used as
an entrypoint for [[https://www.xach.com/lisp/buildapp/][buildapp]] apps.

#+begin_src lisp
(defun main (argv)
"The main entrypoint for buildapp apps"
(let ((app (top-level/command)))
(clingon:run app (rest argv))))
#+end_src

Then build your app with this command.

#+begin_src shell
$ buildapp \
--output my-app-name \
--asdf-tree ~/quicklisp/dists/quicklisp/software/ \
--load-system my-system-name \
--entry my-system-name:main
#+end_src

* Ideas For Future Improvements

** Additional Documentation Generators
Expand Down
5 changes: 5 additions & 0 deletions examples/demo/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@
"The main entrypoint of our demo app"
(let ((app (top-level/command)))
(clingon:run app)))

(defun buildapp-main (argv)
"The main entrypoint for buildapp"
(let ((app (top-level/command)))
(clingon:run app (rest argv))))
3 changes: 2 additions & 1 deletion examples/demo/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
(:use :cl)
(:import-from :clingon)
(:export
:main))
:main
:buildapp-main))
(in-package :clingon.demo)

0 comments on commit 6d8658a

Please sign in to comment.