-
Notifications
You must be signed in to change notification settings - Fork 0
/
runme.rb
177 lines (144 loc) · 3.87 KB
/
runme.rb
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env ruby
MAYA_VERSIONS = %w(
7.0 8.0 8.0-x64 8.5 8.5-x64 2008 2008-x64 2009-x64 2013-x64 2013
)
RUBY_VERSIONS = %w(
1.9 1.8
)
@program_files = ENV['PROGRAMFILES'] || ''
@program_files = @program_files.gsub(/\\/, '/')
@program_files = @program_files.gsub(/ \(x86\)/, '')
MAYA_PLACES = [
"#{ENV['MAYA_ROOT']}/maya",
"#{ENV['MAYA_ROOT']}/Maya",
"/usr/autodesk/maya",
"/usr/aw/maya",
"/usr/local/autodesk/maya",
"/usr/local/aw/maya",
"/opt/autodesk/maya",
"/opt/aw/maya",
"#@program_files/Autodesk/Maya",
]
MAYA_COMPILERS = {
'Windows' => {
'7.0' => '.NET 2003',
'8.0' => '.NET 2003',
'8.0-x64' => '8',
'8.5' => '8',
'8.5-x64' => '8',
'2008' => '8',
'2008-x64' => '8',
'2013-x64' => '10.0'
}
}
def msvc_environment(version)
compiler_version = MAYA_COMPILERS['Windows'][version]
dir = "#@program_files/Microsoft Visual Studio #{compiler_version}"
puts <<EOF
-------------------------------------------------------------------------
Compiler version for maya #{version} is #{compiler_version}.
-------------------------------------------------------------------------
EOF
unless File.directory?(dir)
puts <<EOF
Compiler version for maya version #{version} is #{compiler_version}.
Directory '#{dir}' does not exist.
EOF
exit 1
end
vsvars = "#{dir}/Common7/Tools/vsvars32.bat"
unless File.readable?(vsvars)
puts <<EOF
File '#{vsvars}' is missing or unreadable.
Cannot set compiler environment.
EOF
exit 1
end
msvc = `"#{vsvars}" && set`
envvars = {}
msvc.each_line do |line|
line =~ /^(.*)=(.*)$/
next unless $1
envvars[$1] = $2
end
envvars.each { |k,v|
ENV[k] = v
}
end
def _run_build(maya_location, *args)
puts <<EOF
####################################################################
BEGIN Building for maya #{maya_location}, ruby #{ENV['RUBY_VERSION']}
####################################################################
EOF
maya_location =~ /maya(\d+(?:\.\d+)?)/i
version = $1
version += "-ruby#{ENV['RUBY_VERSION']}"
maya_location =~ /maya(\d+(?:\.\d+)?(?:-x64)?)/i
full_version = $1
type=32
if full_version =~ /.*-x64/
type=64
end
if RUBY_PLATFORM =~ /mswin/
msvc_environment( full_version )
ok = system("sh -c 'mk #{type} #{args.join(' ')}'")
else
ok = system("mk debug #{type} #{args.join(' ')}")
end
text = ok ? "END" : "FAILED"
puts <<EOF
####################################################################
#{text} Building for maya #{maya_location}, ruby #{ENV['RUBY_VERSION']}
####################################################################
EOF
if !ok
exit(1)
end
end
# for debugging environment
def dump_env(start)
puts '-'*50 + " #{start}"
ENV.each { |k,v|
puts "#{k}=#{v}"
}
puts '-'*78
end
def run_build(maya_location, *args)
sep = ':'
sep = ';' if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /cygwin/
if ENV['RUBY_VERSION']
_run_build( maya_location, *args )
else
paths = ENV['PATH'].split(sep)
for v in RUBY_VERSIONS
for path in paths
ruby = "#{path}/ruby#{v}"
if File.exists?(ruby)
ENV['RUBY_VERSION'] = v
_run_build( maya_location, *args )
break
end
end
end
ENV.delete('RUBY_VERSION')
end
end
if ENV['MAYA_LOCATION']
run_build( ENV['MAYA_LOCATION'], ARGV )
else
for v in MAYA_VERSIONS
for i in MAYA_PLACES
maya_location = "#{i}#{v}"
if File.directory?( maya_location )
oldenv = {}
ENV.each { |k,val| oldenv[k] = val }
ENV['MAYA_LOCATION'] = maya_location
puts maya_location
run_build( maya_location, ARGV )
ENV.clear
oldenv.each { |k,val| ENV[k] = val }
end
end
end
end