-
Notifications
You must be signed in to change notification settings - Fork 40
/
Rakefile
46 lines (38 loc) · 1.12 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
require 'rake'
require 'rake/clean'
BIN = 't/gtest_main'
SRC = %w(t/gtest/gtest_main.cc t/gtest/gtest-all.cc)
INC = File.join(Dir.pwd, 't/')
GXX = 'g++'
CXX = ENV['CXX'] || GXX
CXXFLAGS = '-std=c++0x -O2 -Wall -Wextra -Wconversion'
CXXFLAGS << ' -Wno-sign-conversion' if CXX != GXX
CXXFLAGS << ' -D_GLIBCXX_DEBUG' unless ENV['NO_GLIBCXX_DEBUG']
CLEAN.include('**/*.o')
CLOBBER.include(BIN)
rule '.o' => '.cc' do |t|
sh "#{CXX} -I#{INC} #{CXXFLAGS} -c -o #{t.name} #{t.source}"
end
task :default => [:test]
task :build do
dir = Rake.original_dir
src = `find "#{dir}" -wholename '*GTest.cc'`.lines.map(&:chomp)
src.each do |i|
dep = []
dep << "GTestHelper.cpp"
dep << "../#{$1}.cpp" if i =~ /(\w+)GTest.cc$/
dep = dep.map{|j| File.join(File.dirname(i), j)}
dep = dep.select{|j| File.exists? j}
dep << i
file i.ext('.o') => dep
end
src += SRC.map{|i| File.join(Dir.pwd, i)}
obj = src.map{|i| i.ext('.o')}
file BIN => obj do
sh "#{CXX} -pthread -o #{BIN} #{obj * ' '}"
end
Rake::Task[BIN.to_sym].invoke
end
task :test => :build do
sh "ulimit -s unlimited && ./#{BIN} --gtest_shuffle"
end