-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
107 lines (90 loc) · 2.77 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
require 'rake/clean'
$:.push File.expand_path("../lib", __FILE__)
require 'P4/version'
task 'version' do
puts P4::VERSION
end
GEM_SPEC = Gem::Specification.new { |t|
t.name = 'p4ruby'
t.version = P4::VERSION
t.platform = Gem::Platform::RUBY
t.summary = 'Ruby extensions to the C++ Perforce API'
t.description = t.summary + '.'
t.author = 'Perforce Software, Inc.'
t.email = '[email protected]'
t.homepage = 'https://github.com/perforce/p4ruby'
t.extensions = ['ext/P4/extconf.rb']
t.licenses = ['MIT']
t.files = %w( LICENSE.txt README.md )
t.files += Dir.glob('ext/**/*.cpp')
t.files += Dir.glob('ext/**/*.h')
t.files += Dir.glob('lib/**/*.rb')
t.files += Dir.glob('p4-bin/**/p4api.*')
t.files += Dir.glob('lib/**/P4.so*')
t.metadata = { "documentation_uri" => "https://www.perforce.com/manuals/p4ruby/Content/P4Ruby/Home-p4ruby.html" }
}
begin
require 'rake/extensiontask'
unless ENV['P4RUBY_CROSS_PLATFORM'].nil?
# Set P4RUBY_CROSS_PLATFORM to x86-mingw32, x64-mingw32
Rake::ExtensionTask.new('P4', GEM_SPEC) do |ext|
ext.cross_compile = true
ext.cross_platform = ENV['P4RUBY_CROSS_PLATFORM']
end
else
Rake::ExtensionTask.new('P4', GEM_SPEC)
end
Gem::PackageTask.new(GEM_SPEC) do |pkg|
pkg.need_tar = false
pkg.need_zip = false
end
rescue Exception
#puts 'could not load rake/extensiontask'
end
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << '.'
t.libs << 'test'
t.warning = true
t.verbose = true
t.test_files = FileList[ 'test/testlib.rb', 'test/*_test.rb']
end
require 'rake/packagetask'
package_task = Rake::PackageTask.new('p4ruby', :noversion) do |p|
p.need_tar = true
p.need_zip = true
p.package_files.include %w(
Gemfile
LICENSE.txt
Rakefile
README.md
)
p.package_files.include 'ext/**/*'
p.package_files.include 'lib/**/*'
p.package_files.include 'test/**/*'
end
# On some older platforms (Ruby 1.9) the 'directory' command doesn't work
# correctly.
begin
desc 'Create doc directory from docbook files (requires ant)'
directory 'doc' => 'docbook' do
puts 'Executing docbook'
sh 'cd docbook && ant publicsite -Ddoc.build.path=../p4-doc/manuals/_build && cd ..'
doc_files = FileList['doc/**/*']
package_task.package_files += doc_files
end
CLEAN.include('doc')
desc 'Create build.properties, used to share version numbers in Jenkins tasks'
file 'build.properties' do
props = <<-END.gsub(/^ {4}/, '')
P4RUBY_VERSION=#{P4::VERSION}
END
IO.write('build.properties', props)
end
# Remove output of 'rake compile' command
CLEAN.include('lib/P4.bundle')
CLEAN.include('lib/P4.so')
CLEAN.include('pkg')
rescue Exception => e
puts 'Not creating documentation rules used for builds, this is common in test environments'
end