aboutsummaryrefslogtreecommitdiffstats
path: root/doc/rake/example
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-02 19:07:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-02 19:07:55 +0000
commit719b0f8e3037e1033726b6487d7b0d9fc1412e7d (patch)
treec5a08c8c9abae9b7f0514f680f56553a7a03656a /doc/rake/example
parenta0f667c33e24928374d494c9c33d0082355785e1 (diff)
downloadruby-719b0f8e3037e1033726b6487d7b0d9fc1412e7d.tar.gz
* lib/rake: updated to rake code to rake-0.8.7 source code base.
* lib/rake/loaders/makefile.rb (Rake::MakefileLoader#process_line): respace dependencies too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'doc/rake/example')
-rw-r--r--doc/rake/example/Rakefile138
-rw-r--r--doc/rake/example/Rakefile235
-rw-r--r--doc/rake/example/a.c6
-rw-r--r--doc/rake/example/b.c6
-rw-r--r--doc/rake/example/main.c11
5 files changed, 96 insertions, 0 deletions
diff --git a/doc/rake/example/Rakefile1 b/doc/rake/example/Rakefile1
new file mode 100644
index 0000000000..39f8bcceb0
--- /dev/null
+++ b/doc/rake/example/Rakefile1
@@ -0,0 +1,38 @@
+# Example Rakefile -*- ruby -*-
+
+task :default => [:main]
+
+file "a.o" => ["a.c"] do |t|
+ src = t.name.sub(/\.o$/, '.c')
+ sh "gcc #{src} -c -o #{t.name}"
+end
+
+file "b.o" => ["b.c"] do |t|
+ src = t.name.sub(/\.o$/, '.c')
+ sh "gcc #{src} -c -o #{t.name}"
+end
+
+file "main.o" => ["main.c"] do |t|
+ src = t.name.sub(/\.o$/, '.c')
+ sh "gcc #{src} -c -o #{t.name}"
+end
+
+OBJFILES = ["a.o", "b.o", "main.o"]
+task :obj => OBJFILES
+
+file "main" => OBJFILES do |t|
+ sh "gcc -o #{t.name} main.o a.o b.o"
+end
+
+task :clean do
+ rm_f FileList['*.o']
+ Dir['*~'].each { |fn| rm_f fn }
+end
+
+task :clobber => [:clean] do
+ rm_f "main"
+end
+
+task :run => ["main"] do
+ sh "./main"
+end
diff --git a/doc/rake/example/Rakefile2 b/doc/rake/example/Rakefile2
new file mode 100644
index 0000000000..35310eceb5
--- /dev/null
+++ b/doc/rake/example/Rakefile2
@@ -0,0 +1,35 @@
+# Example Rakefile -*- ruby -*-
+# Using the power of Ruby
+
+task :default => [:main]
+
+def ext(fn, newext)
+ fn.sub(/\.[^.]+$/, newext)
+end
+
+SRCFILES = Dir['*.c']
+OBJFILES = SRCFILES.collect { |fn| ext(fn,".o") }
+
+OBJFILES.each do |objfile|
+ srcfile = ext(objfile, ".c")
+ file objfile => [srcfile] do |t|
+ sh "gcc #{srcfile} -c -o #{t.name}"
+ end
+end
+
+file "main" => OBJFILES do |t|
+ sh "gcc -o #{t.name} main.o a.o b.o"
+end
+
+task :clean do
+ rm_f FileList['*.o']
+ Dir['*~'].each { |fn| rm_f fn }
+end
+
+task :clobber => [:clean] do
+ rm_f "main"
+end
+
+task :run => ["main"] do
+ sh "./main"
+end
diff --git a/doc/rake/example/a.c b/doc/rake/example/a.c
new file mode 100644
index 0000000000..620e6f8007
--- /dev/null
+++ b/doc/rake/example/a.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void a()
+{
+ printf ("In function a\n");
+}
diff --git a/doc/rake/example/b.c b/doc/rake/example/b.c
new file mode 100644
index 0000000000..9b24aa1273
--- /dev/null
+++ b/doc/rake/example/b.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void b()
+{
+ printf ("In function b\n");
+}
diff --git a/doc/rake/example/main.c b/doc/rake/example/main.c
new file mode 100644
index 0000000000..a04558a251
--- /dev/null
+++ b/doc/rake/example/main.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+extern void a();
+extern void b();
+
+int main ()
+{
+ a();
+ b();
+ return 0;
+}