-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
66 lines (56 loc) · 1.44 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding:utf-8 -*-
require 'rake/clean'
CPP = 'g++'
CPP_FLAGS = '-std=gnu++0x -Wall'
CPP_DEBUG_FLAGS = '-pg -g -O0 -fmessage-length=0'
CPP_RELEASE_FLAGS = '-O2 -mtune=amdfam10 -mabm -msse4a'
LIBS = ['boost_system', 'readline', 'pthread']
SRC = FileList['*.cpp']
OBJ = SRC.ext('o')
CLEAN.include('*.o')
CLEAN.include('a.out', 'documents', 'gmon.out')
CLOBBER.include('55shogi')
task :default => '55shogi'
task :debug => '.debug'
task :release => '.release'
desc 'コンパイルして実行します'
task :run => '55shogi' do
if File.exist?('.mpi')
sh "mpirun -np 5 ./55shogi"
else
sh "./55shogi"
end
end
task :doc do
sh "doxygen 55shogi.doxyfile"
end
file '.debug' do
Rake::Task['clean'].invoke
sh 'rm -f ./.release'
sh 'touch ./.debug'
Rake::Task['default'].invoke
end
file '.release' do
Rake::Task['clean'].invoke
sh 'rm -f ./.debug'
sh 'touch ./.release'
Rake::Task['default'].invoke
end
# 現在のモードを元にフラグを確定する
def cpp_mode_flags
mode = 'debug'
if File.exist?('.release')
mode = 'release'
end
res = eval("CPP_#{mode.upcase}_FLAGS")
if File.exist?('.mpi')
res += ' -DMPI_ENABLE'
end
return res
end
rule '.o' => '.cpp' do |t|
sh "#{CPP} -c -o #{t.name} #{t.source} #{LIBS.map{|a| "-l#{a}"}.join(' ')} #{CPP_FLAGS} #{cpp_mode_flags}"
end
file '55shogi' => OBJ do
sh "#{CPP} -o 55shogi #{OBJ} #{LIBS.map{|a| "-l#{a}"}.join(' ')} #{CPP_FLAGS} #{cpp_mode_flags}"
end