-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
238 lines (197 loc) · 5.94 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
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
require "open3"
require "rbconfig"
HOST_OS = RbConfig::CONFIG['host_os']
def unity_directory
if ENV.has_key? 'UNITY_PERFORMANCE_VERSION'
"/Applications/Unity/Hub/Editor/#{ENV['UNITY_PERFORMANCE_VERSION']}"
else
raise 'No unity version set - use $UNITY_PERFORMANCE_VERSION'
end
end
##
#
# Find the Unity executable based on the unity directory.
#
def unity_executable dir=unity_directory
[File.join(dir, "Unity.app", "Contents", "MacOS", "Unity"),
File.join(dir, "Editor", "Unity")].find do |unity|
File.exist? unity
end
end
##
#
# Run a command with the unity executable and the default command line parameters
# that we apply
#
def unity(*cmd, force_free: true, no_graphics: true)
raise "Unable to locate Unity executable in #{unity_directory}" unless unity_executable
cmd_prepend = [unity_executable, "-force-free"]
unless force_free
cmd_prepend = cmd_prepend - ["-force-free"]
end
unless no_graphics
cmd_prepend = cmd_prepend - ["-nographics"]
end
cmd = cmd.unshift(*cmd_prepend)
sh *cmd do |ok, res|
if !ok
puts File.read("unity.log") if File.exist?("unity.log")
raise "unity error: #{res}"
end
end
end
def current_directory
File.dirname(__FILE__)
end
def dev_project_path
File.join(current_directory, "BugsnagPerformance")
end
def build_upm_package
script = File.join("upm", "scripts", "build-upm-package.sh")
command = "#{script} 1.2.3"
unless system command
raise 'build upm package failed'
end
end
def run_unit_tests
unity "-runTests", "-batchmode", "-projectPath", dev_project_path, "-testPlatform", "EditMode", "-testResults", File.join(current_directory, "testResults.xml") , force_free: false
end
namespace :plugin do
namespace :build do
desc "Build UPM package"
task :export do
run_unit_tests
build_upm_package
end
end
end
namespace :test do
namespace :android do
task :build do
# Prepare the test fixture project by importing the upm package
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import package failed'
end
# Build the Android APK
script = File.join("features", "scripts", "build_android.sh release")
unless system script
raise 'Android APK build failed'
end
end
task :build_dev do
# Prepare the test fixture project by importing the upm package
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import package failed'
end
# Build the Android APK
script = File.join("features", "scripts", "build_android.sh dev")
unless system script
raise 'Android Dev APK build failed'
end
end
end
namespace :macos do
task :build do
# Prepare the test fixture project by importing the upm package
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import package failed'
end
# Build the Mac App
script = File.join("features", "scripts", "build_macos.sh release")
unless system script
raise 'macos build failed'
end
end
task :build_dev do
# Prepare the test fixture project by importing the upm package
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import package failed'
end
# Build the Mac App
script = File.join("features", "scripts", "build_macos.sh dev")
unless system script
raise 'macos build failed'
end
end
end
namespace :webgl do
task :build do
# Prepare the test fixture project by importing the upm package
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import package failed'
end
# Build the webgl App
script = File.join("features", "scripts", "build_webgl.sh release")
unless system script
raise 'webgl build failed'
end
end
task :build_dev do
# Prepare the test fixture project by importing the upm package
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import package failed'
end
# Build the webgl App
script = File.join("features", "scripts", "build_webgl.sh dev")
unless system script
raise 'webgl build failed'
end
end
end
namespace :ios do
task :generate_xcode do
# Prepare the test fixture project by importing the plugins
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import_package failed'
end
# Generate the Xcode project
cd "features" do
script = File.join("scripts", "generate_xcode_project.sh release")
unless system script
raise 'generate_xcode_project failed'
end
end
end
task :generate_xcode_dev do
# Prepare the test fixture project by importing the plugins
script = File.join("features", "scripts", "import_package.sh")
unless system script
raise 'import_package failed'
end
# Generate the Xcode project
cd "features" do
script = File.join("scripts", "generate_xcode_project.sh dev")
unless system script
raise 'generate_xcode_project_dev failed'
end
end
end
task :build_xcode do
# Build and archive from the Xcode project
cd "features" do
script = File.join("scripts", "build_ios.sh release")
unless system script
raise 'IPA build failed'
end
end
end
task :build_xcode_dev do
# Build and archive from the Xcode project
cd "features" do
script = File.join("scripts", "build_ios.sh dev")
unless system script
raise 'IPA build failed'
end
end
end
task build: %w[test:ios:generate_xcode test:ios:build_xcode] do
end
end
end