blob: 6dc53f38057fa3f9348f641b7a691bc8e6cca098 (
plain)
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
|
require 'rspec/core/rake_task'
require_relative 'lib/ruby2d/colorize'
require_relative 'lib/ruby2d/version'
def get_args
ARGV.each { |a| task a.to_sym do ; end }
end
def print_task(task)
print "\n", "==> ".info, task.bold, "\n\n"
end
def run_cmd(cmd)
puts "==> #{cmd}\n"
system cmd
end
def run_int_test(file)
print_task "Running interpreted test: #{file}.rb"
run_cmd "( cd test/ && ruby -w #{file}.rb )"
end
def run_native_test(file)
print_task "Running native test: #{file}.rb"
run_cmd "ruby2d build --clean"
run_cmd "ruby2d build --native test/#{file}.rb --debug"
run_cmd "( cd test/ && ../build/app )"
end
def run_web_test(file)
print_task "Running web test: #{file}.rb"
run_cmd "ruby2d build --clean"
run_cmd "ruby2d build --web test/#{file}.rb --debug"
return # temporarily disable
open_cmd = 'open'
case RUBY_PLATFORM
when /linux/
open_cmd = "xdg-#{open_cmd}"
when /mingw/
open_cmd = "start"
end
Thread.new do
sleep 2
run_cmd "#{open_cmd} http://localhost:4001/build/app.html"
end
run_cmd "ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port => 4001, :DocumentRoot => Dir.pwd).start'"
end
def run_apple_test(device)
run_cmd "ruby2d build --clean"
run_cmd "ruby2d build --#{device} test/triangle-ios-tvos.rb --debug"
run_cmd "ruby2d launch --#{device}"
end
# Tasks
task default: 'all'
desc "Uninstall gem"
task :uninstall do
print_task "Uninstalling"
run_cmd "gem uninstall ruby2d --executables"
end
desc "Build gem"
task :build do
print_task "Building"
run_cmd "gem build ruby2d.gemspec --verbose"
end
desc "Install gem"
task :install do
print_task "Installing"
run_cmd "gem install ruby2d-#{Ruby2D::VERSION}.gem --local --verbose"
end
desc "Update submodules"
task :update do
run_cmd "git submodule update --remote"
end
desc "Run the RSpec tests"
RSpec::Core::RakeTask.new do |t|
print_task "Running RSpec"
t.pattern = "test/*spec.rb"
end
namespace :test do
desc "Run interpreted test"
task :int do
get_args
run_int_test ARGV[1]
end
desc "Run native test"
task :native do
get_args
run_native_test ARGV[1]
end
desc "Run web test"
task :web do
get_args
run_web_test ARGV[1]
end
desc "Run iOS test"
task :ios do
print_task "Running iOS test"
run_apple_test('ios')
end
desc "Run tvOS test"
task :tvos do
print_task "Running tvOS test"
run_apple_test('tvos')
end
end
desc "Uninstall, build, install, and test"
task :all do
Rake::Task['uninstall'].invoke
Rake::Task['build'].invoke
Rake::Task['install'].invoke
Rake::Task['spec'].invoke
end
|