forked from hhyyrylainen/Leviathan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.rb
executable file
·175 lines (114 loc) · 3.74 KB
/
Setup.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
#!/usr/bin/env ruby
# coding: utf-8
# Setup script for Leviathan
# Downloads the assets and dependencies and then builds and installs them
# NOTE: sudo is required on linux (unless skipping package manager installs)
# TODO: update the things
# Ogre required libs: rapidjson-devel
# compile flags: OGRE_CONFIG_THREADS=2 (background resources) OGRE_CONFIG_THREAD_PROVIDER=std
# RubySetupSystem Bootstrap
if not File.exists? "RubySetupSystem/RubySetupSystem.rb"
puts "Initializing RubySetupSystem"
system "git submodule init && git submodule update"
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)
doxyFile = File.join(suggested, "LeviathanDoxy.in")
onError("Not ran from Leviathan base directory!") if not File.exist?(doxyFile)
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
end
require_relative 'RubySetupSystem/RubySetupSystem.rb'
# If false won't get breakpad
# TODO: fix
GetBreakpad = false
# Doesn't get the resources for samples into leviathan/bin if set to false
FetchAssets = true
require_relative 'LeviathanLibraries.rb'
# All the objects
installer = Installer.new(
$leviathanLibList
)
if GetBreakpad
breakpad = Breakpad.new(
version: "master",
installPath: THIRD_PARTY_INSTALL,
noInstallSudo: true
)
installer.addLibrary breakpad
end
# register us for the dependencies runs
installer.registerSelfAsLibrary $leviathanSelfLib
installer.run
if not File.exist? ProjectDir
onError "'leviathan' folder is missing"
end
Dir.chdir(ProjectDir) do
# Assets svn
# Always updated for continuous integration stuff
if FetchAssets # and not SkipPullUpdates
info "Checking out assets svn"
FileUtils.mkdir_p "bin"
Dir.chdir("bin") do
# Check is it an svn repository
system "svn info"
if $?.exitstatus > 0
info "Creating a working copy for assets svn"
runOpen3Checked("svn", "co",
"https://subversion.assembla.com/svn/leviathan-assets/trunk", ".")
end
# Update to latest version (don't force in case there are local changes)
system "svn update"
success "Updated Assets"
end
success "Assets are good to go"
end
FileUtils.mkdir_p "build"
end
success "Leviathan folder and assets are good to go"
info "Compiling Leviathan"
# Build directory is made earlier
Dir.chdir(File.join(ProjectDir, "build")) do
if !runCMakeConfigure [
# This is done automatically
# "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DOGRE_HOME=#{THIRD_PARTY_INSTALL}",
"-DUSE_BREAKPAD=OFF"
]
onError "Failed to configure Leviathan"
end
if !TC.runCompiler
onError "Failed to compile Leviathan"
end
end
success "Done compiling Leviathan"
if OS.linux?
info "Indexing with cscope"
Dir.chdir(ProjectDir) do
runOpen3Checked File.join(ProjectDir, "RubySetupSystem/RunCodeIndexing.rb")
end
success "All done."
info "To compile again just run 'make' in ./build"
puts "You may need to run this setup again from time to time"
else
success "All done."
info "Open build/Leviathan.sln and start coding"
end
exit 0