mox692 のブログ

妄想の書き留め場所.

Roswellのinstall方法 on ubuntu

common lispcliツールを作ろうと思い、実行ファイルを吐く機構が欲しくなった.

調べたらRoswellというツールで実行ファイルを作成できるみたいなので、install・使用法のメモ.

install

基本的には公式の通り

$ curl -L https://github.com/roswell/roswell/releases/download/v19.08.10.101/roswell_19.08.10.101-1_amd64.deb --output roswell.deb
$ sudo dpkg -i roswell.deb

これらのコマンドを実行すると、/usr/bin/rosというbinaryがinstallされていると思う

$ find /usr/ -name 'ros*'
/usr/bin/ros

とりあえず、このrosを叩いてみる. するとおもむろにrosのセットアップが始まる (sbclのinstallも行ってるようだ)

$ ros

Installing sbcl-bin...
No SBCL version specified. Downloading platform-table.html to see the available versions...
[#########################                                                 ] 3[##################################################                        ] 6[##########################################################################]100%
Installing sbcl-bin/2.0.4...
Downloading https://github.com/roswell/sbcl_bin/releases/download/2.0.4/sbcl-2.0.4-x86-64-linux-binary.tar.bz2
...

セットアップが完了して、再度 ros を叩いてみて下記のhelpが表示されたら完了

ros
Common Lisp environment setup Utility.

Usage:

   ros [options] Command [arguments...]
or
   ros [options] [[--] script-path arguments...]

commands:
   run       Run repl
   install   Install a given implementation or a system for roswell environment
   update    Update installed systems.
   build     Make executable from script.
   use       Change default implementation.
   init      Creates a new ros script, optionally based on a template.
   fmt       Indent lisp source.
   list      List Information
   template  Manage templates
   delete    Delete installed implementations
   config    Get and set options
   version   Show the roswell version information

Use "ros help [command]" for more information about a command.

Additional help topics:

   options

Use "ros help [topic]" for more information about the topic.

実行ファイルを作成してみる

ros init <file name> ってやると、実行ファイルを作成するのに必要なros fileが生成される.
試しに↓みたいなprogramをbuildしてみる

#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
  (ros:ensure-asdf)
  ;;#+quicklisp(ql:quickload '() :silent t)
  )

(defpackage :ros.script.ros_test.3860230012
  (:use :cl))
(in-package :ros.script.ros_test.3860230012)

(defun foo ()
  (print "hey from foo"))

(defun main (&rest argv)
  (declare (ignorable argv))
  (foo))
;;; vim: set ft=lisp lisp:

build

$ ros build ros_test.ros

$ ./ros_test
"hey from foo"

感想

  • とりあえず実行ファイルは簡単に作れた
  • build は遅い
  • 実行したら明らかに落ちるerrorもbuild時には弾いてくれないことがある

開発中はscriptで書いて、配布時にbuildするって使い方かなー。
あとはmoduleの分け方を調べる。

/* -----codeの行番号----- */