-
Notifications
You must be signed in to change notification settings - Fork 253
/
Rakefile
164 lines (139 loc) · 4.81 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
$: << File.expand_path("../lib", __FILE__)
require "ruby_installer/build"
require "bundler/gem_tasks"
require "rake/clean"
require "find"
include RubyInstaller::Build::Utils
task :gem => :build
# Forward package build tasks to the sub Rakefiles.
%w[ri ri-msys].each do |packname|
namespace packname do |ns|
Rake::TaskManager.record_task_metadata = true
Rake.load_rakefile "packages/#{packname}/Rakefile"
ns.tasks.select(&:comment).each do |t|
name, comment = t.name.sub(/.*?:/, ""), t.comment
t.clear
desc comment
task name do
chdir "packages/#{packname}" do
sh "rake", name
end
end
end
end
# Add all package dirs/files to `rake clean` which are not registered in git and don't contain any files registered in git.
gitfiles = `git ls-files -z`.split("\0")
clean_list = Enumerator.new do |y|
Find.find("packages/#{packname}") do |path|
path = path.gsub(/\A\.\//, "") # remove prefix "./"
unless gitfiles.find { |gf| gf.start_with?(path) }
y << path
Find.prune
end
end
end
CLEAN.include(clean_list.to_a)
end
libtest = "test/helper/libtest.dll"
file libtest => libtest.sub(".dll", ".c") do |t|
RubyInstaller::Build.enable_msys_apps
sh RbConfig::CONFIG['CC'], "-shared", t.prerequisites.first, "-o", t.name
end
CLEAN.include(libtest)
desc "Run tests on the Ruby installation"
task :test => libtest do
sh "ruby -w -W2 -I. -e \"#{Dir["test/**/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
# Re-test with simulated legacy Windows version.
# This is done in a dedicated run, because it's not possible to revert a call to SetDefaultDllDirectories().
# See https://msdn.microsoft.com/de-de/library/windows/desktop/hh310515(v=vs.85).aspx
ENV['RI_FORCE_PATH_FOR_DLL'] = '1'
sh "ruby -w -W2 -I. -e \"#{Dir["test/ruby_installer/test_module.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
ENV['RI_FORCE_PATH_FOR_DLL'] = '0'
end
namespace :ssl do
directory "resources/ssl"
desc "Download latest SSL trust certificates"
task :update => "resources/ssl" do
ca_file = RubyInstaller::Build::CaCertFile.new
File.binwrite("resources/ssl/cacert.pem", ca_file.content)
end
task :update_check do
old_file = RubyInstaller::Build::CaCertFile.new(File.binread("resources/ssl/cacert.pem"))
print "Download SSL CA list..."
begin
new_file = RubyInstaller::Build::CaCertFile.new
rescue SocketError => err
puts " failed: #{err} (#{err.class})"
else
if old_file == new_file
puts " => unchanged"
else
puts " => changed"
raise "cacert.pem has changed"
end
end
end
end
namespace "release" do
desc "Update date in CHANGELOG file and set a git tag"
task "tag", [:name] do |_task, args|
release = RubyInstaller::Build::Release.new
# Enable this to update release date in CHANGELOG files
# release.update_history(args[:name])
release.tag_version(args[:name])
end
task "upload" do
files = ARGV[ARGV.index("--")+1 .. -1]
release = RubyInstaller::Build::Release.new
release.upload_to_github(
tag: ENV['DEPLOY_TAG'],
repo: ENV['DEPLOY_REPO_NAME'],
token: ENV['DEPLOY_TOKEN'],
files: files
)
end
task "appveyor_upload" do
files = ARGV[ARGV.index("--")+1 .. -1]
files.each { |f| task(f) }
if ENV['DEPLOY_TAG'].to_s.include?(ENV['target_ruby'])
puts "Upload #{ENV['DEPLOY_TAG']}: #{files}"
require "ruby_installer/build"
RubyInstaller::Build.enable_msys_apps
sh "#{ENV['RI_DEVKIT']}/usr/bin/mkdir -p %USERPROFILE%/.gnupg"
sh "gpg --batch --passphrase %GPGPASSWD% --decrypt appveyor-key.asc.asc | gpg --import"
sh "#{ENV['RI_DEVKIT']}/usr/bin/mkdir artifacts"
sh "cp", "-v", *files, "artifacts/"
sh "ls artifacts/* | xargs -n1 gpg --verbose --detach-sign --armor"
sh "rake release:upload -- artifacts/*"
else
puts "No release upload"
end
end
CLEAN.include("artifacts")
end
namespace "docker" do
task :image do
rm_rf "docker/gitrepo"
cp_r ".git", "docker/gitrepo"
sh "docker build -t ri2 docker"
end
desc "Run all builds"
multitask :builds
%w[ri ri-msys].each do |package|
%w[x86 x64].each do |arch|
task "#{package}-#{arch}" => :image do
# Use the cache of our main MSYS2 environment for package install
cachedir = File.expand_path("../cache/#{package}-#{arch}", __FILE__)
mkdir_p cachedir
puts "Using pacman cache in #{cachedir}"
pwd = Dir.pwd
pkgdir = "#{pwd}/pkg"
mkdir_p pkgdir
sh "docker run --rm -v #{cachedir}:c:/ruby24-x64/msys64/var/cache/pacman -v #{pkgdir}:c:/build/pkg ri2 cmd /c rake PACKAGE=#{package} ARCH=#{arch}"
end
multitask :builds => "#{package}-#{arch}"
end
end
end
CLOBBER.include("pkg")
CLOBBER.include("cache")