3
|
1 |
#
|
|
2 |
# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
# raptor_make module
|
|
16 |
# This module contains the classes that write and call Makefile wrappers.
|
|
17 |
#
|
|
18 |
|
|
19 |
import hashlib
|
|
20 |
import os
|
|
21 |
import random
|
|
22 |
import raptor
|
|
23 |
import raptor_utilities
|
|
24 |
import raptor_version
|
5
|
25 |
import raptor_data
|
3
|
26 |
import re
|
|
27 |
import subprocess
|
|
28 |
import time
|
|
29 |
from raptor_makefile import *
|
5
|
30 |
import raptor_version
|
|
31 |
import traceback
|
|
32 |
import sys
|
3
|
33 |
|
|
34 |
# raptor_make module classes
|
|
35 |
|
|
36 |
class MakeEngine(object):
|
|
37 |
|
|
38 |
def __init__(self, Raptor):
|
|
39 |
self.raptor = Raptor
|
|
40 |
self.valid = True
|
|
41 |
self.descrambler = None
|
|
42 |
self.descrambler_started = False
|
|
43 |
|
|
44 |
engine = Raptor.makeEngine
|
|
45 |
|
|
46 |
# look for an alias first as this gives end-users a chance to modify
|
|
47 |
# the shipped variant rather than completely replacing it.
|
|
48 |
if engine in Raptor.cache.aliases:
|
|
49 |
avar = Raptor.cache.FindNamedAlias(engine)
|
|
50 |
elif engine in Raptor.cache.variants:
|
|
51 |
avar = Raptor.cache.FindNamedVariant(engine)
|
|
52 |
else:
|
|
53 |
Raptor.Error("No settings found for build engine '%s'", engine)
|
|
54 |
return
|
|
55 |
|
|
56 |
# find the variant and extract the values
|
|
57 |
try:
|
5
|
58 |
units = avar.GenerateBuildUnits(Raptor.cache)
|
3
|
59 |
evaluator = Raptor.GetEvaluator( None, units[0] , gathertools=True)
|
|
60 |
|
|
61 |
# shell
|
|
62 |
self.shellpath = evaluator.Get("DEFAULT_SHELL")
|
|
63 |
usetalon_s = evaluator.Get("USE_TALON")
|
|
64 |
self.usetalon = usetalon_s is not None and usetalon_s != ""
|
|
65 |
self.talonshell = str(evaluator.Get("TALON_SHELL"))
|
|
66 |
self.talontimeout = str(evaluator.Get("TALON_TIMEOUT"))
|
|
67 |
self.talonretries = str(evaluator.Get("TALON_RETRIES"))
|
|
68 |
|
|
69 |
# commands
|
|
70 |
self.initCommand = evaluator.Get("initialise")
|
|
71 |
self.buildCommand = evaluator.Get("build")
|
|
72 |
self.shutdownCommand = evaluator.Get("shutdown")
|
|
73 |
|
|
74 |
# options
|
|
75 |
self.makefileOption = evaluator.Get("makefile")
|
|
76 |
self.keepGoingOption = evaluator.Get("keep_going")
|
|
77 |
self.jobsOption = evaluator.Get("jobs")
|
|
78 |
self.defaultMakeOptions = evaluator.Get("defaultoptions")
|
|
79 |
|
|
80 |
# buffering
|
|
81 |
self.scrambled = (evaluator.Get("scrambled") == "true")
|
|
82 |
|
|
83 |
# check tool versions
|
|
84 |
Raptor.CheckToolset(evaluator, avar.name)
|
|
85 |
|
|
86 |
# default targets (can vary per-invocation)
|
|
87 |
self.defaultTargets = Raptor.defaultTargets
|
|
88 |
|
|
89 |
# work out how to split up makefiles
|
|
90 |
try:
|
|
91 |
selectorNames = [ x.strip() for x in evaluator.Get("selectors").split(',') if x.strip() != "" ]
|
|
92 |
self.selectors = []
|
|
93 |
|
|
94 |
|
|
95 |
if len(selectorNames) > 0:
|
|
96 |
for name in selectorNames:
|
|
97 |
pattern = evaluator.Get(name.strip() + ".selector.iface")
|
|
98 |
target = evaluator.Get(name.strip() + ".selector.target")
|
|
99 |
ignoretargets = evaluator.Get(name.strip() + ".selector.ignoretargets")
|
|
100 |
self.selectors.append(MakefileSelector(name,pattern,target,ignoretargets))
|
|
101 |
except KeyError:
|
|
102 |
Raptor.Error("%s.selector.iface, %s.selector.target not found in make engine configuration", name, name)
|
|
103 |
self.selectors = []
|
|
104 |
|
|
105 |
except KeyError:
|
|
106 |
Raptor.Error("Bad '%s' configuration found.", engine)
|
|
107 |
self.valid = False
|
|
108 |
return
|
|
109 |
|
|
110 |
# there must at least be a build command...
|
|
111 |
if not self.buildCommand:
|
|
112 |
Raptor.Error("No build command for '%s'", engine)
|
|
113 |
self.valid = False
|
|
114 |
|
|
115 |
|
|
116 |
if self.usetalon:
|
|
117 |
talon_settings="""
|
|
118 |
TALON_SHELL:=%s
|
|
119 |
TALON_TIMEOUT:=%s
|
|
120 |
TALON_RECIPEATTRIBUTES:=\
|
|
121 |
name='$$RECIPE'\
|
|
122 |
target='$$TARGET'\
|
|
123 |
host='$$HOSTNAME'\
|
|
124 |
layer='$$COMPONENT_LAYER'\
|
|
125 |
component='$$COMPONENT_NAME'\
|
|
126 |
bldinf='$$COMPONENT_META' mmp='$$PROJECT_META'\
|
|
127 |
config='$$SBS_CONFIGURATION' platform='$$PLATFORM'\
|
5
|
128 |
phase='$$MAKEFILE_GROUP' source='$$SOURCE'
|
3
|
129 |
export TALON_RECIPEATTRIBUTES TALON_SHELL TALON_TIMEOUT
|
|
130 |
USE_TALON:=%s
|
|
131 |
|
|
132 |
""" % (self.talonshell, self.talontimeout, "1")
|
|
133 |
else:
|
|
134 |
talon_settings="""
|
|
135 |
USE_TALON:=
|
|
136 |
|
|
137 |
"""
|
|
138 |
|
|
139 |
|
|
140 |
self.makefile_prologue = """
|
|
141 |
# generated by %s %s
|
|
142 |
|
|
143 |
HOSTPLATFORM:=%s
|
|
144 |
HOSTPLATFORM_DIR:=%s
|
|
145 |
OSTYPE:=%s
|
|
146 |
FLMHOME:=%s
|
|
147 |
SHELL:=%s
|
|
148 |
|
|
149 |
%s
|
|
150 |
|
|
151 |
include %s
|
|
152 |
|
5
|
153 |
""" % ( raptor.name, raptor_version.fullversion(),
|
3
|
154 |
" ".join(raptor.hostplatform),
|
|
155 |
raptor.hostplatform_dir,
|
|
156 |
self.raptor.filesystem,
|
|
157 |
str(self.raptor.systemFLM),
|
|
158 |
self.shellpath,
|
|
159 |
talon_settings,
|
|
160 |
self.raptor.systemFLM.Append('globals.mk') )
|
|
161 |
|
|
162 |
|
|
163 |
self.makefile_epilogue = """
|
|
164 |
|
|
165 |
include %s
|
|
166 |
|
|
167 |
""" % (self.raptor.systemFLM.Append('final.mk') )
|
|
168 |
|
|
169 |
def Write(self, toplevel, specs, configs):
|
|
170 |
"""Generate a set of makefiles, or one big Makefile."""
|
|
171 |
|
|
172 |
if not self.valid:
|
5
|
173 |
return None
|
|
174 |
|
|
175 |
self.raptor.Debug("Writing Makefile '%s'" % (str(toplevel)))
|
3
|
176 |
|
|
177 |
self.toplevel = toplevel
|
|
178 |
|
|
179 |
# create the top-level makefiles
|
5
|
180 |
makefileset = None
|
3
|
181 |
|
|
182 |
try:
|
5
|
183 |
makefileset = MakefileSet(directory = str(toplevel.Dir()),
|
3
|
184 |
selectors = self.selectors,
|
|
185 |
filenamebase = str(toplevel.File()),
|
|
186 |
prologue = self.makefile_prologue,
|
|
187 |
epilogue = self.makefile_epilogue,
|
|
188 |
defaulttargets = self.defaultTargets)
|
|
189 |
|
|
190 |
# are we pruning duplicates?
|
|
191 |
self.prune = self.raptor.pruneDuplicateMakefiles
|
|
192 |
self.hashes = set()
|
|
193 |
|
|
194 |
# are we writing one Makefile or lots?
|
|
195 |
self.many = not self.raptor.writeSingleMakefile
|
|
196 |
|
|
197 |
# add a makefile for each spec under each config
|
5
|
198 |
config_makefileset = makefileset
|
3
|
199 |
for c in configs:
|
|
200 |
if self.many:
|
5
|
201 |
config_makefileset = makefileset.createChild(c.name)
|
3
|
202 |
|
|
203 |
# make sure the config_wide spec item is put out first so that it
|
|
204 |
# can affect everything.
|
|
205 |
ordered_specs=[]
|
|
206 |
config_wide_spec = None
|
|
207 |
for s in specs:
|
|
208 |
if s.name == "config_wide":
|
|
209 |
config_wide_spec = s
|
|
210 |
else:
|
|
211 |
ordered_specs.append(s)
|
|
212 |
|
|
213 |
if config_wide_spec is not None:
|
5
|
214 |
config_wide_spec.Configure(c, cache = self.raptor.cache)
|
3
|
215 |
self.WriteConfiguredSpec(config_makefileset, config_wide_spec, c, True)
|
|
216 |
|
|
217 |
for s in ordered_specs:
|
5
|
218 |
s.Configure(c, cache = self.raptor.cache)
|
3
|
219 |
self.WriteConfiguredSpec(config_makefileset, s, c, False)
|
|
220 |
|
5
|
221 |
makefileset.close()
|
3
|
222 |
except Exception,e:
|
5
|
223 |
tb = traceback.format_exc()
|
|
224 |
if not self.raptor.debugOutput:
|
|
225 |
tb=""
|
|
226 |
self.raptor.Error("Failed to write makefile '%s': %s : %s" % (str(toplevel),str(e),tb))
|
|
227 |
makefileset = None
|
|
228 |
|
|
229 |
return makefileset
|
3
|
230 |
|
|
231 |
|
|
232 |
def WriteConfiguredSpec(self, parentMakefileSet, spec, config, useAllInterfaces):
|
|
233 |
# ignore this spec if it is empty
|
|
234 |
hasInterface = spec.HasInterface()
|
|
235 |
childSpecs = spec.GetChildSpecs()
|
|
236 |
|
|
237 |
if not hasInterface and not childSpecs:
|
|
238 |
return
|
|
239 |
|
|
240 |
parameters = []
|
|
241 |
dupe = True
|
|
242 |
iface = None
|
|
243 |
guard = None
|
|
244 |
if hasInterface:
|
|
245 |
# find the Interface (it may be a ref)
|
5
|
246 |
try:
|
|
247 |
iface = spec.GetInterface(self.raptor.cache)
|
3
|
248 |
|
5
|
249 |
except raptor_data.MissingInterfaceError, e:
|
3
|
250 |
self.raptor.Error("No interface for '%s'", spec.name)
|
|
251 |
return
|
|
252 |
|
|
253 |
if iface.abstract:
|
|
254 |
self.raptor.Error("Abstract interface '%s' for '%s'",
|
|
255 |
iface.name, spec.name)
|
|
256 |
return
|
|
257 |
|
|
258 |
# we need to guard the FLM call with a hash based on all the
|
|
259 |
# parameter values so that duplicate calls cannot be made.
|
|
260 |
# So we need to find all the values before we can write
|
|
261 |
# anything out.
|
|
262 |
md5hash = hashlib.md5()
|
|
263 |
md5hash.update(iface.name)
|
|
264 |
|
|
265 |
# we need an Evaluator to get parameter values for this
|
|
266 |
# Specification in the context of this Configuration
|
|
267 |
evaluator = self.raptor.GetEvaluator(spec, config)
|
|
268 |
|
|
269 |
def addparam(k, value, default):
|
|
270 |
if value == None:
|
|
271 |
if p.default != None:
|
|
272 |
value = p.default
|
|
273 |
else:
|
|
274 |
self.raptor.Error("%s undefined for '%s'",
|
|
275 |
k, spec.name)
|
|
276 |
value = ""
|
|
277 |
|
|
278 |
parameters.append((k, value))
|
|
279 |
md5hash.update(value)
|
|
280 |
|
|
281 |
# parameters required by the interface
|
5
|
282 |
for p in iface.GetParams(self.raptor.cache):
|
3
|
283 |
val = evaluator.Resolve(p.name)
|
|
284 |
addparam(p.name,val,p.default)
|
|
285 |
|
|
286 |
# Use Patterns to fetch a group of parameters
|
5
|
287 |
for g in iface.GetParamGroups(self.raptor.cache):
|
3
|
288 |
for k,v in evaluator.ResolveMatching(g.patternre):
|
|
289 |
addparam(k,v,g.default)
|
|
290 |
|
|
291 |
hash = md5hash.hexdigest()
|
|
292 |
dupe = hash in self.hashes
|
|
293 |
|
|
294 |
self.hashes.add(hash)
|
|
295 |
|
|
296 |
# we only create a Makefile if we have a new FLM call to contribute,
|
|
297 |
# OR we are not pruning duplicates (guarding instead)
|
|
298 |
# OR we have some child specs that need something to include them.
|
|
299 |
if dupe and self.prune and not childSpecs:
|
|
300 |
return
|
|
301 |
|
|
302 |
makefileset = parentMakefileSet
|
|
303 |
# Create a new layer of makefiles?
|
|
304 |
if self.many:
|
|
305 |
makefileset = makefileset.createChild(spec.name)
|
|
306 |
|
|
307 |
if not (self.prune and dupe):
|
|
308 |
if self.prune:
|
|
309 |
guard = ""
|
|
310 |
else:
|
|
311 |
guard = "guard_" + hash
|
|
312 |
|
|
313 |
# generate the call to the FLM
|
|
314 |
if iface is not None:
|
5
|
315 |
makefileset.addCall(spec.name, config.name, iface.name, useAllInterfaces, iface.GetFLMIncludePath(self.raptor.cache), parameters, guard)
|
3
|
316 |
|
|
317 |
# recursive includes
|
|
318 |
|
|
319 |
for child in childSpecs:
|
|
320 |
self.WriteConfiguredSpec(makefileset, child, config, useAllInterfaces)
|
|
321 |
|
|
322 |
if self.many:
|
|
323 |
makefileset.close() # close child set of makefiles as we'll never see them again.
|
|
324 |
|
|
325 |
def Make(self, makefileset):
|
|
326 |
"run the make command"
|
|
327 |
|
|
328 |
if not self.valid:
|
|
329 |
return False
|
|
330 |
|
|
331 |
if self.usetalon:
|
|
332 |
# Always use Talon since it does the XML not
|
|
333 |
# just descrambling
|
|
334 |
if not self.StartTalon() and not self.raptor.keepGoing:
|
|
335 |
self.Tidy()
|
|
336 |
return False
|
|
337 |
else:
|
|
338 |
# use the descrambler if we are doing a parallel build on
|
|
339 |
# a make engine which does not buffer each agent's output
|
|
340 |
if self.raptor.jobs > 1 and self.scrambled:
|
|
341 |
self.StartDescrambler()
|
|
342 |
if not self.descrambler_started and not self.raptor.keepGoing:
|
|
343 |
self.Tidy()
|
|
344 |
return False
|
|
345 |
|
|
346 |
# run any initialisation script
|
|
347 |
if self.initCommand:
|
|
348 |
self.raptor.Info("Running %s", self.initCommand)
|
|
349 |
if os.system(self.initCommand) != 0:
|
|
350 |
self.raptor.Error("Failed in %s", self.initCommand)
|
|
351 |
self.Tidy()
|
|
352 |
return False
|
|
353 |
|
|
354 |
# Save file names to a list, to allow the order to be reversed
|
5
|
355 |
fileName_list = list(makefileset.makefileNames())
|
3
|
356 |
|
|
357 |
# Iterate through args passed to raptor, searching for CLEAN or REALLYCLEAN
|
|
358 |
clean_flag = False
|
|
359 |
for arg in self.raptor.args:
|
|
360 |
clean_flag = ("CLEAN" in self.raptor.args) or \
|
|
361 |
("REALLYCLEAN" in self.raptor.args)
|
|
362 |
|
|
363 |
# Files should be deleted in the opposite order to the order
|
|
364 |
# they were built. So reverse file order if cleaning
|
|
365 |
if clean_flag:
|
|
366 |
fileName_list.reverse()
|
|
367 |
|
|
368 |
# Process each file in turn
|
|
369 |
for makefile in fileName_list:
|
|
370 |
if not os.path.exists(makefile):
|
|
371 |
self.raptor.Info("Skipping makefile %s", makefile)
|
|
372 |
continue
|
|
373 |
self.raptor.Info("Making %s", makefile)
|
|
374 |
# assemble the build command line
|
|
375 |
command = self.buildCommand
|
|
376 |
|
|
377 |
if self.makefileOption:
|
|
378 |
command += " " + self.makefileOption + " " + '"' + str(makefile) + '"'
|
|
379 |
|
|
380 |
if self.raptor.keepGoing and self.keepGoingOption:
|
|
381 |
command += " " + self.keepGoingOption
|
|
382 |
|
|
383 |
if self.raptor.jobs > 1 and self.jobsOption:
|
|
384 |
command += " " + self.jobsOption +" "+ str(self.raptor.jobs)
|
|
385 |
|
|
386 |
# Set default options first so that they can be overridden by
|
|
387 |
# ones set by the --mo option on the raptor commandline:
|
|
388 |
command += " " + self.defaultMakeOptions
|
|
389 |
# Can supply options on the commandline to override default settings.
|
|
390 |
if len(self.raptor.makeOptions) > 0:
|
|
391 |
command += " " + " ".join(self.raptor.makeOptions)
|
|
392 |
|
|
393 |
# Switch off dependency file including?
|
|
394 |
if self.raptor.noDependInclude:
|
|
395 |
command += " NO_DEPEND_INCLUDE=1"
|
|
396 |
|
|
397 |
if self.usetalon:
|
|
398 |
# use the descrambler if we set it up
|
|
399 |
command += ' TALON_DESCRAMBLE='
|
|
400 |
if self.scrambled:
|
|
401 |
command += '1 '
|
|
402 |
else:
|
|
403 |
command += '0 '
|
|
404 |
else:
|
|
405 |
if self.descrambler_started:
|
|
406 |
command += ' DESCRAMBLE="' + self.descrambler + '"'
|
|
407 |
|
|
408 |
# use the retry mechanism if requested
|
|
409 |
if self.raptor.tries > 1:
|
|
410 |
command += ' RECIPETRIES=' + str(self.raptor.tries)
|
|
411 |
command += ' TALON_RETRIES=' + str(self.raptor.tries - 1)
|
|
412 |
|
|
413 |
# targets go at the end, if the makefile supports them
|
|
414 |
addTargets = self.raptor.targets[:]
|
5
|
415 |
ignoreTargets = makefileset.ignoreTargets(makefile)
|
3
|
416 |
if addTargets and ignoreTargets:
|
|
417 |
for target in self.raptor.targets:
|
|
418 |
if re.match(ignoreTargets, target):
|
|
419 |
addTargets.remove(target)
|
|
420 |
|
|
421 |
if addTargets:
|
|
422 |
command += " " + " ".join(addTargets)
|
|
423 |
|
5
|
424 |
# Substitute the makefile name for any occurrence of #MAKEFILE#
|
|
425 |
command = command.replace("#MAKEFILE#", str(makefile))
|
|
426 |
|
3
|
427 |
self.raptor.Info("Executing '%s'", command)
|
|
428 |
|
|
429 |
# execute the build.
|
|
430 |
# the actual call differs between Windows and Unix.
|
|
431 |
# bufsize=1 means "line buffered"
|
|
432 |
#
|
|
433 |
try:
|
|
434 |
makeenv=os.environ.copy()
|
|
435 |
if self.usetalon:
|
|
436 |
makeenv['TALON_RECIPEATTRIBUTES']="none"
|
|
437 |
makeenv['TALON_SHELL']=self.talonshell
|
|
438 |
makeenv['TALON_BUILDID']=str(self.buildID)
|
|
439 |
makeenv['TALON_TIMEOUT']=str(self.talontimeout)
|
|
440 |
if self.raptor.filesystem == "unix":
|
|
441 |
p = subprocess.Popen(command, bufsize=65535,
|
|
442 |
stdout=subprocess.PIPE,
|
|
443 |
stderr=subprocess.STDOUT,
|
|
444 |
close_fds=True, env=makeenv, shell=True)
|
|
445 |
else:
|
|
446 |
p = subprocess.Popen(command, bufsize=65535,
|
|
447 |
stdout=subprocess.PIPE,
|
|
448 |
stderr=subprocess.STDOUT,
|
|
449 |
universal_newlines=True, env=makeenv)
|
|
450 |
stream = p.stdout
|
|
451 |
|
|
452 |
|
|
453 |
line = " "
|
|
454 |
while line:
|
|
455 |
line = stream.readline()
|
|
456 |
self.raptor.out.write(line)
|
|
457 |
|
|
458 |
# should be done now
|
|
459 |
returncode = p.wait()
|
|
460 |
|
|
461 |
|
|
462 |
if returncode != 0 and not self.raptor.keepGoing:
|
|
463 |
self.Tidy()
|
|
464 |
return False
|
|
465 |
|
|
466 |
except Exception,e:
|
|
467 |
self.raptor.Error("Exception '%s' during '%s'", str(e), command)
|
|
468 |
self.Tidy()
|
|
469 |
return False
|
|
470 |
|
|
471 |
# run any shutdown script
|
|
472 |
if self.shutdownCommand != None and self.shutdownCommand != "":
|
|
473 |
self.raptor.Info("Running %s", self.shutdownCommand)
|
|
474 |
if os.system(self.shutdownCommand) != 0:
|
|
475 |
self.raptor.Error("Failed in %s", self.shutdownCommand)
|
|
476 |
self.Tidy()
|
|
477 |
return False
|
|
478 |
|
|
479 |
self.Tidy()
|
|
480 |
return True
|
|
481 |
|
|
482 |
def Tidy(self):
|
|
483 |
if self.usetalon:
|
|
484 |
self.StopTalon()
|
|
485 |
else:
|
|
486 |
"clean up after the make command"
|
|
487 |
self.StopDescrambler()
|
|
488 |
|
|
489 |
def StartTalon(self):
|
|
490 |
# the talon command
|
|
491 |
beginning = raptor.hostplatform_dir + "/bin"
|
|
492 |
if "win" in raptor.hostplatform:
|
|
493 |
end = ".exe"
|
|
494 |
else:
|
|
495 |
end = ""
|
|
496 |
|
|
497 |
self.talonctl = str(self.raptor.home.Append(beginning, "talonctl"+end))
|
|
498 |
|
|
499 |
# generate a unique build number
|
|
500 |
random.seed()
|
|
501 |
looking = True
|
|
502 |
tries = 0
|
|
503 |
while looking and tries < 100:
|
|
504 |
self.buildID = raptor.name + str(random.getrandbits(32))
|
|
505 |
|
|
506 |
command = self.talonctl + " start"
|
|
507 |
|
|
508 |
os.environ["TALON_BUILDID"] = self.buildID
|
|
509 |
self.raptor.Info("Running %s", command)
|
|
510 |
looking = (os.system(command) != 0)
|
|
511 |
tries += 1
|
|
512 |
if looking:
|
5
|
513 |
self.raptor.Error("Failed to initialise the talon shell for this build")
|
3
|
514 |
self.talonctl = ""
|
|
515 |
return False
|
|
516 |
|
|
517 |
return True
|
|
518 |
|
|
519 |
def StopTalon(self):
|
|
520 |
if self.talonctl:
|
|
521 |
command = self.talonctl + " stop"
|
|
522 |
self.talonctl = ""
|
|
523 |
|
|
524 |
self.raptor.Info("Running %s", command)
|
|
525 |
if os.system(command) != 0:
|
|
526 |
self.raptor.Error("Failed in %s", command)
|
|
527 |
return False
|
|
528 |
|
|
529 |
return True
|
|
530 |
|
|
531 |
def StartDescrambler(self):
|
|
532 |
# the descrambler command
|
|
533 |
beginning = raptor.hostplatform_dir + "/bin"
|
|
534 |
if "win" in raptor.hostplatform:
|
|
535 |
end = ".exe"
|
|
536 |
else:
|
|
537 |
end = ""
|
|
538 |
|
|
539 |
self.descrambler = str(self.raptor.home.Append(beginning, "sbs_descramble"+end))
|
|
540 |
|
|
541 |
# generate a unique build number
|
|
542 |
random.seed()
|
|
543 |
looking = True
|
|
544 |
tries = 0
|
|
545 |
while looking and tries < 100:
|
|
546 |
buildID = raptor.name + str(random.getrandbits(32))
|
|
547 |
|
|
548 |
command = self.descrambler + " " + buildID + " start"
|
|
549 |
self.raptor.Info("Running %s", command)
|
|
550 |
looking = (os.system(command) != 0)
|
|
551 |
tries += 1
|
|
552 |
|
|
553 |
if looking:
|
|
554 |
self.raptor.Error("Failed to start the log descrambler")
|
|
555 |
self.descrambler_started = True
|
|
556 |
return False
|
|
557 |
|
|
558 |
self.descrambler_started = True
|
|
559 |
self.descrambler += " " + buildID
|
|
560 |
|
|
561 |
return True
|
|
562 |
|
|
563 |
def StopDescrambler(self):
|
|
564 |
if self.descrambler_started:
|
|
565 |
command = self.descrambler + " stop"
|
|
566 |
self.descrambler = ""
|
|
567 |
|
|
568 |
self.raptor.Info("Running %s", command)
|
|
569 |
if os.system(command) != 0:
|
|
570 |
self.raptor.Error("Failed in %s", command)
|
|
571 |
return False
|
|
572 |
return True
|
|
573 |
|
|
574 |
# raptor_make module functions
|
|
575 |
|
|
576 |
|
|
577 |
# end of the raptor_make module
|