forked from watashi/AlgoLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
43 lines (35 loc) · 1019 Bytes
/
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
require 'rake'
require 'rake/clean'
BIN = 't/gtest_main'
SRC = %w(t/gtest_main.cc t/gtest-all.cc)
INC = File.join(Dir.pwd, 't/')
CXX = 'g++'
CXXFLAGS = '-std=c++11 -O2 -Wall -Wextra -Wconversion -D_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 :testbin 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} -lpthread -o #{BIN} #{obj * ' '}"
end
Rake::Task[BIN.to_sym].invoke
end
task :test => :testbin do
sh "ulimit -s unlimited && ./#{BIN} --gtest_shuffle"
end