forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
148 lines (128 loc) · 4.09 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
namespace :build do
desc "Upload the build files to an imagefactory instance"
task :upload do
raise "must set ENV['SCP_USER_HOST'], such as root@your_host" if ENV['SCP_USER_HOST'].nil?
require 'pathname'
build_dir = Pathname.new(File.join(File.dirname(__FILE__), 'build'))
`ssh #{ENV['SCP_USER_HOST']} "rm -rf ~/manageiq && mkdir -p ~/manageiq"`
`scp -qr #{build_dir} #{ENV['SCP_USER_HOST']}:~/manageiq/build`
end
namespace :shared_objects do
desc "Clean built shared objects and artifacts."
task :clean do
require 'fileutils'
require 'pathname'
base = Pathname.new(File.dirname(__FILE__)).freeze
artifacts_dirs = %w(
lib/disk/modules/MiqBlockDevOps
lib/disk/modules/MiqLargeFileLinux.d
lib/SlpLib/SlpLib_raw/
lib/NetappManageabilityAPI/NmaCore/NmaCore_raw
)
artifacts_dirs.each do |dir|
dir = base.join(dir)
patterns = %w(*.log *.o *.out Makefile)
patterns.each do |p|
Dir.glob(dir.join(p)) do |f|
puts "** Removing #{f}"
FileUtils.rm_f(f)
end
end
end
so_dirs = %w(
lib/disk/modules/
lib/SlpLib/lib/
lib/NetappManageabilityAPI/NmaCore/
)
so_dirs.each do |dir|
dir = base.join(dir)
patterns = %w(**/*.so **/*.bundle)
patterns.each do |p|
Dir.glob(dir.join(p)) do |f|
puts "** Removing #{f}"
FileUtils.rm_f(f)
end
end
end
end
end
desc "Build shared objects"
task :shared_objects do
def build_shared_objects(so_name, make_dir, install_dir, extconf_params = nil)
if File.exist?(install_dir.join(so_name))
puts "** Skipping build of #{so_name} since it is already built."
return
end
puts "** Building #{so_name}..."
Dir.chdir(make_dir) do
`ruby extconf.rb #{extconf_params}`
`make`
FileUtils.mkdir_p(install_dir)
FileUtils.mv(so_name, install_dir)
end
puts "** Building #{so_name}...complete"
end
require 'fileutils'
require 'pathname'
base = Pathname.new(File.dirname(__FILE__)).freeze
platform = RUBY_PLATFORM.match(/(.+?)[0-9\.]*$/)[1] # => "x86_64-linux" or "x86_64-darwin"
_arch, os = platform.split("-") # => ["x86_64", "linux"]
#
# MiqBlockDevOps
#
if platform == "x86_64-linux"
build_shared_objects(
"MiqBlockDevOps.so",
base.join("lib/disk/modules/MiqBlockDevOps/"),
base.join("lib/disk/modules/")
)
else
puts "** Skipping build of MiqBlockDevOps.so since it is only built on x86_64-linux."
end
#
# MiqLargeFileLinux
#
if platform == "x86_64-linux"
build_shared_objects(
"MiqLargeFileLinux.so",
base.join("lib/disk/modules/MiqLargeFileLinux.d/"),
base.join("lib/disk/modules/ruby#{RUBY_VERSION}/")
)
else
puts "** Skipping build of MiqLargeFileLinux.so since it is only built on x86-linux."
end
#
# SlpLib
#
if os == "darwin"
include_file = "/usr/local/include/slp.h"
lib_file = "/usr/local/lib/libslp.dylib"
so_name = "SlpLib_raw.bundle"
else # RHEL, Fedora
include_file = "/usr/include/slp.h"
lib_file = "/usr/lib64/libslp.so"
so_name = "SlpLib_raw.so"
end
if File.exist?(include_file) && File.exist?(lib_file)
build_shared_objects(
so_name,
base.join("lib/SlpLib/SlpLib_raw/"),
base.join("lib/SlpLib/lib/#{platform}/")
)
else
puts "** Skipping build of #{so_name} due to missing header or library."
end
#
# NmaCore
#
if Dir.exist?("/usr/include/netapp") && Dir.exist?("/usr/lib64/netapp")
build_shared_objects(
"NmaCore_raw.so",
base.join("lib/NetappManageabilityAPI/NmaCore/NmaCore_raw/"),
base.join("lib/NetappManageabilityAPI/NmaCore/#{platform}/ruby#{RUBY_VERSION}/")
)
else
puts "** Skipping build of NmaCore_raw.so due to missing header or library."
end
end
end