31 import traceback |
31 import traceback |
32 import sys |
32 import sys |
33 from xml.sax.saxutils import escape |
33 from xml.sax.saxutils import escape |
34 |
34 |
35 |
35 |
|
36 class BadMakeEngineException(Exception): |
|
37 pass |
|
38 |
36 # raptor_make module classes |
39 # raptor_make module classes |
37 |
40 |
38 class MakeEngine(object): |
41 class MakeEngine(object): |
39 |
42 |
40 def __init__(self, Raptor): |
43 def __init__(self, Raptor, engine="make_engine"): |
41 self.raptor = Raptor |
44 self.raptor = Raptor |
42 self.valid = True |
45 self.valid = True |
43 self.descrambler = None |
46 self.descrambler = None |
44 self.descrambler_started = False |
47 self.descrambler_started = False |
45 |
48 |
46 engine = Raptor.makeEngine |
|
47 |
|
48 # look for an alias first as this gives end-users a chance to modify |
49 # look for an alias first as this gives end-users a chance to modify |
49 # the shipped variant rather than completely replacing it. |
50 # the shipped variant rather than completely replacing it. |
50 if engine in Raptor.cache.aliases: |
51 if engine in Raptor.cache.aliases: |
51 avar = Raptor.cache.FindNamedAlias(engine) |
52 avar = Raptor.cache.FindNamedAlias(engine) |
52 elif engine in Raptor.cache.variants: |
53 elif engine in Raptor.cache.variants: |
53 avar = Raptor.cache.FindNamedVariant(engine) |
54 avar = Raptor.cache.FindNamedVariant(engine) |
54 else: |
55 else: |
55 Raptor.Error("No settings found for build engine '%s'", engine) |
56 raise BadMakeEngineException("'%s' does not appear to be a make engine - no settings found for it" % engine) |
56 return |
57 |
|
58 if not avar.isDerivedFrom("make_engine", Raptor.cache): |
|
59 raise BadMakeEngineException("'%s' is not a build engine (it's a variant but it does not extend 'make_engine')" % engine) |
57 |
60 |
58 # find the variant and extract the values |
61 # find the variant and extract the values |
59 try: |
62 try: |
60 units = avar.GenerateBuildUnits(Raptor.cache) |
63 units = avar.GenerateBuildUnits(Raptor.cache) |
61 evaluator = Raptor.GetEvaluator( None, units[0] , gathertools=True) |
64 evaluator = Raptor.GetEvaluator( None, units[0] , gathertools=True) |
103 except KeyError: |
106 except KeyError: |
104 Raptor.Error("%s.selector.iface, %s.selector.target not found in make engine configuration", name, name) |
107 Raptor.Error("%s.selector.iface, %s.selector.target not found in make engine configuration", name, name) |
105 self.selectors = [] |
108 self.selectors = [] |
106 |
109 |
107 except KeyError: |
110 except KeyError: |
108 Raptor.Error("Bad '%s' configuration found.", engine) |
|
109 self.valid = False |
111 self.valid = False |
110 return |
112 raise BadMakeEngineException("Bad '%s' configuration found." % engine) |
111 |
113 |
112 # there must at least be a build command... |
114 # there must at least be a build command... |
113 if not self.buildCommand: |
115 if not self.buildCommand: |
114 Raptor.Error("No build command for '%s'", engine) |
116 self.valid = False |
115 self.valid = False |
117 raise BadMakeEngineException("No build command for '%s'"% engine) |
116 |
118 |
117 |
119 |
118 if self.usetalon: |
120 if self.usetalon: |
119 talon_settings=""" |
121 talon_settings=""" |
120 TALON_SHELL:=%s |
122 TALON_SHELL:=%s |
513 stderr=subprocess.STDOUT, |
515 stderr=subprocess.STDOUT, |
514 shell = False, |
516 shell = False, |
515 universal_newlines=True, env=makeenv) |
517 universal_newlines=True, env=makeenv) |
516 stream = p.stdout |
518 stream = p.stdout |
517 |
519 |
518 |
520 inRecipe = False |
519 line = " " |
521 line = " " |
520 while line: |
522 while line: |
521 line = stream.readline() |
523 line = stream.readline() |
522 self.raptor.out.write(line) |
524 |
523 |
525 if line.startswith("<recipe"): |
|
526 inRecipe = True |
|
527 elif line.startswith("</recipe"): |
|
528 inRecipe = False |
|
529 |
|
530 # unless we are inside a "recipe", any line not starting |
|
531 # with "<" is free text that must be escaped. |
|
532 if inRecipe or line.startswith("<"): |
|
533 self.raptor.out.write(line) |
|
534 else: |
|
535 self.raptor.out.write(escape(line)) |
524 |
536 |
525 # should be done now |
537 # should be done now |
526 returncode = p.wait() |
538 returncode = p.wait() |
527 |
539 |
528 # Report end-time of the build |
540 # Report end-time of the build |