-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathRakefile
More file actions
69 lines (55 loc) · 1.53 KB
/
Rakefile
File metadata and controls
69 lines (55 loc) · 1.53 KB
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
require "bundler/gem_tasks"
begin
require "rake/extensiontask"
require "rake_compiler_dock"
require "shellwords"
require "rspec/core/rake_task"
spec = Bundler::GemHelper.gemspec
cross_platforms = ["x86-mingw32", "x64-mingw32"]
Rake::ExtensionTask.new("numo/narray", spec) do |ext|
ext.cross_compile = true
ext.cross_platform = cross_platforms
end
RSpec::Core::RakeTask.new("spec")
Rake::Task[:spec].prerequisites << :compile
pkg_dir = "pkg"
windows_gem_paths = cross_platforms.collect do |platform|
File.join(pkg_dir, "#{spec.full_name}-#{platform}.gem")
end
namespace :build do
directory pkg_dir
desc "Build gems for Windows into the pkg directory"
task :windows => pkg_dir do
ruby_versions = "2.1.6:2.2.2:2.3.0"
build_dir = "tmp/windows"
rm_rf build_dir
mkdir_p build_dir
commands = [
["git", "clone", "file://#{Dir.pwd}/.git", build_dir],
["cd", build_dir],
["bundle"],
["rake", "cross", "native", "gem", "RUBY_CC_VERSION=#{ruby_versions}"],
]
raw_commands = commands.collect do |command|
Shellwords.join(command)
end
raw_command_line = raw_commands.join(" && ")
RakeCompilerDock.sh(raw_command_line)
cp(Dir.glob("#{build_dir}/#{pkg_dir}/*.gem"),
"#{pkg_dir}/")
end
windows_gem_paths.each do |path|
file path do
Rake::Task["build:windows"].invoke
end
end
end
namespace :release do
task :windows => windows_gem_paths do
windows_gem_paths.each do |path|
ruby("-S", "gem", "push", path)
end
end
end
rescue LoadError
end