lisp meet up #31, clake: a gnu make-like build utility in common lisp

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

If you can't read please download the document

Upload: masayukitakagi

Post on 26-Jan-2017

7.239 views

Category:

Technology


0 download

TRANSCRIPT

Clake: a GNU make-like build utility in Common Lisp

2015.8.26 Masayuki Takagi

Lisp Meet Up presented by Shibuya.lisp #31

About me

Masayuki Takagi

Common Lisp

cl-cuda on Lisp Meet Up #19

PIC compiler on Lisp Meet Up #25 and #27

What's clake?

Clake is a build utility in Common Lisp like:GNU make

Ruby's rake

$ cat MakefileCC = gcc

hello: hello.c ${CC} -o $@ $ hello.c do sh #{CC} -o hello hello.cend

$ rake helloMakefileRakefile

Motivation

Web applications on shoulders of UNIXRedis

UNIX / Linux

MySQL

AWS CLI

docker

etc.

git

Apache

Nginx

Motivation

GNU make and Ruby's rakeOriginally build utility

Another point of view, shell command manager

task compile do sh gcc -o product product.cend

task test do sh test productend

task profile do sh profile productend

task deploy do sh deploy productend

Rakefile

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))

How it started

Originally Rudolph Miller's GitHub repository

Fork and jack

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"))

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:foohello.barhello.foo

Clakefile

Clakefile dictionary

TASK task-name dependency-list form*FILE task-name dependency-list form*DIRECTORY task-nameNAMESPACE form*

API

[Function] clake

CLAKE &key target pathname verboseLoads a Clakefile specified with pathname to execute a task of name target declared in the loaded Clakefile.[Function] sh, echo

SH command &key echoECHO stringSH 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.

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

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.

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

GitHub repository

https://github.com/takagi/clake

Closing

Beyond the Lisp / UNIX gap

Bring the power of Common Lisp to UNIX world

Title

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. SH command &key echo$ cat ClakefileBla bla bla...The quick brown fox

jumps over

the lazy dog

An implementation-dependent pathname, typically in the working directory that was current when Common Lisp was started up.

2015 Masayuki Takagi

--

2015 Masayuki Takagi

--

2015 Masayuki Takagi

--