-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
63 lines (52 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
61
62
63
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'bundler/audit/task'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'rubygems/tasks'
require 'json'
require 'ffi/platform'
def map_library_name(libname)
"#{FFI::Platform::LIBPREFIX}#{libname}.#{FFI::Platform::LIBSUFFIX}"
end
def vendor_arch
"#{FFI::Platform::OS}-#{FFI::Platform::ARCH}"
end
def define_copy_tanker
task copy_tanker_libs:
build_infos = Dir.glob('conan/*/conanbuildinfo.json')
raise 'too many profiles' if build_infos.size > 1
return if build_infos.empty?
deps_info = JSON.parse File.read(build_infos[0])
tankerdep = deps_info['dependencies'].detect { |d| d['name'] == 'tanker' }
# we only need ctanker
libs = ['ctanker']
dest = "vendor/tanker/#{vendor_arch}"
desc 'create vendor directory'
file dest do
mkdir_p dest
end
libs.map { |l| map_library_name(l) }.map { |lib| File.join(tankerdep['lib_paths'][0], lib) }.each do |libname|
target_lib = File.join(dest, File.basename(libname))
desc "copy from #{libname}"
file target_lib => [libname, dest] do
cp(libname, target_lib)
end
task copy_tanker_libs: target_lib
end
end
define_copy_tanker
task :tanker_libs do
libs = Dir.glob("vendor/tanker/#{vendor_arch}/#{map_library_name('ctanker')}")
raise 'no vendor library present and no build infos to get it from' if libs.empty?
task 'copy_tanker_libs'
end
task tanker_libs: :copy_tanker_libs
task install: :tanker_libs
task build: :tanker_libs
task spec: :tanker_libs
Gem::Tasks.new
Bundler::Audit::Task.new
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new
task default: :spec