-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrakefile
More file actions
91 lines (74 loc) · 2.04 KB
/
rakefile
File metadata and controls
91 lines (74 loc) · 2.04 KB
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
require 'rake/clean'
PROJECT_NAME = "Graph"
AUTHOR = "Jimmy Lu"
GITHUB = "https://github.com/BeyondSora/Graph"
CC = "g++"
STANDARD = " -std=c++11 -Wall -Wextra"
DEFINES = " "
EXT_DEFINES = " -DTINYFORMAT_USE_VARIADIC_TEMPLATES"
LIB= ""
@CFLAGS = STANDARD + DEFINES + EXT_DEFINES
PROG = "graph"
SRC = FileList['src/**/*.cpp',
'test/**/*.cpp']
OBJDIR = 'obj'
OBJ = SRC.collect { |fn| File.join(OBJDIR, File.basename(fn).ext('o')) }
CLEAN.include(OBJ, OBJDIR)
CLOBBER.include(PROG)
task :default => [:help]
task :help do
puts
puts "info -> display project related information"
puts "build -> build project for release"
puts "debug -> build a debug version of project"
puts "run -> run executable normally"
puts "test -> run executable with valgrind --leak-full=check"
puts
end
task :info do
puts
puts "Project: #{PROJECT_NAME}"
puts "Author: #{AUTHOR}"
puts "LOC: #{count_loc}"
puts "Github: #{GITHUB}"
puts "Summary:"
puts " Graph is a program which builds simple graphs as defined in"
puts " graph theory of MATH239 at University of Waterloo. This means"
puts " you can build a graph and query the program on the graph's"
puts " connectivity, if it's isomorphic to another graph, or find a"
puts " spanning tree, etc."
puts
end
task :build do
@CFLAGS += " -D_RELEASE"
Rake::Task[PROG].invoke
end
task :debug do
@CFLAGS += " -D_DEBUG"
Rake::Task[PROG].invoke
end
task :run => "build" do
sh "./#{PROG}"
end
task :test => "debug" do
sh "valgrind --leak-check=full ./#{PROG}"
end
file PROG => OBJ do
sh "#{CC} #{@CFLAGS} -o #{PROG} #{OBJ} #{LIB}"
end
directory OBJDIR
rule '.o' => lambda{ |objfile| find_source(objfile) } do |t|
Task[OBJDIR].invoke
sh "#{CC} #{@CFLAGS} -c -o #{t.name} #{t.source}"
end
def find_source(objfile)
base = File.basename(objfile, '.o')
SRC.find { |s| File.basename(s, '.cpp') == base }
end
def count_loc
loc = 0
SRC.each { |f|
loc += File.foreach(f).inject(0) { |c, line| c + 1 }
}
return loc
end