-
Notifications
You must be signed in to change notification settings - Fork 47
/
Rakefile
56 lines (46 loc) · 1.71 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
require 'optparse'
include FileUtils::Verbose
class Dir
def self.nonhidden_entries dirname
self.entries(dirname).grep(/^[^.]/)
end
end
task :default do
mkdir './bin' unless File.directory? './bin'
unless File.exist? './bin/dict'
mrc = `which macrubyc`.strip # mrc == macruby compiler
if mrc.empty?
STDERR.puts <<-EOF.split("\n").map {|l| l.strip}
WARNING: MacRuby is not installed; therefore, `dict`, one
of the tools that depends on it, will not be installed.
The rest of the tools will be installed.
If you would like to use `dict`, install MacRuby from
http://macruby.org/ then re-install tools-osx.
EOF
else
mkdir './.tmp/'
cp './src/dict', './.tmp/dict.rb'
sh "#{mrc} -o ./bin/dict ./.tmp/dict.rb"
rm_rf './.tmp/'
end
end
scrs = Dir.nonhidden_entries('./src/'); scrs.delete 'dict'
scrs.each {|f| cp "./src/#{f}", "./bin/#{f}" unless File.exist? "./bin/#{f}"}
end
task :install => [:default] do |t, args|
unless File.exist? '/usr/local/bin' # create /usr/local/bin if it doesn't exist
mkdir '/usr/local/bin', :mode => 0755
chown 'root', 'wheel', '/usr/local/bin'
end
bins = Dir.nonhidden_entries('./bin/')
bins = bins.select {|x| args.extras.include? x} unless args.extras.count == 0
sh "install -b #{bins.map {|x| "./bin/#{x}"}.join ' '} /usr/local/bin/" unless bins.count == 0
end
task :uninstall do
Dir.nonhidden_entries('./src/').each do |x| # should probably figure out a better way to do this
rm "/usr/local/bin/#{x}", :force => true
end
end
task :clean do
rm_rf './bin'
end