Clake: a GNU make-like build utility in Common Lisp
2015.8.26 Masayuki Takagi
Lisp Meet Up presented by Shibuya.lisp #31
© 2015 Masayuki Takagi
-2-
About me
●
Masayuki Takagi
●
Common Lisp
●
cl-cuda on Lisp Meet Up #19
●
PIC compiler on Lisp Meet Up #25 and #27
© 2015 Masayuki Takagi
-3-
What's clake?
Clake is a build utility in Common Lisp like:
●
GNU make
●
Ruby's rake
$ cat Makefile
CC = gcc
hello: hello.c
${CC} -o $@ $<
$ make hello
$ cat Rakefile
CC = “gcc”
file “hello” => “hello.c” do
sh “#{CC} -o hello hello.c”
end
$ rake hello
Makefile Rakefile
© 2015 Masayuki Takagi
-4-
Motivation
Web applications on shoulders of UNIX
Redis
UNIX / Linux
MySQL
AWS CLI
docker
etc.
git
Apache
Nginx
© 2015 Masayuki Takagi
-5-
Motivation
GNU make and Ruby's rake
●
Originally build utility
●
Another point of view,
shell command manager
task “compile” do
sh “gcc -o product
product.c”
end
task “test” do
sh “test product”
end
task “profile” do
sh “profile product”
end
task “deploy” do
sh “deploy product”
end
Rakefile
© 2015 Masayuki Takagi
-6-
Motivation
Want to use the power of UNIX,
while keep standing on Common Lisp.
(defparameter cc “gcc”)
(file “hello” (“hello.c”)
(sh #?”${cc} -o hello hello.c”))
© 2015 Masayuki Takagi
-7-
How it started
●
Originally Rudolph Miller's GitHub repository
●
Fork and jack
© 2015 Masayuki Takagi
-8-
Clakefile
●
“Task” and “File Task”
●
File Tasks are executed only when out of date
;; Tasks that build an executable with dependency.
(defparameter cc "gcc")
(file "hello" ("hello.o" "message.o")
(sh #?"${cc} -o hello hello.o message.o"))
(file "hello.o" ("hello.c")
(sh #?"${cc} -c hello.c"))
(file "message.o" ("message.c")
(sh #?"${cc} -c message.c"))
(task "clean" ()
(sh "rm -f hello hello.o message.o"))
© 2015 Masayuki Takagi
-9-
Clakefile
●
Manage a group of tasks using “Namespace”
$ cat Clakefile
(namespace "hello"
(task "foo" (“bar”)
(echo "hello.foo"))
(task "bar" ()
(echo "hello.bar")))
$ clake hello:foo
hello.bar
hello.foo
© 2015 Masayuki Takagi
-10-
Clakefile
●
Clakefile dictionary
TASK task-name dependency-list form*
FILE task-name dependency-list form*
DIRECTORY task-name
NAMESPACE form*
© 2015 Masayuki Takagi
-11-
API
●
[Function] clake
CLAKE &key target pathname verbose
Loads a Clakefile specified with pathname to execute a task of name
target declared in the loaded Clakefile.
●
[Function] sh, echo
SH command &key echo
ECHO string
SH spawns a subprocess that runs the specified command given as a
string. ECHO writes the given string into the standard output
followed by a new line. Both are intended for UNIX terminology
convenience.
© 2015 Masayuki Takagi
-12-
Command Line Interface
●
Provided as a roswell script
●
Lisp / UNIX gap
SYNOPSIS
clake [ -f clakefile ] [ options ] ... [ targets ] ...
OPTIONS
-f FILE
Use FILE as a clakefile.
-h
Print usage.
-v
Verbose mode.
EXAMPLE
$ clake hello:foo hello:bar
© 2015 Masayuki Takagi
-13-
Lisp / UNIX gap
●
Common Lisp does not have the concept of current directory
●
uiop:getcwd, uiop:chdir
;; Where hello and hello.c should be located?
(file “hello” (“hello.c”)
(sh “gcc -o hello hello.c”))
●
*default-pathname-defaults* does not follow CL process' current
directory changed
“An implementation-dependent pathname, typically in the
working directory that was current when Common Lisp was
started up.”
●
How clake function should work? The command line interface would be
its main use case.
© 2015 Masayuki Takagi
-14-
clake-tools
●
A complementary program to provide some useful
goodies
SYNOPSIS
clake-tools COMMAND
COMMANDS
init Create an empty Clakefile with boilerplates
in current directory.
EXAMPLE
$ clake-tools init
$ ls
Clakefile
© 2015 Masayuki Takagi
-15-
GitHub repository
●
https://github.com/takagi/clake
© 2015 Masayuki Takagi
-16-
Closing
●
Beyond the Lisp / UNIX gap
●
Bring the power of Common Lisp to UNIX world

Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp

  • 1.
    Clake: a GNUmake-like build utility in Common Lisp 2015.8.26 Masayuki Takagi Lisp Meet Up presented by Shibuya.lisp #31
  • 2.
    © 2015 MasayukiTakagi -2- About me ● Masayuki Takagi ● Common Lisp ● cl-cuda on Lisp Meet Up #19 ● PIC compiler on Lisp Meet Up #25 and #27
  • 3.
    © 2015 MasayukiTakagi -3- What's clake? Clake is a build utility in Common Lisp like: ● GNU make ● Ruby's rake $ cat Makefile CC = gcc hello: hello.c ${CC} -o $@ $< $ make hello $ cat Rakefile CC = “gcc” file “hello” => “hello.c” do sh “#{CC} -o hello hello.c” end $ rake hello Makefile Rakefile
  • 4.
    © 2015 MasayukiTakagi -4- Motivation Web applications on shoulders of UNIX Redis UNIX / Linux MySQL AWS CLI docker etc. git Apache Nginx
  • 5.
    © 2015 MasayukiTakagi -5- Motivation GNU make and Ruby's rake ● Originally build utility ● Another point of view, shell command manager task “compile” do sh “gcc -o product product.c” end task “test” do sh “test product” end task “profile” do sh “profile product” end task “deploy” do sh “deploy product” end Rakefile
  • 6.
    © 2015 MasayukiTakagi -6- Motivation Want to use the power of UNIX, while keep standing on Common Lisp. (defparameter cc “gcc”) (file “hello” (“hello.c”) (sh #?”${cc} -o hello hello.c”))
  • 7.
    © 2015 MasayukiTakagi -7- How it started ● Originally Rudolph Miller's GitHub repository ● Fork and jack
  • 8.
    © 2015 MasayukiTakagi -8- Clakefile ● “Task” and “File Task” ● File Tasks are executed only when out of date ;; Tasks that build an executable with dependency. (defparameter cc "gcc") (file "hello" ("hello.o" "message.o") (sh #?"${cc} -o hello hello.o message.o")) (file "hello.o" ("hello.c") (sh #?"${cc} -c hello.c")) (file "message.o" ("message.c") (sh #?"${cc} -c message.c")) (task "clean" () (sh "rm -f hello hello.o message.o"))
  • 9.
    © 2015 MasayukiTakagi -9- Clakefile ● Manage a group of tasks using “Namespace” $ cat Clakefile (namespace "hello" (task "foo" (“bar”) (echo "hello.foo")) (task "bar" () (echo "hello.bar"))) $ clake hello:foo hello.bar hello.foo
  • 10.
    © 2015 MasayukiTakagi -10- Clakefile ● Clakefile dictionary TASK task-name dependency-list form* FILE task-name dependency-list form* DIRECTORY task-name NAMESPACE form*
  • 11.
    © 2015 MasayukiTakagi -11- API ● [Function] clake CLAKE &key target pathname verbose Loads a Clakefile specified with pathname to execute a task of name target declared in the loaded Clakefile. ● [Function] sh, echo SH command &key echo ECHO string SH spawns a subprocess that runs the specified command given as a string. ECHO writes the given string into the standard output followed by a new line. Both are intended for UNIX terminology convenience.
  • 12.
    © 2015 MasayukiTakagi -12- Command Line Interface ● Provided as a roswell script ● Lisp / UNIX gap SYNOPSIS clake [ -f clakefile ] [ options ] ... [ targets ] ... OPTIONS -f FILE Use FILE as a clakefile. -h Print usage. -v Verbose mode. EXAMPLE $ clake hello:foo hello:bar
  • 13.
    © 2015 MasayukiTakagi -13- Lisp / UNIX gap ● Common Lisp does not have the concept of current directory ● uiop:getcwd, uiop:chdir ;; Where hello and hello.c should be located? (file “hello” (“hello.c”) (sh “gcc -o hello hello.c”)) ● *default-pathname-defaults* does not follow CL process' current directory changed “An implementation-dependent pathname, typically in the working directory that was current when Common Lisp was started up.” ● How clake function should work? The command line interface would be its main use case.
  • 14.
    © 2015 MasayukiTakagi -14- clake-tools ● A complementary program to provide some useful goodies SYNOPSIS clake-tools COMMAND COMMANDS init Create an empty Clakefile with boilerplates in current directory. EXAMPLE $ clake-tools init $ ls Clakefile
  • 15.
    © 2015 MasayukiTakagi -15- GitHub repository ● https://github.com/takagi/clake
  • 16.
    © 2015 MasayukiTakagi -16- Closing ● Beyond the Lisp / UNIX gap ● Bring the power of Common Lisp to UNIX world