forked from Revolutionary-Games/Thrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetupThrive.rb
executable file
·258 lines (170 loc) · 6.05 KB
/
SetupThrive.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/usr/bin/env ruby
# coding: utf-8
# Setup script for Thrive.
# RubySetupSystem Bootstrap
if not File.exists? "RubySetupSystem/RubySetupSystem.rb"
puts "Initializing RubySetupSystem"
system "git submodule init && git submodule update --recursive"
if $?.exitstatus != 0
abort("Failed to initialize or update git submodules. " +
"Please make sure git is in path and " +
"you have an ssh key setup for your github account")
end
else
# Make sure RubySetupSystem is up to date
# This may make debugging RubySetupSystem harder so feel free to comment out
system "git submodule update"
end
require 'fileutils'
require_relative 'RubySetupSystem/RubyCommon.rb'
def checkRunFolder(suggested)
versionFile = File.join(suggested, "thriveversion.ver")
onError("Not ran from Thrive base directory!") if not File.exist?("SetupThrive.rb")
thirdPartyFolder = File.join suggested, "ThirdParty"
FileUtils.mkdir_p thirdPartyFolder
FileUtils.mkdir_p File.join suggested, "build", "ThirdParty"
thirdPartyFolder
end
def projectFolder(baseDir)
File.expand_path File.join(baseDir, "../")
end
def parseExtraArgs
if ARGV.length > 1
onError("Unrecognized command line options.\n" +
"Expected only username in addition to other arguments. Got: #{ARGV.join(' ')}")
end
$svnUser = ARGV[0]
ARGV.shift
# Handle provided password
if $svnUser.count ':'
split = $svnUser.split ':'
$svnUser = split[0]
$svnPassword = split[1]
end
end
require_relative 'RubySetupSystem/RubySetupSystem.rb'
require_relative 'RubySetupSystem/Libraries/SetupLeviathan.rb'
if !$svnUser
$svnUser = "thrive"
$svnPassword = "thrive"
end
WantedURL = "https://#{$svnUser}@boostslair.com/svn/thrive_assets"
leviathan = Leviathan.new(
# Use this if you always want the latest commit
# version: "develop",
version: "eb2bba0a5dc08ae1fda6f97cddd8750c0ad06e4b",
# Doesn't actually work, but leviathan doesn't install with sudo by
# default, or install at all for that matter
noInstallSudo: true
)
puts ""
puts ""
info "Running the engine compilation"
installer = Installer.new([leviathan])
installer.run
info "Thrive folder setup"
if not File.exist? ProjectDir
onError "'thrive' folder is missing"
end
success "Thrive folder exists"
Dir.chdir(ProjectDir) do
system "git pull"
if $?.exitstatus > 0
warning "Failed to pull thrive repo"
end
runOpen3Checked("git", "submodule", "update", "--recursive")
info "Checking assets"
isInteractive = $stdout.isatty
puts "Interactive mode is: " + isInteractive.to_s
if not File.exist? "assets"
info "Getting assets"
params = ["svn", "checkout", "--username", $svnUser]
if !isInteractive
params.push "--non-interactive"
end
if $svnPassword
params.push("--password", $svnPassword)
end
params.push(WantedURL, "assets")
system(*params)
if $?.exitstatus != 0
onError "Failed to get thrive assets repository"
end
else
info "Updating assets"
Dir.chdir("assets") do
verifySVNUrl(WantedURL)
if $svnPassword
system("svn", "up", "--username", $svnUser, "--password", $svnPassword)
else
system "svn up"
end
onError "Failed to update thrive assets" if $?.exitstatus > 0
end
end
success "Assets are good to go"
# info "Building luajit"
# Dir.chdir(File.join(ProjectDir, "contrib/lua/luajit/src")) do
# # Make sure XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT is uncommented
# outdata = File.read("Makefile").gsub(/#XCFLAGS\+= -DLUAJIT_ENABLE_LUA52COMPAT/,
# "XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT")
# File.open("Makefile", 'w') do |out|
# out << outdata
# end
# runCompiler $compileThreads
# onError "Failed to compile luajit" if $?.exitstatus > 0
# end
# success "luajit is ok"
FileUtils.mkdir_p "build"
end
# Symlink the textures and fonts from assets to make local previewing of the GUI easier
if OS.windows?
info "Creating junctions for assets to be referenced from gui " +
"html without running cmake every time"
runSystemSafe "cmd", "/c", "mklink", "/J",
convertPathToWindows(File.join(ProjectDir, "Textures")),
convertPathToWindows(File.join(ProjectDir, "assets", "textures"))
runSystemSafe "cmd", "/c", "mklink", "/J",
convertPathToWindows(File.join(ProjectDir, "Fonts")),
convertPathToWindows(File.join(ProjectDir, "assets", "fonts"))
runSystemSafe "cmd", "/c", "mklink", "/J",
convertPathToWindows(File.join(ProjectDir, "JSVendor")),
convertPathToWindows(File.join(ProjectDir, "ThirdParty/Leviathan/bin/Data",
"JSVendor"))
else
if !File.exists? File.join(ProjectDir, "Textures")
FileUtils.ln_sf File.join(ProjectDir, "assets", "textures"),
File.join(ProjectDir, "Textures")
end
if !File.exists? File.join(ProjectDir, "Fonts")
FileUtils.ln_sf File.join(ProjectDir, "assets", "fonts"),
File.join(ProjectDir, "Fonts")
end
if !File.exists? File.join(ProjectDir, "JSVendor")
FileUtils.ln_sf File.join(ProjectDir, "ThirdParty/Leviathan/bin/Data", "JSVendor"),
File.join(ProjectDir, "JSVendor")
end
end
success "Thrive folder and assets are good to go"
info "Compiling thrive"
# Build directory is made earlier
Dir.chdir(File.join(ProjectDir, "build")) do
if !runCMakeConfigure []
onError "Failed to configure Thrive. Are you using a broken version, " +
"or did a dependency fail to install?"
end
if !TC.runCompiler
onError "Failed to compile Thrive"
end
end
success "Done compiling thrive"
if OS.windows?
info "Open build/Thrive.sln and start coding"
else
info "run the game with '#{CurrentDir}/thrive/build/Thrive'"
end
puts ""
info "NOTE: when changing the scripts or assets you must rerun cmake to make it move the " +
"changed files to the build folder"
success "Done"
exit 0