-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
88 lines (64 loc) · 2.1 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
# build, clean, clobber, release[remote]
require 'bundler/gem_tasks'
# clean
CLEAN.include "ext/digest/kangarootwelve/Makefile"
CLEAN.include "ext/digest/kangarootwelve/**/*.o"
CLEAN.include "ext/digest/kangarootwelve/**/*.so"
# clobber
if File.exist?(".git")
CLOBBER.include "LICENSE.XKCP"
CLOBBER.include "ext/digest/kangarootwelve/XKCP"
CLOBBER.include "ext/digest/kangarootwelve/targets"
end
# initialize_xkcp
desc "Initialize and update XKCP submodule"
task :initialize_xkcp => ".git" do |t|
puts "Initializing and updating XKCP submodule."
system "git submodule init && git submodule update -f"
end
file "XKCP/Makefile.build" => :initialize_xkcp
file "XKCP/README.markdown" => :initialize_xkcp
# import_xkcp_license
task :import_xkcp_license do
Rake::Task["XKCP/LICENSE"].invoke
puts "Importing XKCP/LICENSE as LICENSE.XKCP."
File.binwrite("LICENSE.XKCP", File.binread("XKCP/LICENSE"))
end.instance_eval do
def needed?
!File.exist?("LICENSE.XKCP") || File.exist?("XKCP/LICENSE") &&
File.mtime("LICENSE.XKCP") < File.mtime("XKCP/LICENSE")
end
end
# import_xkcp_files_lazy
task :import_xkcp_files_lazy do
Rake::Task[:import_xkcp_files].invoke
end.instance_eval do
def needed?
%w[XKCP targets].any?{ |dir| !File.exist?("ext/digest/kangarootwelve/#{dir}") }
end
end
# build
Rake::Task[:build].prerequisites.unshift :import_xkcp_files
Rake::Task[:build].prerequisites.unshift :import_xkcp_license
Rake::Task[:build].prerequisites.unshift :clobber
# compile, compile:digest/kangarootwelve
require 'rake/extensiontask'
Rake::ExtensionTask.new('digest/kangarootwelve', Bundler::GemHelper.gemspec)
Rake::Task[:compile].prerequisites.unshift :import_xkcp_files_lazy
# compile_lazy
task :compile_lazy do
Rake::Task[:compile].invoke
end.instance_eval do
def needed?
!File.exist?("lib/digest/kangarootwelve.so")
end
end
# test
require 'rake/testtask'
Rake::TestTask.new(:test => :compile_lazy) do |t|
t.test_files = FileList['test/test.rb']
t.verbose = true
end
# default
task :default => [:compile, :test]
# Run `rake --tasks` or `rake --tasks --all` for a list of tasks.