The onion truck strikes again ... Announcing rake

Ok, let me state from the beginning that I never intended to write this
code. I’m not convinced it is useful, and I’m not convinced anyone
would even be interested in it. All I can say is that Why’s onion truck
must by been passing through the Ohio valley.

What am I talking about? … A Ruby version of Make.

See, I can sense you cringing already, and I agree. The world certainly
doesn’t need yet another reworking of the “make” program. I mean, we
already have “ant”. Isn’t that enough?

It started yesterday. I was helping a coworker fix a problem in one of
the Makefiles we use in our project. Not a particularly tough problem,
but during the course of the conversation I began lamenting some of the
shortcomings of make. In particular, in one of my makefiles I wanted to
determine the name of a file dynamically and had to resort to some
simple scripting (in Ruby) to make it work. “Wouldn’t it be nice if you
could just use Ruby inside a Makefile” I said.

My coworker (a recent convert to Ruby) agreed, but wondered what it
would look like. So I sketched the following on the whiteboard…

"What if you could specify the make tasks in Ruby, like this ..."

  task "build" do
    java_compile(...args, etc ...)
  end

"The task function would register "build" as a target to be made,
and the block would be the action executed whenever the build
system determined that it was time to do the build target."

We agreed that would be cool, but writing make from scratch would be WAY
too much work. And that was the end of that!

… Except I couldn’t get the thought out of my head. What exactly
would be needed to make the about syntax work as a make file? Hmmm, you
would need to register the tasks, you need some way of specifying
dependencies between tasks, and some way of kicking off the process.
Hey! What if we did … and fifteen minutes later I had a working
prototype of Ruby make, complete with dependencies and actions.

I showed the code to my coworker and we had a good laugh. It was just
about a page worth of code that reproduced an amazing amount of the
functionality of make. We were both truely stunned with the power of
Ruby.

But it didn’t do everything make did. In particular, it didn’t have
timestamp based file dependencies (where a file is rebuilt if any of its
prerequisite files have a later timestamp). Obviously THAT would be a
pain to add and so Ruby Make would remain an interesting experiment.

… Except as I walked back to my desk, I started thinking about what
file based dependecies would really need. Rats! I was hooked again,
and by adding a new class and two new methods, file/timestamp
dependencies were implemented.

Ok, now I was really hooked. Last night (during CSI!) I massaged the
code and cleaned it up a bit. The result is a bare-bones replacement
for make in exactly 100 lines of code.

For the curious, you can see it at …
o http://w3.one.net/~jweirich/tools/rake/rake.rb (the code)
o http://w3.one.net/~jweirich/tools/rake/Rakefile (example Rakefile)
o ftp://ftp.one.net/pub/users/jweirich/tools/rake/rake-0.1.0.tgz
(the complete package).

(NOTE: The FTP server is flakey. If it says it is busy, keep trying.
I’m looking into a different web/ftp hosting, but in the mean
time, good luck.)

Oh, about the name. When I wrote the example Ruby Make task on my
whiteboard, my coworker exclaimed “Oh! I have the perfect name: Rake …
Get it? Ruby-Make. Rake!” He said he envisioned the tasks as leaves
and Rake would clean them up … or something like that. Anyways, the
name stuck.

Some quick examples …

A simple task to delete backup files …

task :clean do
Dir[’*~’].each {|fn| File.delete(fn) rescue nil }
end

Note that task names are symbols (they are slightly easier to type than
quoted strings … but you may use quoted string if you would rather).
Note also the use of “rescue nil” to trap and ignore errors in the
File.delete command.

To run it, just type “rake clean”. Rake will automatically find a
Rakefile in the current directory (or above!) and will invoke the
targets named on the command line. If there are no targets explicitly
named, rake will invoke the task “default”.

Here’s another task with dependencies …

task :clobber => [:clean] do
sys %{rm -r tempdir}
end

Task :clobber depends upon task :clean, so :clean will be run before
:clobber is executed. “sys” is short for the “system” command (with an
echo to standard out).

Files are specified by using the “file” command. It is similar to the
task command, except that the task name represents a file, and the task
will be run only if the file doesn’t exist, or if its modification time
is earlier than any of its prerequisites.

