-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
51 lines (42 loc) · 1.23 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
require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end
require 'rake/extensiontask'
task build: :compile
Rake::ExtensionTask.new('alglib') do |ext|
ext.lib_dir = 'lib/alglib'
end
desc 'Download and extract ALGLIB'
namespace :ext do
task :alglib do
require 'open-uri'
require 'zip'
source_url = 'https://www.alglib.net/translator/re/alglib-4.01.0.cpp.gpl.zip'
target_dir = './ext/alglib'
# Download the file to a temporary location
temp_file = Tempfile.new('alglib')
URI.open(source_url) do |src|
temp_file.write(src.read)
temp_file.flush
end
# Extract downloaded file to target directory
Zip::File.open(temp_file.path) do |zip_file|
zip_file.each do |entry|
# Skip test files
next if entry.name.start_with?('alglib-cpp/tests')
path_to_extract = File.join(target_dir, File.basename(entry.name))
case File.extname(entry.name)
when '.cpp', '.h'
FileUtils.mkdir_p File.dirname(path_to_extract)
entry.extract(path_to_extract) { true }
end
end
end
temp_file.close
temp_file.unlink
end
end