forked from ruby-prof/ruby-prof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
113 lines (99 loc) · 3.3 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
# encoding: utf-8
require "rubygems/package_task"
require "rake/extensiontask"
require "rake/testtask"
require "rdoc/task"
require "date"
require "rake/clean"
begin
require "bundler/setup"
Bundler::GemHelper.install_tasks
[:build, :install, :release].each {|t| Rake::Task[t].enhance [:rdoc] }
rescue LoadError
$stderr.puts "Install bundler to get support for simplified gem publishing"
end
# To release a version of ruby-prof:
# * Update lib/ruby-prof/version.rb
# * Update CHANGES
# * git commit to commit files
# * rake clobber to remove extra files
# * rake compile to build windows gems
# * rake package to create the gems
# * Tag the release (git tag 0.10.1)
# * Push to ruybgems.org (gem push pkg/<gem files>)
# For a ruby only release, just run
# * rake release
# it will push changes to github, tag the release, build the package and upload it to rubygems.org
# and in case you forgot to increment the version number or have uncommitted changes, it will refuse to work
GEM_NAME = 'ruby-prof'
SO_NAME = 'ruby_prof'
default_spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
# specify which versions/builds to cross compile
Rake::ExtensionTask.new do |ext|
ext.gem_spec = default_spec
ext.name = SO_NAME
ext.ext_dir = "ext/#{SO_NAME}"
ext.lib_dir = "lib/#{RUBY_VERSION}"
ext.cross_compile = true
ext.cross_platform = ['x86-mswin32-60', 'x86-mingw32-60']
end
# Rake task to build the default package
Gem::PackageTask.new(default_spec) do |pkg|
pkg.need_tar = true
end
# make sure rdoc has been built when packaging
# why do we ship rdoc as part of the gem?
Rake::Task[:package].enhance [:rdoc]
# Setup Windows Gem
if RUBY_PLATFORM.match(/win32|mingw32/)
# Windows specification
win_spec = default_spec.clone
win_spec.platform = Gem::Platform::CURRENT
win_spec.files += Dir.glob('lib/**/*.so')
win_spec.instance_variable_set(:@cache_file, nil) # Hack to work around gem issue
# Unset extensions
win_spec.extensions = nil
# Rake task to build the windows package
Gem::PackageTask.new(win_spec) do |pkg|
pkg.need_tar = false
end
end
# --------- RDoc Documentation ------
desc "Generate rdoc documentation"
RDoc::Task.new("rdoc") do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "ruby-prof"
# Show source inline with line numbers
rdoc.options << "--line-numbers"
# Make the readme file the start page for the generated html
rdoc.options << '--main' << 'README.rdoc'
rdoc.rdoc_files.include('bin/*',
'doc/*.rdoc',
'examples/flat.txt',
'examples/graph.txt',
'examples/graph.html',
'lib/**/*.rb',
'ext/ruby_prof/ruby_prof.c',
'ext/ruby_prof/measure_*.h',
'README.rdoc',
'LICENSE')
end
task :default => :test
for file in Dir['lib/**/*.{o,so,bundle}']
CLEAN.include file
end
for file in Dir['doc/**/*.{txt,dat,png,html}']
CLEAN.include file
end
CLEAN.reject!{|f| !File.exist?(f)}
task :clean do
# remove tmp dir contents completely after cleaning
FileUtils.rm_rf('tmp/*')
end
desc 'Run the ruby-prof test suite'
Rake::TestTask.new do |t|
t.libs += %w(lib ext test)
t.test_files = Dir['test/**_test.rb']
t.verbose = true
t.warning = true
end