-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
106 lines (86 loc) · 2.83 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
require 'rake/clean'
cxx = ENV['CXX']
boost = ENV['BOOST_INCLUDE_PATH']
sphinx_build = ""
if ENV.key?('PYTHON_BIN')
sphinx_build = "#{ENV['PYTHON_BIN']}sphinx-build"
end
langflags = "-std=c++1y -ftemplate-backtrace-limit=0"
wflags = "-Wall -Wextra -pedantic -Wno-missing-field-initializers"
archflags = "-march=native"
incflags = "-I include -isystem #{boost}"
ldflags = ""
if cxx.include? "clang"
optflags = "-Ofast -fno-fast-math -flto"
lib_optflags = "-Ofast -fno-fast-math -flto"
elsif cxx.include? "g++"
optflags = "-Ofast -fno-fast-math -flto"
lib_optflags = "-Ofast -fno-fast-math -flto"
end
if RUBY_PLATFORM.include? "linux"
ldflags = "-ldl"
end
cxxflags = "#{langflags} #{wflags} #{archflags} #{incflags} #{optflags}"
lib_ppflags = "-DCCBASE_EXPORT_SYMBOLS"
lib_confflags = ""
if RUBY_PLATFORM.include? "linux"
lib_confflags = "-shared -fpic -fvisibility=hidden"
elsif RUBY_PLATFORM.include? "darwin"
lib_confflags = "-dynamiclib -fvisibility=hidden"
end
lib_cxxopts = "#{langflags} #{wflags} #{archflags} #{incflags} #{lib_optflags}"
lib_cxxflags = "#{lib_cxxopts} #{lib_ppflags} #{lib_confflags}"
dirs = ["out/test", "out/libraries", "out/reference"]
tests = FileList["source/test/*"].map{|f| f.sub("source", "out").ext("run")}
libs = FileList["source/libraries/*"].map{|f| f.sub("source", "out").ext("lib")}
if RUBY_PLATFORM.include? "linux"
refs = FileList["source/reference/linux/*"].map{|f| f.sub("source", "out").
sub("linux/", "").ext("run")}
elsif RUBY_PLATFORM.include? "darwin"
refs = FileList["source/reference/os_x/*"].map{|f| f.sub("source", "out").
sub("os_x/", "").ext("run")}
end
multitask :default => dirs + tests + libs
task "refs" => dirs + refs
task "check" => dirs + tests + libs do
(tests - ["out/test/unit_test_test.run"]).each do |f|
r = `./#{f} -v medium`
if r.include? "Failure"
puts "The test \"#{f}\" failed! Please submit a bug report."
puts r
end
end
end
task "docs" do
sh "#{sphinx_build} -b html docs ../gh-pages"
end
dirs.each do |d|
directory d
end
libs.each do |f|
src = f.sub("out", "source").ext("cpp")
file f => [src] + dirs do
sh "#{cxx} #{lib_cxxflags} -o #{f} #{src}"
end
end
tests.each do |f|
src = f.sub("out", "source").ext("cpp")
file f => [src] + dirs do
sh "#{cxx} #{cxxflags} -o #{f} #{src} #{ldflags}"
end
end
refs.each do |f|
if RUBY_PLATFORM.include? "linux"
src = f.sub("out", "source").sub("ref", "reference/linux").ext("cpp")
elsif RUBY_PLATFORM.include? "darwin"
src = f.sub("out", "source").sub("ref", "reference/os_x").ext("cpp")
end
file f => [src] + dirs do
sh "#{cxx} #{cxxflags} -o #{f} #{src} #{ldflags}"
end
end
task :clobber => dirs do
FileList["out/test/*.run"].each{|f| File.delete(f)}
FileList["out/libraries/*"].each{|f| File.delete(f)}
FileList["out/reference/**/*.run"].each{|f| File.delete(f)}
end