Ant (or NAnt) in Lisp

In her article Nature of Lisp , Glory Ahmeset introduces people to lisp with Ant / NAnt as an example. Is there an Ant / NAnt implementation in lisp? Where can you use actual lisp code instead of xml to define things? I had to deal with add-ons for NAnt and would like to get around the xml system in the way Slava is displayed.

+6
lisp ant
source share
4 answers

Ant is a program that interprets commands written in any XML language. You can, as Justinhj said in his answer, use some XML parser (such as the XMLisp mentioned) and convert the XML description into some Lisp data, and then write additional code in Lisp. You also need to override some interpretations of Ant.

Most of the primitive material in Ant is not needed in Lisp. Some file operations are built into Lisp (delete file, rename file, test file, ...). Some of them are missing and need to be implemented - alternative you can use one of the existing libraries. Also note that you can DOWNLOAD Lisp files into Lisp and execute the code - there is also REPL - so it already comes with an interactive interface (unlike Java).

Higher-level build systems in Common Lisp typically implement an abstraction called SYSTEM . There are several of these. ASDF is a popular choice, but there are others. The system has subsystems and files. The system also has several options. Its components also have options. The system has either a structural description of the components, a description of the dependencies, or a peculiar description of the "actions" and their dependencies. Typically, these things are implemented in an object-oriented manner, and you can implement "actions" as functions of Lisp (generic). Lisp also provides features such as COMPILE-FILE, which the Lisp compiler will use to compile the file. If your code has, say, C files - you will need to call the C compiler - usually through some implementation-specific function that allows you to call external programs (here the C compiler).

As mentioned by dmitry-vk, ASDF is a popular choice. LispWorks provides the Common Defsystem . Allegro CL has its own DEFSYSTEM. His DEFSYSTEM manual also describes how to expand it.

All Lisp solutions use some kind of Lisp syntax (not XML syntax), usually implemented by a macro to describe the system. After it is read in Lisp, it turns into a data representation - often with CLOS instances for the system, modules, etc. Then actions are also Lisp functions. Some functions of a higher order go through the graph / tree of components and perform the necessary actions. Some other tools move around the graph / component tree and return a view for the action β€” that is, the proposed plan β€” then the user can let Lisp execute the entire plan or parts of the plan.

On a Lisp machine, a simple system description is as follows:

(sct:defsystem scigraph (:default-pathname "sys:scigraph;" :required-systems "DWIM") (:serial "package" "copy" "dump" "duplicate" "random" "menu-tools" "basic-classes" "draw" "mouse" "color" "basic-graph" "graph-mixins" "axis" "moving-object" "symbol" "graph-data" "legend" "graph-classes" "present" "annotations" "annotated-graph" "contour" "equation" "popup-accept" "popup-accept-methods" "duplicate-methods" "frame" "export" "demo-frame")) 

The SCIGRAPH system is defined above, and all files must be compiled and downloaded in sequential order.

Now I see what the Lisp machine does to update the compiled code:

  Command: Compile System (a system [default Scigraph]) Scigraph (keywords)
                         : Simulate (compiling [default Yes]) Yes

   The plan for constructing Scigraph version Newest for the Compile 
       operation is:
   Compile RJNXP:> software> scigraph> scigraph> popup-accept-methods.lisp.newest
   Load RJNXP:> software> scigraph> scigraph> popup-accept-methods.ibin.newest

It will compile one file and download it - I downloaded the software and changed only this file.

For ASDF, see the documentation listed on the CLIKI page - it is slightly different.

+12
source share

Stuart Halloway's upcoming Clojure Programming book goes through the Lancet design throughout the book as an example application. Lancet is a Clojure build system that (optionally) integrates directly with Ant. Source code and examples are available .

If all you want to do is generate Ant XML files using Lisp code, you can use something like clj-html for Clojure or CL-WHO for Common Lisp. Generating XML from Lisp s-exps is fun and easy.

+4
source share

Perhaps you could define things in lisp and convert them to XML the moment you pass them NAnt.

Something like XMLisp makes it easy to move between two views.

Edit: Actually, xml-emitter will make more sense.

+1
source share

Generic Lisp ASDF (another system definition mechanism) is similar to Make / Ant (but not a complete analogue - it is designed to create Lisp programs, not general systems such as make or ant). It is extensible with Lisp code (subclass systems, components, adding operations to systems). For example, there are asdf-ecs extensions that allow you to include (and compile) C source files in the system.

+1
source share

All Articles