D语言通用 Rakefile

在一个日文网站上发现的通用 Rakefile for GDC

require
"rake/clean"

NAME = "hogehoge" # プロジェクト名 ##可执行文件名
PROG = "#{NAME}"
PROG_DEBUG = "#{NAME}_debug"
SRC = "src"

SRCS = FileList["./src/**/*.d"]
OBJS = SRCS.ext "o"
OBJS_DEBUG = SRCS.map {|file| file.sub /\.d$/, "_debug.o"}

task :default => :run_debug
task :release => PROG
task :debug => PROG_DEBUG

rule ".o" => ".d" do |t|
sh "gdc #{t.source} -c -I #{SRC} -inline -O --release -w -o #{t.name}"
end

rule("_debug.o" => [proc {|tn| tn.sub(/_debug\.o$/, ".d")}]) do |t|
sh "gdc #{t.source} -c --debug -g -I #{SRC} --unittest -w -o #{t.name}"
end

file PROG => OBJS do |t|
sh "gdc -o #{t.name} #{t.prerequisites.join(' ')}"
end
file PROG_DEBUG => OBJS_DEBUG do |t|
sh "gdc -o #{t.name} #{t.prerequisites.join(' ')}"
end

CLEAN.include OBJS
CLEAN.include OBJS_DEBUG
CLOBBER.include PROG
CLOBBER.include PROG_DEBUG

task :run => :run_release
task :run_release => PROG do
sh "./#{PROG}"
end
task :run_debug => PROG_DEBUG do
sh "./#{PROG_DEBUG}"
end

你可能感兴趣的:(C++,c,windows,ext,D语言)