- お知らせ -
  • 当wikiのプログラムコードの表示を直してみました(ついでに長い行があると全体が下にぶっ飛ぶのも修正)。不具合があればBBSまでご連絡下さい。

内容 Edit

Rakefile で、test.c sub.c をそれぞれコンパイルする例

用意するファイル Edit

以下のファイルを用意する

Rakefile

1
require "rake/clean"

CLEAN.include("*.o")
CLOBBER.include("*.exe")

SRC = FileList["*.c"]
OBJ = SRC.ext("o")

EXE = "test.exe"

desc "default task"
task :default => [EXE]

desc "run task"
task :run do
  sh "test.exe"
end

rule '.o' => [".c"] do |t|
  sh "gcc #{t.source} -c -o #{t.name}"
end
 
file EXE => OBJ do
  sh "gcc #{OBJ} -o #{EXE}"
end

test.c

1
2
3
4
5
6
7
8
9
#include "stdio.h"

extern void hello_world();

int main()
{
  hello_world();
  return(0);
}

sub.c

1
2
3
4
void hello_world()
{
  printf("Hello world!\n");
}

コマンド Edit

rake

で、コンパイル。

rake run

で、実行

rake clean

で、.o削除

rake clobber

で、.exe と .o 削除

rake -T

で、解説表示




Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New Pages Search Recent changes   Help   RSS of recent changes
Last-modified: 2007-05-13 Sun 06:53:27 JST (1210d)