Here is a file based dependency that will compile “hello.cc” to
"hello.o".

file "hello.cc"
file “hello.o” => [“hello.cc”] do |t|
srcfile = t.name.sub(/.o$/, “.cc”)
sys %{g++ #{srcfile} -c -o #{t.name}}
end

I normally specify file tasks with string (rather than symbols). Some
file names can’t be represented by symbols. Plus it makes the
distinction between them more clear to the casual reader. And yes,
currently the “hello.cc” task with no prerequisites and no actions is
required.

Currently writing a task for each and every file in the project would be
tedious at best. I envision a set of libraries to make this job
easier. For instance, perhaps something like this …

require ‘rake/ctools’
Dir[’*.c’].each do |fn|
c_source_file(fn)
end

where “c_source_file” will create all the tasks need to compile all the
C source files in a directory. Any number of useful libraries could be
created for rake.

That’s it. There’s no documentation (other than whats in this
message). Does this sound interesting to anyone? If so, I’ll continue
to clean it up and write it up and publish it on RAA. Otherwise, I’ll
leave it as an interesting excerise and a tribute to the power of Ruby.

Why /might/ rake be intersting to Ruby programmers. I don’t know,
perhaps …

o No weird make syntax (only weird Ruby syntax :slight_smile:
o No need to edit or read XML (a la ant)
o Platform independent build scripts.
o Will run anywhere Ruby exists, so no need to have “make” installed.
If you stay away from the “sys” command and use things like
’ftools’, you can have a perfectly platform independent
build script. Also rake is only 100 lines of code, so it can
easily be packaged along with the rest of your code.

So … Sorry for the long rambling message. Like I said, I never
intended to write this code at all.

···


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

A couple of comments.

  1. I hate having to type Makefile instead of makefile. make will accept
    either, so any make replacement should allow the initial lower case letter.
    Why anyone uses Makefile instead of makefile I’ve never understood…

  2. Automatic dependency checking (not just timestamps, but automatically
    discovering dependencies like “make depend”) is important.

  3. How about implementing something like the clearcase concept of derived
    objects?

···

On Friday 14 March 2003 08:56 pm, Jim Weirich wrote:

Ok, let me state from the beginning that I never intended to write this
code. I’m not convinced it is useful, and I’m not convinced anyone
would even be interested in it. All I can say is that Why’s onion truck
must by been passing through the Ohio valley.

What am I talking about? … A Ruby version of Make.

See, I can sense you cringing already, and I agree. The world certainly
doesn’t need yet another reworking of the “make” program. I mean, we
already have “ant”. Isn’t that enough?

It started yesterday. I was helping a coworker fix a problem in one of
the Makefiles we use in our project. Not a particularly tough problem,
but during the course of the conversation I began lamenting some of the
shortcomings of make. In particular, in one of my makefiles I wanted to
determine the name of a file dynamically and had to resort to some
simple scripting (in Ruby) to make it work. “Wouldn’t it be nice if you
could just use Ruby inside a Makefile” I said.

My coworker (a recent convert to Ruby) agreed, but wondered what it
would look like. So I sketched the following on the whiteboard…

"What if you could specify the make tasks in Ruby, like this ..."

  task "build" do
    java_compile(...args, etc ...)
  end

"The task function would register "build" as a target to be made,
and the block would be the action executed whenever the build
system determined that it was time to do the build target."

We agreed that would be cool, but writing make from scratch would be WAY
too much work. And that was the end of that!

… Except I couldn’t get the thought out of my head. What exactly
would be needed to make the about syntax work as a make file? Hmmm, you
would need to register the tasks, you need some way of specifying
dependencies between tasks, and some way of kicking off the process.
Hey! What if we did … and fifteen minutes later I had a working
prototype of Ruby make, complete with dependencies and actions.

I showed the code to my coworker and we had a good laugh. It was just
about a page worth of code that reproduced an amazing amount of the
functionality of make. We were both truely stunned with the power of
Ruby.

But it didn’t do everything make did. In particular, it didn’t have
timestamp based file dependencies (where a file is rebuilt if any of its
prerequisite files have a later timestamp). Obviously THAT would be a
pain to add and so Ruby Make would remain an interesting experiment.

… Except as I walked back to my desk, I started thinking about what
file based dependecies would really need. Rats! I was hooked again,
and by adding a new class and two new methods, file/timestamp
dependencies were implemented.

Ok, now I was really hooked. Last night (during CSI!) I massaged the
code and cleaned it up a bit. The result is a bare-bones replacement
for make in exactly 100 lines of code.

For the curious, you can see it at …
o http://w3.one.net/~jweirich/tools/rake/rake.rb (the code)
o http://w3.one.net/~jweirich/tools/rake/Rakefile (example Rakefile)
o ftp://ftp.one.net/pub/users/jweirich/tools/rake/rake-0.1.0.tgz
(the complete package).

(NOTE: The FTP server is flakey. If it says it is busy, keep trying.
I’m looking into a different web/ftp hosting, but in the mean
time, good luck.)

Oh, about the name. When I wrote the example Ruby Make task on my
whiteboard, my coworker exclaimed “Oh! I have the perfect name: Rake …
Get it? Ruby-Make. Rake!” He said he envisioned the tasks as leaves
and Rake would clean them up … or something like that. Anyways, the
name stuck.

Some quick examples …

A simple task to delete backup files …

task :clean do
Dir[‘*~’].each {|fn| File.delete(fn) rescue nil }
end

Note that task names are symbols (they are slightly easier to type than
quoted strings … but you may use quoted string if you would rather).
Note also the use of “rescue nil” to trap and ignore errors in the
File.delete command.

To run it, just type “rake clean”. Rake will automatically find a
Rakefile in the current directory (or above!) and will invoke the
targets named on the command line. If there are no targets explicitly
named, rake will invoke the task “default”.

Here’s another task with dependencies …

task :clobber => [:clean] do
sys %{rm -r tempdir}
end

Task :clobber depends upon task :clean, so :clean will be run before

:clobber is executed. “sys” is short for the “system” command (with an

echo to standard out).

Files are specified by using the “file” command. It is similar to the
task command, except that the task name represents a file, and the task
will be run only if the file doesn’t exist, or if its modification time
is earlier than any of its prerequisites.

Here is a file based dependency that will compile “hello.cc” to
“hello.o”.

file “hello.cc”
file “hello.o” => [“hello.cc”] do |t|
srcfile = t.name.sub(/.o$/, “.cc”)
sys %{g++ #{srcfile} -c -o #{t.name}}
end

I normally specify file tasks with string (rather than symbols). Some
file names can’t be represented by symbols. Plus it makes the
distinction between them more clear to the casual reader. And yes,
currently the “hello.cc” task with no prerequisites and no actions is
required.

Currently writing a task for each and every file in the project would be
tedious at best. I envision a set of libraries to make this job
easier. For instance, perhaps something like this …

require ‘rake/ctools’
Dir[‘*.c’].each do |fn|
c_source_file(fn)
end

where “c_source_file” will create all the tasks need to compile all the
C source files in a directory. Any number of useful libraries could be
created for rake.

That’s it. There’s no documentation (other than whats in this
message). Does this sound interesting to anyone? If so, I’ll continue
to clean it up and write it up and publish it on RAA. Otherwise, I’ll
leave it as an interesting excerise and a tribute to the power of Ruby.

Why /might/ rake be intersting to Ruby programmers. I don’t know,
perhaps …

o No weird make syntax (only weird Ruby syntax :slight_smile:
o No need to edit or read XML (a la ant)
o Platform independent build scripts.
o Will run anywhere Ruby exists, so no need to have “make” installed.
If you stay away from the “sys” command and use things like
‘ftools’, you can have a perfectly platform independent
build script. Also rake is only 100 lines of code, so it can
easily be packaged along with the rest of your code.

So … Sorry for the long rambling message. Like I said, I never
intended to write this code at all.


Seth Kurtzberg
M. I. S. Corp.
480-661-1849
seth@cql.com

So, now we just need to integrate ‘rake’ with TaskMaster (or just plain
DRb), and we have a parallel task control and distribution system. That
could be fun…

Time to grab that code and start playing.

Lennon

How does Rake compare to something like Torrent?
http://raa.ruby-lang.org/list.rhtml?name=torrentworkflow

I’ve spent a small amount of time considering pipelining processes for creating web sites, and Torrent seemed like a good fit.

James

···

-----Original Message-----
From: Jim Weirich [mailto:jim@mail.one.net]On Behalf Of Jim Weirich
Sent: Friday, March 14, 2003 8:57 PM
To: ruby-talk ML
Subject: The onion truck strikes again … Announcing rake

Ok, let me state from the beginning that I never intended to write this
code. I’m not convinced it is useful, and I’m not convinced anyone
would even be interested in it. All I can say is that Why’s onion truck
must by been passing through the Ohio valley.

What am I talking about? … A Ruby version of Make.

See, I can sense you cringing already, and I agree. The world certainly
doesn’t need yet another reworking of the “make” program. I mean, we
already have “ant”. Isn’t that enough?

In article 1047700803.26404.123.camel@traken,

That’s it. There’s no documentation (other than whats in this
message). Does this sound interesting to anyone? If so, I’ll continue
to clean it up and write it up and publish it on RAA. Otherwise, I’ll
leave it as an interesting excerise and a tribute to the power of Ruby.

Please do put it on the RAA. I proposed that somebody do a make in Ruby a
year or so ago… I think this has a lot of potential.

Why /might/ rake be intersting to Ruby programmers. I don’t know,
perhaps …

o No weird make syntax (only weird Ruby syntax :slight_smile:
o No need to edit or read XML (a la ant)
o Platform independent build scripts.
o Will run anywhere Ruby exists, so no need to have “make” installed.
If you stay away from the “sys” command and use things like
‘ftools’, you can have a perfectly platform independent
build script. Also rake is only 100 lines of code, so it can
easily be packaged along with the rest of your code.

o also, if it becomes quite useful, it can be a way for 'sneaking' 

Ruby into places where it isn’t in use now. This is the perfect vehicle
for that.

So … Sorry for the long rambling message. Like I said, I never
intended to write this code at all.

That’s probably how a lot of the best tools get created…

Phil

···

Jim Weirich jweirich@one.net wrote:

o Portability of makefiles themselves.
(I keep getting bitten with the differences between BSD make and GNU make.
Even simple conditionals like .ifdef are different)

o Would be the perfect partner to mkmf if it were rewritten to generate
rakefiles!

Regards,

Brian.

···

On Sat, Mar 15, 2003 at 12:56:35PM +0900, Jim Weirich wrote:

Why /might/ rake be intersting to Ruby programmers. I don’t know,
perhaps …

o No weird make syntax (only weird Ruby syntax :slight_smile:
o No need to edit or read XML (a la ant)
o Platform independent build scripts.
o Will run anywhere Ruby exists, so no need to have “make” installed.
If you stay away from the “sys” command and use things like
‘ftools’, you can have a perfectly platform independent
build script. Also rake is only 100 lines of code, so it can
easily be packaged along with the rest of your code.

What am I talking about? … A Ruby version of Make.

See, I can sense you cringing already, and I agree. The world certainly
doesn’t need yet another reworking of the “make” program. I mean, we
already have “ant”. Isn’t that enough?

It started yesterday. I was helping a coworker fix a problem in one of
the Makefiles we use in our project. Not a particularly tough problem,
but during the course of the conversation I began lamenting some of the
shortcomings of make. In particular, in one of my makefiles I wanted to
determine the name of a file dynamically and had to resort to some
simple scripting (in Ruby) to make it work. “Wouldn’t it be nice if you
could just use Ruby inside a Makefile” I said.

At the risk of sounding blasphemous, how about Python? :slight_smile:

http://www.a-a-p.org/ for more details.

Regards,
Doug

···

On Sat, Mar 15, 2003 at 12:56:35PM +0900, Jim Weirich wrote:

“Jim Weirich” jweirich@one.net wrote in message
news:1047700803.26404.123.camel@traken…

Ok, let me state from the beginning that I never intended to write this
code. I’m not convinced it is useful, and I’m not convinced anyone
would even be interested in it. All I can say is that Why’s onion truck
must by been passing through the Ohio valley.

What am I talking about? … A Ruby version of Make.

For inspiration, please also look at the AAP tool I posted a link to
yesterday. It’s inspired by SCons.
Both SCons and AAP are using plugable dependecy scanners and signatures.
Signatures are much better than the timestamp approach.
AAP were almost choosing Ruby for scripting but got conservative and chose
python. AAP also deals with distribution (like rpgk), but it is a make tool.
I’d love a make tool in Ruby, and I was part of discussion on the topic
about a year ago. I also hacked a bit on a Ruby make tool, but dropped in in
favor of SCons.

Today I’m a bit torn - I’d prefer a tool in Ruby, but I’d also like a tool
that is useful for many languages and tasks - it doesn’t make sense for each
language to have its own tool. Perhaps it is time to support an approach
like AAP although it is scripted in Python.

On the other hand, Ruby could provide yet another build alternative and
prove to be the better choice.

In any case Rake is propably genuinely useful in its own right as it would
make common scripting tasks in Ruby easier.

Mikkel

I’ll put yet another thing in the discussion: what about jam ?
It seem there are quite a few projects using it instead of make, maybe
you could get some inspiration

···

il Sat, 15 Mar 2003 12:56:35 +0900, Jim Weirich jweirich@one.net ha scritto::

What am I talking about? … A Ruby version of Make.

Jim Weirich jweirich@one.net wrote in message news:1047700803.26404.123.camel@traken

Ok, let me state from the beginning that I never intended to write this
code. I’m not convinced it is useful, and I’m not convinced anyone
would even be interested in it. All I can say is that Why’s onion truck
must by been passing through the Ohio valley.

What am I talking about? … A Ruby version of Make.

See, I can sense you cringing already, and I agree. The world certainly
doesn’t need yet another reworking of the “make” program. I mean, we
already have “ant”. Isn’t that enough?

It started yesterday. I was helping a coworker fix a problem in one of
the Makefiles we use in our project. Not a particularly tough problem,
but during the course of the conversation I began lamenting some of the
shortcomings of make. In particular, in one of my makefiles I wanted to
determine the name of a file dynamically and had to resort to some
simple scripting (in Ruby) to make it work. “Wouldn’t it be nice if you
could just use Ruby inside a Makefile” I said.

My coworker (a recent convert to Ruby) agreed, but wondered what it
would look like. So I sketched the following on the whiteboard…

"What if you could specify the make tasks in Ruby, like this ..."

  task "build" do
    java_compile(...args, etc ...)
  end

"The task function would register "build" as a target to be made,
and the block would be the action executed whenever the build
system determined that it was time to do the build target."

We agreed that would be cool, but writing make from scratch would be WAY
too much work. And that was the end of that!

… Except I couldn’t get the thought out of my head. What exactly
would be needed to make the about syntax work as a make file? Hmmm, you
would need to register the tasks, you need some way of specifying
dependencies between tasks, and some way of kicking off the process.
Hey! What if we did … and fifteen minutes later I had a working
prototype of Ruby make, complete with dependencies and actions.

I showed the code to my coworker and we had a good laugh. It was just
about a page worth of code that reproduced an amazing amount of the
functionality of make. We were both truely stunned with the power of
Ruby.

But it didn’t do everything make did. In particular, it didn’t have
timestamp based file dependencies (where a file is rebuilt if any of its
prerequisite files have a later timestamp). Obviously THAT would be a
pain to add and so Ruby Make would remain an interesting experiment.

… Except as I walked back to my desk, I started thinking about what
file based dependecies would really need. Rats! I was hooked again,
and by adding a new class and two new methods, file/timestamp
dependencies were implemented.

Ok, now I was really hooked. Last night (during CSI!) I massaged the
code and cleaned it up a bit. The result is a bare-bones replacement
for make in exactly 100 lines of code.

For the curious, you can see it at …
o http://w3.one.net/~jweirich/tools/rake/rake.rb (the code)
o http://w3.one.net/~jweirich/tools/rake/Rakefile (example Rakefile)
o ftp://ftp.one.net/pub/users/jweirich/tools/rake/rake-0.1.0.tgz
(the complete package).

(NOTE: The FTP server is flakey. If it says it is busy, keep trying.
I’m looking into a different web/ftp hosting, but in the mean
time, good luck.)

Oh, about the name. When I wrote the example Ruby Make task on my
whiteboard, my coworker exclaimed “Oh! I have the perfect name: Rake …
Get it? Ruby-Make. Rake!” He said he envisioned the tasks as leaves
and Rake would clean them up … or something like that. Anyways, the
name stuck.

Some quick examples …

A simple task to delete backup files …

task :clean do
Dir[‘*~’].each {|fn| File.delete(fn) rescue nil }
end

Note that task names are symbols (they are slightly easier to type than
quoted strings … but you may use quoted string if you would rather).
Note also the use of “rescue nil” to trap and ignore errors in the
File.delete command.

To run it, just type “rake clean”. Rake will automatically find a
Rakefile in the current directory (or above!) and will invoke the
targets named on the command line. If there are no targets explicitly
named, rake will invoke the task “default”.

Here’s another task with dependencies …

task :clobber => [:clean] do
sys %{rm -r tempdir}
end

Task :clobber depends upon task :clean, so :clean will be run before
:clobber is executed. “sys” is short for the “system” command (with an
echo to standard out).

Files are specified by using the “file” command. It is similar to the
task command, except that the task name represents a file, and the task
will be run only if the file doesn’t exist, or if its modification time
is earlier than any of its prerequisites.

Here is a file based dependency that will compile “hello.cc” to
“hello.o”.

file “hello.cc”
file “hello.o” => [“hello.cc”] do |t|
srcfile = t.name.sub(/.o$/, “.cc”)
sys %{g++ #{srcfile} -c -o #{t.name}}
end

I normally specify file tasks with string (rather than symbols). Some
file names can’t be represented by symbols. Plus it makes the
distinction between them more clear to the casual reader. And yes,
currently the “hello.cc” task with no prerequisites and no actions is
required.

Currently writing a task for each and every file in the project would be
tedious at best. I envision a set of libraries to make this job
easier. For instance, perhaps something like this …

require ‘rake/ctools’
Dir[‘*.c’].each do |fn|
c_source_file(fn)
end

where “c_source_file” will create all the tasks need to compile all the
C source files in a directory. Any number of useful libraries could be
created for rake.

That’s it. There’s no documentation (other than whats in this
message). Does this sound interesting to anyone? If so, I’ll continue
to clean it up and write it up and publish it on RAA. Otherwise, I’ll
leave it as an interesting excerise and a tribute to the power of Ruby.

Why /might/ rake be intersting to Ruby programmers. I don’t know,
perhaps …

o No weird make syntax (only weird Ruby syntax :slight_smile:
o No need to edit or read XML (a la ant)
o Platform independent build scripts.
o Will run anywhere Ruby exists, so no need to have “make” installed.
If you stay away from the “sys” command and use things like
‘ftools’, you can have a perfectly platform independent
build script. Also rake is only 100 lines of code, so it can
easily be packaged along with the rest of your code.

So … Sorry for the long rambling message. Like I said, I never
intended to write this code at all.

Just an FYI, there’s a Perl version at
http://www.perl.com/language/ppt/src/make/index.html. Might be a good
baseline.

Regards,

Dan

Hi,

Here is a file based dependency that will compile “hello.cc” to
“hello.o”.

file “hello.cc”

This line looks verbose for me.

require ‘rake/ctools’
Dir[‘*.c’].each do |fn|
c_source_file(fn)
end

Why not pattern rule?

require ‘rbconfig.rb’
include Config

CC = CONFIG[‘CC’]
COMPILE_C = “#{CC} #{CONFIG[‘COMPILE_C_FLAG’]}”
OBJEXT = CONFIG[‘OBJEXT’]

srcs = Dir[“*.c”]
objs = srcs.map{|f|f.sub(/.c$/, “.#{OBJEXT}”)}
target = “foo”

rule /.#{OBJEXT}$/, ‘.c’ do |f|
src = f.prerequisites.first
sys(“#{COMPILE_C} #{src}”)
end

file target => objs do |f|
sys(“#{CC} -o #{f.name} #{f.prerequisites.join(’ ')}”)
end

task :default => target

— bin/rake.rb-0.1.0 Sat Mar 15 11:01:00 2003
+++ bin/rake.rb Mon Mar 17 05:31:31 2003
@@ -4,6 +4,7 @@

class Task
TASKS = Hash.new

  • RULES = Array.new

    attr_reader :prerequisites

@@ -42,7 +43,15 @@

class << self
def

  •  TASKS[intern(task_name)] or fail "Don't know how to rake #{task_name}"
    
  •  task = TASKS[intern(task_name)] and return task
    
  •  task_name = task_name.to_s
    
  •  RULES.each do |pat, deps, block|
    
  •    pat.match(task_name) or next
    
  •    deps = deps.collect {|dep| task_name.sub(pat, dep)}
    
  •    return FileTask.new(task_name).enhance(deps, &block)
    
  •  end
    
  •  task = File.exist?(task_name) and return FileTask.new(task_name)
    
  •  raise "Don't know how to rake #{task_name}"
    

    end

    def define_task(args, &block)
    @@ -66,7 +75,12 @@
    end

    def intern(task_name)

  •  (Symbol === task_name) ? task_name : task_name.intern
    
  •  task_name.to_s
    
  • end
···

At Sat, 15 Mar 2003 12:56:35 +0900, Jim Weirich wrote:
+

  • def define_rule(pat, prereq)
  •  String === pat and pat = /#{Regexp.quote(pat)}$/
    
  •  RULES << [pat, prereq, Proc.new]
    
    end
    end
    end
    @@ -92,12 +106,16 @@
    FileTask.define_task(args, &block)
    end

+def rule(pat, args, &block)

  • Task.define_rule(pat, args, &block)
    +end

def sys(cmd)
puts cmd
system(cmd) or fail “Command Failed: [#{cmd}]”
end

-def rake
+def rake(*targets)
begin
here = Dir.pwd
while ! File.exist?(“Rakefile”)
@@ -107,8 +125,8 @@
end
puts “(in #{Dir.pwd})”
load “./Rakefile”

  • ARGV.push(“default”) if ARGV.size == 0
  • ARGV.each { |task_name| Task[task_name].invoke }
  • targets = [“default”] if targets.empty?
  • targets.each { |task_name| Task[task_name].invoke }
    rescue Exception => ex
    puts “rake aborted!”
    puts ex.message
    @@ -117,5 +135,5 @@
    end

if FILE == $0 then

  • rake
  • rake(*ARGV)
    end

I always thought the convention was that a Makefile was generated, but a
makefile was hand written.

···

On Sat, Mar 15, 2003 at 01:06:51PM +0900, Seth Kurtzberg wrote:

A couple of comments.

  1. I hate having to type Makefile instead of makefile. make will accept
    either, so any make replacement should allow the initial lower case letter.
    Why anyone uses Makefile instead of makefile I’ve never understood…


Alan Chen
Digikata Computing
http://digikata.com

The convention is that ‘Makefile’ is generated and ‘makefile’ is hand
written. ‘Makefile’ take precedence over ‘makefile’, so if you generate
‘Makefile’ from ‘makefile’ and run make again, everything works as
expected.

Actually, we base our build system on imake (quite different from X
environment, though) and gnumake, so in ‘makefile’ the code is invoked
to generate ‘Makefile’ from ‘Imakefile’ (via include directive and a
build rule Imakefile → Makefile). However recently I started thinking
about replacing imake with ruby. I like Jim’s syntax, however it seems
to me that better way would be to marry rake and gnumake, where ruby is
used to generate Makefile from Rakefile. I’ll give it a shot next week.

Gennady.

···

On Friday, March 14, 2003, at 08:06 PM, Seth Kurtzberg wrote:

A couple of comments.

  1. I hate having to type Makefile instead of makefile. make will
    accept
    either, so any make replacement should allow the initial lower case
    letter.
    Why anyone uses Makefile instead of makefile I’ve never understood…

In article 3E72ACA6.5040807@day-reynolds.com,

···

Lennon Day-Reynolds lennon@day-reynolds.com wrote:

So, now we just need to integrate ‘rake’ with TaskMaster (or just plain
DRb), and we have a parallel task control and distribution system. That
could be fun…

Time to grab that code and start playing.

Lennon

That sort of tool could become immediately popular on Linux clusters.

Phil

Seth Kurtzberg seth@cql.com writes:

Why anyone uses Makefile instead of makefile I’ve never understood…

So ls puts it out of the way in the upper left corner, rather than sticking
it in the middle of what you were actually interested in.

···


Steve Coltrin spcoltri@omcl.org WWVBF?
Rho! Etra shivat elor ko’obay k’shia, vata elor ko’obay shiebran. Enshia,
ensitra.

A couple of comments.

  1. I hate having to type Makefile instead of makefile. make will accept
    either, so any make replacement should allow the initial lower case letter.
    Why anyone uses Makefile instead of makefile I’ve never understood…

Easy to do. Ok.

  1. Automatic dependency checking (not just timestamps, but automatically
    discovering dependencies like “make depend”) is important.

I see this functionality as an add-in library. I already have a stand
alone program (called jdepend.rb) which determines the dependencies in a
Java project. I can see reworking the jdepend code so that it can be
used as a library and then in your Rakefile have …

require 'jdepend'
JDepend.generate_java_dependencies

or something like that. Since a Rakefile is really Ruby code, its
trivial to extend it in ways that are difficult in a Makefile.

  1. How about implementing something like the clearcase concept of derived
    objects?

Enlighten me. Is that like knowing that X.class is derived from X.java?

···

On Fri, 2003-03-14 at 23:06, Seth Kurtzberg wrote:


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

Now, of course, all we need is a good rAnt …

-austin, running and ducking
– Austin Ziegler, austin@halostatue.ca on 2003.03.15 at 21:49:35

I won’t use AAP if I have to use Python in any way. IMO, from the
porting and other work that I’ve had to do with Python, I won’t
touch the language for any reason except to get good code out of
it.

-austin, would rather program in Perl or Malbolge than Python
– Austin Ziegler, austin@halostatue.ca on 2003.03.15 at 21:51:26

···

On Sat, 15 Mar 2003 21:45:00 +0900, MikkelFJ wrote:

Today I’m a bit torn - I’d prefer a tool in Ruby, but I’d also
like a tool that is useful for many languages and tasks - it
doesn’t make sense for each language to have its own tool. Perhaps
it is time to support an approach like AAP although it is scripted
in Python.

Yes. This is exactly the kind of thing I had in mind. Thanks for the
diffs.

···

On Sun, 2003-03-16 at 21:48, nobu.nokada@softhome.net wrote:

Hi,

At Sat, 15 Mar 2003 12:56:35 +0900, > Jim Weirich wrote:

Here is a file based dependency that will compile “hello.cc” to
“hello.o”.

file “hello.cc”

This line looks verbose for me.

require ‘rake/ctools’
Dir[‘*.c’].each do |fn|
c_source_file(fn)
end

Why not pattern rule?


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

Perhaps, but then why do we have Makefile.in, Makefile.whatever, etc., etc.?
However I concede that it is likely that nobody in the entire world cares
about this other than me. :slight_smile:

···

On Friday 14 March 2003 10:54 pm, Alan Chen wrote:

I always thought the convention was that a Makefile was generated, but a
makefile was hand written.

On Sat, Mar 15, 2003 at 01:06:51PM +0900, Seth Kurtzberg wrote:

A couple of comments.

  1. I hate having to type Makefile instead of makefile. make will accept
    either, so any make replacement should allow the initial lower case
    letter. Why anyone uses Makefile instead of makefile I’ve never
    understood…


Seth Kurtzberg
M. I. S. Corp.
480-661-1849
seth@cql.com