Skip to content

Instantly share code, notes, and snippets.

@vic
Created Feb 26, 2009
Embed
What would you like to do?
A sample Mikefile
;; -*- ioke -*-
;;
;; This is a sample Mikefile.
;; Mike is a build system for Ioke, along the lines of ruby's rake.
;; It is still young, awaiting for more specs to be written and
;; having full Java support to call ant tasks, etc.
;; To test Mike, you need the development branch from
;; http://github.com/vic/ioke/tree/mike
;;
;; Then place this Mikefile in the ioke's root directory
;; (at this time mike expects this file to be at the working directory)
;;
;; And try invoking some tasks
;;
;; This one will create vic directory, you can remove it safely.
;; ./bin/mike vic/is/learning/ioke
;;
;; An example of a task taking arguments
;; ./bin/mike whats:up Ioke
;; A task is declared with a simple:
task(:hello, "The Task Documentation", "#{hi} WORLD" println)
;; you can later enhance that task, e.g. adding a prerequisite
;; prerequisites are resolved at execution time..
task(:hello => :hola)
;; or add an action
task(:hello, "Also do this!" println)
;; Of course you can make all of this in a single line..
task(:yay => [:hello, "good:bye"], "Prints yay", "YAY" println)
;; The code on a Mikefile is evaluated on the root namespace (a Mike mimic),
;; that means the cells you assign here arent globals (you could use Ground for that).
;; Instead each namespace is a mimic of its parent namespace, so you have available
;; all methods, mixins from child namespaces.
;; this one is available from this namespace downwards.
who = method("MIKE")
;; we could reference the current namespace by giving no args to namespace
self = method(namespace)
;; The names for namespaces looks like those used in rake.. something:like:this
;; The first argument to the namespace macro can be a name, in that case
;; a child namespace will be created, if a second argument is given, it will
;; be evaluated having the new namespace as receiver and ground.
namespace(:good,
who = "VICO" ;; this one masks the parent namespace who
task(:bye => :hello,
jaja = "ADIOS #{who}"
jaja println)
;; jaja doesn't exist on this namespace, as it is created inside the task block.
)
namespace(:cool,
;; define cool:man:inner task
namespace(:man) task("inner", "CREATING INER DIR" println)
task(:aid => "good:bye", it name println))
;; a directory creates a task for each parent directory
directory("vic/is/learning" => "cool:aid")
namespace(:yeah,
;; we enhance the previously created vic/is task
task("vic/is" => "cool:man:inner",
"created dir #{it name}" println
)
fileCreate("vic/is/learning/ioke" => "vic/is/learning",
FileSystem withOpenFile(it name, fn(file,
file println(it inspect))))
)
;; define the hola task
task(:hola, "Sets the hi cell to be used by hello",
;; Inside a task block, you can access the task instance using
;; the it cell.
it name println
;; The namespace where this task was created is available in the mike cell
it mike hi = "HeLLo!")
namespace(:whats,
task(:up, "A task taking an argument", you,
"What's up #{you}?" println)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment