forked from ruby-numo/numo-narray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
81 lines (68 loc) · 1.85 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
require "bundler/gem_tasks"
begin
task :doc do
dir = "ext/numo/narray"
src = %w[array.c data.c index.c math.c narray.c rand.c struct.c].
map{|s| File.join(dir,s)} +
[File.join(dir,"types/*.c"), "lib/numo/narray/extra.rb"]
sh "cd ext/numo/narray; ruby extconf.rb; make src"
sh "rm -rf yard .yardoc; yard doc -o yard -m markdown -r README.md #{src.join(' ')}"
end
require "rake/extensiontask"
require "rake_compiler_dock"
require "shellwords"
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
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
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",
"RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6",
"cross",
"native",
"gem",
],
]
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
end
namespace :release do
task :windows => "build:windows" do
windows_gem_paths.each do |path|
ruby("-S", "gem", "push", path)
end
end
end
rescue LoadError
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.verbose = false
t.warning = false
t.test_files = FileList['test/**/*_test.rb']
end