-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
59 lines (41 loc) · 1.2 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
require 'rake'
require 'rake/clean'
CC = "clang"
PKGS = "alsa libspotify ncurses"
CFLAGS = "-std=gnu99 -ggdb -Wall"
LDFLAGS = `pkg-config --libs #{PKGS}`.strip << " -lpthread"
TARGET = "spoticli"
SOURCE_DIR = "src"
OBJECT_DIR = "build"
SOURCE_FILES = FileList.new("#{SOURCE_DIR}/**/*.c")
directory OBJECT_DIR
task :default => "build:target"
task :install do
end
task :uninstall do
end
namespace :build do
task :deps do
end
task :objects do
SOURCE_FILES.each do |source|
# replace source dir with object dir
object = source.gsub(/^#{SOURCE_DIR}/, "#{OBJECT_DIR}")
object = object.sub(/\.c$/, '.o')
# create directory
mkdir_p object.pathmap("%d").strip
# compile source
sh "#{CC} #{CFLAGS} -I./#{SOURCE_DIR} -c -o #{object} #{source}"
end
end
CLEAN.include('**/*.o', 'build')
task :target => :objects do
# find all object files in build
object_files = FileList["#{OBJECT_DIR}/**/*.o"].join(' ')
# link
sh "#{CC} #{object_files} #{LDFLAGS} -o #{TARGET}"
end
CLOBBER.include("#{TARGET}")
end
namespace :test do
end