-
Notifications
You must be signed in to change notification settings - Fork 12
/
rakefile.rb
168 lines (131 loc) · 4.72 KB
/
rakefile.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
############################################################################
##
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation ([email protected])
##
## This file is part of Testability Driver Qt Agent
##
## If you have questions regarding the use of this file, please contact
## Nokia at [email protected] .
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License version 2.1 as published by the Free Software Foundation
## and appearing in the file LICENSE.LGPL included in the packaging
## of this file.
##
############################################################################
@__release_mode = ENV['rel_mode']
@__release_mode = 'minor' if @__release_mode == nil
# version information
def read_version
version = "0"
File.open(Dir.getwd << '/debian/changelog') do |file|
line = file.gets
arr = line.split(')')
arr = arr[0].split('(')
version = arr[1]
end
if(@__release_mode == 'release')
return version
else
return version + "~" + Time.now.strftime("%Y%m%d%H%M%S")
end
end
@__tas_revision = read_version
puts "version " << @__tas_revision
desc "Task for cruise control"
task :cruise => ['kill_qttasserver', 'build_qttas', 'start_qttasserver'] do
exit(0)
end
desc "Task for cruise control"
task :cruise_vs => ['kill_qttasserver', 'build_qttas_vs', 'start_qttasserver'] do
exit(0)
end
desc "Task for building the example QT application(s)"
task :build_qttas do
puts "#########################################################"
puts "### Building qttas ####"
puts "#########################################################"
# buid version file
#File.open('common/inc/version.h', 'w') { |f| f.write "static QString TAS_VERSION = \"#{@__tas_revision}\";" }
make = "make"
sudo = ""
if /win/ =~ RUBY_PLATFORM || /mingw32/ =~ RUBY_PLATFORM
make = "mingw32-make"
else
sudo = "echo \"testability\" | sudo -S "
end
cmd = sudo + " #{make} uninstall"
system(cmd)
cmd = "#{make} distclean"
system(cmd)
cmd = "qmake CONFIG+=release qt_testability.pro"
failure = system(cmd)
raise "qmake failed" if (failure != true) or ($? != 0)
cmd = "#{make}"
failure = system(cmd)
raise "make release failed" if (failure != true) or ($? != 0)
cmd = sudo + "#{make} install"
failure = system(cmd)
raise "make install failed" if (failure != true) or ($? != 0)
puts "qttas built"
end
desc "Task for building the example QT application(s)"
task :build_qttas_vs do
puts "#########################################################"
puts "### Building qttas ####"
puts "#########################################################"
# buid version file
#File.open('common/inc/version.h', 'w') { |f| f.write "static QString TAS_VERSION = \"#{@__tas_revision}\";" }
make = "nmake"
sudo = ""
cmd = sudo + " #{make} uninstall"
system(cmd)
cmd = "#{make} distclean"
system(cmd)
cmd = "qmake CONFIG+=release qt_testability.pro"
failure = system(cmd)
raise "qmake failed" if (failure != true) or ($? != 0)
cmd = "#{make}"
failure = system(cmd)
raise "make release failed" if (failure != true) or ($? != 0)
cmd = sudo + "#{make} install"
failure = system(cmd)
raise "make install failed" if (failure != true) or ($? != 0)
puts "qttas built"
end
desc "Task for shutting down the qttasserver"
task :kill_qttasserver do
puts "#########################################################"
puts "### Killing qttasserver ####"
puts "#########################################################"
if /win/ =~ RUBY_PLATFORM || /mingw32/ =~ RUBY_PLATFORM
cmd = "taskkill /F /IM qttasserver.exe"
stdOut = system(cmd)
else
cmd = "echo \"testability\" | sudo -S killall qttasserver"
stdOut = system(cmd)
end
puts "qttasserver killed"
end
desc "Task for starting the qttasserver"
task :start_qttasserver do
puts "#########################################################"
puts "### Starting qttasserver ####"
puts "#########################################################"
if /win/ =~ RUBY_PLATFORM || /mingw32/ =~ RUBY_PLATFORM
require 'win32ole'
begin
shell = WIN32OLE.new( 'Shell.Application' )
shell.ShellExecute( 'qttasserver.exe', '', 'f:\qttas\bin', '', 2)
rescue
raise "Qttasserver startup failed"
end
else
# directly calling "/usr/bin/qttasserver &" hangs, now disabled the stdin, out and err
result=`qttasserver </dev/null >/dev/null 2>&1 &`
end
puts "qttasserver started"
end