-
Notifications
You must be signed in to change notification settings - Fork 28
/
Rakefile
44 lines (37 loc) · 1.24 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
require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"
task default: :test
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
end
Rake::ExtensionTask.new("or-tools") do |ext|
ext.name = "ext"
ext.lib_dir = "lib/or_tools"
end
task :remove_ext do
path = "lib/or_tools/ext.bundle"
File.unlink(path) if File.exist?(path)
end
Rake::Task["build"].enhance [:remove_ext]
task :update do
require "digest"
require "open-uri"
require "tmpdir"
version = "9.11.4210"
distributions = ["arm64_macOS-14.6.1", "x86_64_macOS-14.6.1", "amd64_ubuntu-24.04", "amd64_ubuntu-22.04", "amd64_ubuntu-20.04", "amd64_debian-11", "amd64_debian-12", "amd64_archlinux"]
short_version = version.split(".").first(2).join(".")
distributions.each do |dist|
filename = "or-tools_#{dist}_cpp_v#{version}.tar.gz"
url = "https://github.com/google/or-tools/releases/download/v#{short_version}/#{filename}"
dest = "#{Dir.tmpdir}/#{filename}"
unless File.exist?(dest)
temp_dest = "#{dest}.tmp"
success = system("wget", "-O", temp_dest, url)
raise "Download failed" unless success
File.rename(temp_dest, dest)
end
puts "#{dist}: #{Digest::SHA256.file(dest).hexdigest}"
end
end