-
Notifications
You must be signed in to change notification settings - Fork 34
/
Rakefile
189 lines (161 loc) · 5.22 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
require 'rake/testtask'
require 'rake/extensiontask'
require 'bundler/setup'
require 'bindeps'
require 'rbconfig'
Rake::ExtensionTask.new('transrate') do |ext|
ext.lib_dir = "lib/transrate"
end
Rake::TestTask.new do |t|
t.libs << 'test'
end
Rake::TestTask.new do |t|
t.name = :recip
t.libs << 'test'
t.test_files = ['test/test_reciprocal.rb']
end
Rake::TestTask.new do |t|
t.name = :comp
t.libs << 'test'
t.test_files = ['test/test_comp_metrics.rb']
end
Rake::TestTask.new do |t|
t.name = :contig_metrics
t.libs << 'test'
t.test_files = ['test/test_contig_metrics.rb']
end
Rake::TestTask.new do |t|
t.name = :read
t.libs << 'test'
t.test_files = ['test/test_read_metrics.rb']
end
Rake::TestTask.new do |t|
t.name = :bowtie
t.libs << 'test'
t.test_files = ['test/test_bowtie.rb']
end
Rake::TestTask.new do |t|
t.name = :rater
t.libs << 'test'
t.test_files = ['test/test_transrater.rb']
end
Rake::TestTask.new do |t|
t.name = :bin
t.libs << 'test'
t.test_files = ['test/test_bin.rb']
end
Rake::TestTask.new do |t|
t.name = :contig
t.libs << 'test'
t.test_files = ['test/test_contig.rb']
end
Rake::TestTask.new do |t|
t.name = :assembly
t.libs << 'test'
t.test_files = ['test/test_assembly.rb']
end
Rake::TestTask.new do |t|
t.name = :snap
t.libs << 'test'
t.test_files = ['test/test_snap.rb']
end
Rake::TestTask.new do |t|
t.name = :salmon
t.libs << 'test'
t.test_files = ['test/test_salmon.rb']
end
Rake::TestTask.new do |t|
t.name = :optimiser
t.libs << 'test'
t.test_files = ['test/test_optimiser.rb']
end
Rake::TestTask.new do |t|
t.name = :cmdline
t.libs << 'test'
t.test_files = ['test/test_cmdline.rb']
end
desc "Run tests"
task :default => :test
# PACKAGING
PACKAGE_NAME = "transrate"
VERSION = `bundle exec bin/transrate -v`.chomp
TRAVELING_RUBY_VERSION = "20150210-2.2.0"
desc "Package your app"
task :package => ['package:linux', 'package:osx']
namespace :package do
desc "Package your app for Linux x86_64"
task :linux => [:bundle_install, "packaging/packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz"] do
create_package("linux-x86_64")
end
desc "Package your app for OS X"
task :osx => [:bundle_install, "packaging/packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz"] do
create_package("osx")
end
end
file "packaging/packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz" do
download_runtime("linux-x86_64")
end
file "packaging/packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz" do
download_runtime("osx")
end
desc "Install gems to local directory"
task :bundle_install do
if RUBY_VERSION !~ /^2\.2\./
abort "You can only 'bundle install' using Ruby 2.2, because that's what Traveling Ruby uses."
end
Bundler.with_clean_env do
sh "env BUNDLE_IGNORE_CONFIG=1 bundle install --path packaging/vendor --without development"
end
sh "rm -f packaging/vendor/*/*/cache/*"
end
def create_package(target)
package_pref = "#{PACKAGE_NAME}-#{VERSION}-#{target}"
package_dir = "packaging/#{package_pref}"
sh "rm -rf #{package_dir}"
sh "mkdir -p #{package_dir}/lib/app"
# copy transrate gem to destination
sh "cp -r lib bin deps ext files.txt #{package_dir}/lib/app/"
# install travelling ruby
sh "mkdir #{package_dir}/lib/app/ruby"
sh "tar -xzf packaging/packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz -C #{package_dir}/lib/app/ruby"
# install loading script for transrate
sh "cp packaging/transrate #{package_dir}/transrate"
# install bundled gem dependencies
sh "cp -pR packaging/vendor #{package_dir}/lib/"
sh "cd #{package_dir} && ../minify.sh"
sh "cp -r #{package_dir}/lib/vendor/* #{package_dir}/lib/app/"
sh "cp Gemfile Gemfile.lock transrate.gemspec #{package_dir}/lib/app/"
sh "mkdir #{package_dir}/lib/app/.bundle"
sh "cp packaging/bundler-config #{package_dir}/lib/app/.bundle/config"
# free up some more space in the package dir
sh "rm -rf #{package_dir}/lib/vendor"
sh "rm -rf #{package_dir}/lib/app/ruby/*/gems/*/test"
# install binary dependencies
bindest = File.expand_path "packaging/bindeps/#{target}"
sh "mkdir -p #{bindest}"
sh "rm -rf packaging/bindeps/#{target}/*"
real_os = RbConfig::CONFIG['host_os']
real_path = ENV['PATH']
RbConfig::CONFIG['host_os'] = target == 'osx' ? 'darwin' : target
ENV['PATH'] = "/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"
bindeps_file = File.join(File.dirname(__FILE__), 'deps/deps.yaml')
Bindeps.require(bindeps_file, bindest)
RbConfig::CONFIG['host_os'] = real_os
ENV['PATH'] = real_path
sh "cp -r packaging/bindeps/#{target}/{bin,lib} #{package_dir}/"
# install c extension
sh "cp test/vagrant/#{target}/libruby.* #{package_dir}/lib/"
sh "cp test/vagrant/#{target}/transrate.* #{package_dir}/lib/app/ext/transrate/"
# create package
if !ENV['DIR_ONLY']
sh "cd packaging && tar -czf #{package_pref}.tar.gz #{package_pref}"
sh "rm -rf #{package_dir}"
end
# cleanup
sh "rm -rf packaging/vendor packaging/bindeps .bundle"
end
def download_runtime(target)
sh "mkdir -p packaging/packaging &&" +
"cd packaging/packaging && curl -L -O --fail " +
"http://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz"
end