Rake (software)
   HOME

TheInfoList



OR:

Rake is a software
task management Task management is the process of managing a task through its life cycle. It involves planning, testing, tracking, and reporting. Task management can help either individual achieve goals, or groups of individuals collaborate and share knowledg ...
and build automation tool created by
Jim Weirich James Nolan Weirich (November 18, 1956 – February 19, 2014) was a software developer, speaker, teacher, and contributor to the Ruby programming language community. He was active in the Ruby community worldwide, speaking at events in Asia, South ...
. It allows the user to specify tasks and describe dependencies as well as to group tasks in a namespace. It is similar in to
SCons SCons is a computer software build tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the targe ...
and
Make Make or MAKE may refer to: * Make (magazine), a tech DIY periodical *Make (software), a software build tool *Make, Botswana, in the Kalahari Desert *Make Architects Make Architects is an international architecture practice headquartered in Londo ...
. It's written in the
Ruby programming language Ruby is an interpreted, high-level, general-purpose programming language which supports multiple programming paradigms. It was designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including p ...
and the Rakefiles (equivalent of Makefiles in Make) use Ruby syntax. Rake uses Ruby's
anonymous function In computer programming, an anonymous function (function literal, lambda abstraction, lambda function, lambda expression or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to ...
blocks to define various tasks, allowing the use of Ruby syntax. It has a library of common tasks: for example, functions to do common file-manipulation tasks and a library to remove compiled files (the "clean" task). Like Make, Rake can also synthesize tasks based on patterns: for example, automatically building a file compilation task based on filename patterns. Rake is now part of the standard library of Ruby from version 1.9 onward.


Example

Below is an example of a simple Rake script to build a C Hello World program. file 'hello.o' => 'hello.c' do sh 'cc -c -o hello.o hello.c' end file 'hello' => 'hello.o' do sh 'cc -o hello hello.o' end


Rules

When a file is named as a prerequisite but it does not have a file task defined for it, Rake will attempt to synthesize a task by looking at a list of rules supplied in the Rakefile. For example, suppose we were trying to invoke task "mycode.o" with no tasks defined for it. If the Rakefile has a rule that looks like this: rule '.o' => '.c' do , t, sh "cc # -c -o #" end This rule will synthesize any task that ends in ".o". It has as a prerequisite that a source file with an extension of ".c" must exist. If Rake is able to find a file named "mycode.c", it will automatically create a task that builds "mycode.o" from "mycode.c". If the file "mycode.c" does not exist, Rake will attempt to recursively synthesize a rule for it. When a task is synthesized from a rule, the source attribute of the task is set to the matching source file. This allows users to write rules with actions that reference the source file.


Advanced rules

Any regular expression may be used as the rule pattern. Additionally, a proc may be used to calculate the name of the source file. This allows for complex patterns and sources. The following rule is equivalent to the example above: rule(/\.o$/ => ->(t_name)) do , t, sh "cc # -c -o #" end NOTE: Because of a quirk in Ruby syntax, parentheses are required around a rule when the first argument is a regular expression. The following rule might be used for Java files: rule '.class' => ->(t_name) do , t, java_compile(t.source, t.name) end Below is an example of a simple Rake recipe: namespace :cake do desc 'make pancakes' task :pancake => flour,:milk,:egg,:baking_powderdo puts "sizzle" end task :butter do puts "cut 3 tablespoons of butter into tiny squares" end task :flour => :butter do puts "use hands to knead butter squares into 1 1/2 cup flour" end task :milk do puts "add 1 1/4 cup milk" end task :egg do puts "add 1 egg" end task :baking_powder do puts "add 3 1/2 teaspoons baking powder" end end


See also

*
Make Make or MAKE may refer to: * Make (magazine), a tech DIY periodical *Make (software), a software build tool *Make, Botswana, in the Kalahari Desert *Make Architects Make Architects is an international architecture practice headquartered in Londo ...
*
Apache Maven Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation, where it was ...
*
Apache Ant Apache Ant is a software tool for automating software build processes which originated from the Apache Tomcat project in early 2000 as a replacement for the Make build tool of Unix. It is similar to Make, but is implemented using the Java languag ...


External links


Rake documentation
*

by Martin Fowler
Ruby on Rails Rake tutorial
at railsenvy.com
Custom Rake Tasks
at railscasts.com
Rake Tutorial
at lukaszwrobel.pl {{DEFAULTSORT:Rake (Software) Programming tools Build automation Software using the MIT license Ruby (programming language)