-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
60 lines (54 loc) · 1.62 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
# frozen_string_literal: true
require "rake"
require "fileutils"
require "ffi"
minimap2_dir = File.expand_path("minimap2", __dir__)
target_dir = "../../vendor"
target_fname = FFI.map_library_name("minimap2")
target_path = File.join(target_dir, target_fname)
task default: ["minimap2:build", "minimap2:clean"]
namespace :minimap2 do
desc "Compile Minimap2"
task :build do
Dir.chdir(minimap2_dir) do
# Add -fPIC option to Makefile
sh "git apply ../minimap2.patch"
sh "cp ../cmappy/cmappy.h ../cmappy/cmappy.c ."
case RbConfig::CONFIG["host_cpu"]
when /arm64/
sh "make arm_neon=1 aarch64=1"
when /arm/
sh "make arm_neon=1"
else
sh "make"
end
case RbConfig::CONFIG["host_os"]
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
sh "cc *.o -shared -o #{target_fname} -lm -lz -lpthread"
when /darwin|mac os/
sh "clang -dynamiclib -undefined dynamic_lookup -o #{target_fname} *.o -lm -lz -lpthread"
sh "otool -L #{target_fname}"
else
sh "cc *.o -shared -o #{target_fname} -lm -lz -lpthread"
sh "ldd -r #{target_fname}"
end
sh "rm cmappy.h cmappy.c"
sh "git apply -R ../minimap2.patch"
FileUtils.mkdir_p(target_dir)
warn "mkdir -p #{target_dir}"
sh "mv #{target_fname} #{target_path}"
end
end
desc "`make clean`"
task :clean do
Dir.chdir(minimap2_dir) do
sh "make clean"
end
end
desc "`make clean` and remove shared lib"
task cleanall: [:clean] do
Dir.chdir(minimap2_dir) do
sh "rm #{target_path}" if File.exist?(target_path)
end
end
end