45 import traceback |
45 import traceback |
46 import pluginbox |
46 import pluginbox |
47 from xml.sax.saxutils import escape |
47 from xml.sax.saxutils import escape |
48 |
48 |
49 |
49 |
50 if not "HOSTPLATFORM" in os.environ or not "HOSTPLATFORM_DIR" in os.environ: |
50 if not "HOSTPLATFORM" in os.environ or not "HOSTPLATFORM_DIR" in os.environ or not "HOSTPLATFORM32_DIR" in os.environ: |
51 print "Error: HOSTPLATFORM and HOSTPLATFORM_DIR must be set in the environment (this is usually done automatically by the startup script)." |
51 print "Error: HOSTPLATFORM, HOSTPLATFORM_DIR and HOSTPLATFORM32_DIR must be set in the environment (this is usually done automatically by the startup script)." |
52 sys.exit(1) |
52 sys.exit(1) |
53 |
53 |
54 hostplatform = os.environ["HOSTPLATFORM"].split(" ") |
54 hostplatform = os.environ["HOSTPLATFORM"].split(" ") |
55 hostplatform_dir = os.environ["HOSTPLATFORM_DIR"] |
55 hostplatform_dir = os.environ["HOSTPLATFORM_DIR"] |
|
56 hostplatform32_dir = os.environ["HOSTPLATFORM32_DIR"] |
56 |
57 |
57 # defaults can use EPOCROOT |
58 # defaults can use EPOCROOT |
58 |
59 |
59 if "EPOCROOT" in os.environ: |
60 if "EPOCROOT" in os.environ: |
60 incoming_epocroot = os.environ["EPOCROOT"] |
61 incoming_epocroot = os.environ["EPOCROOT"] |
236 # to be able to simulate the overall recursive unfurling of a build. |
237 # to be able to simulate the overall recursive unfurling of a build. |
237 |
238 |
238 class Component(ModelNode): |
239 class Component(ModelNode): |
239 """A group of projects or, in symbian-speak, a bld.inf. |
240 """A group of projects or, in symbian-speak, a bld.inf. |
240 """ |
241 """ |
241 def __init__(self, filename, layername="", componentname=""): |
242 def __init__(self, filename, layername="commandline", componentname=""): |
242 super(Component,self).__init__(filename) |
243 super(Component,self).__init__(filename) |
243 # Assume that components are specified in bld.inf files for now |
244 # Assume that components are specified in bld.inf files for now |
244 # One day that tyranny might end. |
245 # One day that tyranny might end. |
245 self.bldinf = None # Slot for a bldinf object if we spot one later |
246 self.bldinf = None # Slot for a bldinf object if we spot one later |
246 self.bldinf_filename = generic_path.Path.Absolute(filename) |
247 self.bldinf_filename = generic_path.Path.Absolute(filename) |
361 component_blocks.pop() |
362 component_blocks.pop() |
362 number_blocks -= 1 |
363 number_blocks -= 1 |
363 |
364 |
364 build.Info("Parallel Parsing: bld.infs split into %d blocks\n", number_blocks) |
365 build.Info("Parallel Parsing: bld.infs split into %d blocks\n", number_blocks) |
365 # Cause the binding makefiles to have the toplevel makefile's |
366 # Cause the binding makefiles to have the toplevel makefile's |
366 # name. The bindee's have __pp appended. |
367 # name. The bindee's have _pp appended. |
367 tm = build.topMakefile.Absolute() |
368 tm = build.topMakefile.Absolute() |
368 binding_makefiles = raptor_makefile.MakefileSet(str(tm.Dir()), build.maker.selectors, makefiles=None, filenamebase=str(tm.File())) |
369 binding_makefiles = raptor_makefile.MakefileSet(str(tm.Dir()), build.maker.selectors, makefiles=None, filenamebase=str(tm.File())) |
369 build.topMakefile = generic_path.Path(str(build.topMakefile) + "_pp") |
370 build.topMakefile = generic_path.Path(str(build.topMakefile) + "_pp") |
370 |
371 |
371 loop_number = 0 |
372 loop_number = 0 |
372 for block in component_blocks: |
373 for block in component_blocks: |
373 loop_number += 1 |
374 loop_number += 1 |
374 specNode = raptor_data.Specification("metadata_" + self.name) |
375 specNode = raptor_data.Specification("metadata_" + self.name) |
375 |
376 |
376 componentList = " ".join([str(c.bldinf_filename) for c in block]) |
377 # root path for generated sysdef files and their partnering makefiles |
377 |
|
378 |
|
379 configList = " ".join([c.name for c in self.configs if c.name != "build" ]) |
|
380 |
|
381 makefile_path = str(build.topMakefile) + "_" + str(loop_number) |
378 makefile_path = str(build.topMakefile) + "_" + str(loop_number) |
|
379 |
382 try: |
380 try: |
383 os.unlink(makefile_path) # until we have dependencies working properly |
381 os.unlink(makefile_path) # until we have dependencies working properly |
384 except Exception: |
382 except Exception: |
385 pass |
383 pass |
|
384 |
|
385 pp_system_definition = makefile_path + ".sysdef.xml" |
|
386 |
|
387 try: |
|
388 sys_def_writer = raptor_xml.SystemModel(build, aDoRead=False) |
|
389 for component in block: |
|
390 sys_def_writer.AddComponent(component) |
|
391 sys_def_writer.Write(pp_system_definition) |
|
392 build.Debug("Wrote intermediate parallel-parsing system definition file " + pp_system_definition) |
|
393 except Exception as e: |
|
394 build.Error("Failed to write intermediate parallel-parsing system definition file " + pp_system_definition) |
|
395 raise |
|
396 |
|
397 |
|
398 configList = " ".join([c.name for c in self.configs if c.name != "build" ]) |
|
399 |
386 |
400 |
387 # add some basic data in a component-wide variant |
401 # add some basic data in a component-wide variant |
388 var = raptor_data.Variant() |
402 var = raptor_data.Variant() |
389 var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList)) |
403 var.AddOperation(raptor_data.Set("PP_SYSTEM_DEFINITION", pp_system_definition)) |
390 var.AddOperation(raptor_data.Set("MAKEFILE_PATH", makefile_path)) |
404 var.AddOperation(raptor_data.Set("MAKEFILE_PATH", makefile_path)) |
391 var.AddOperation(raptor_data.Set("CONFIGS", configList)) |
405 var.AddOperation(raptor_data.Set("CONFIGS", configList)) |
392 var.AddOperation(raptor_data.Set("CLI_OPTIONS", cli_options)) |
406 var.AddOperation(raptor_data.Set("CLI_OPTIONS", cli_options)) |
393 |
407 |
394 |
408 |
710 self.Warn(" parallel parsing option must be either 'on' or 'off' (was %s)" % type) |
725 self.Warn(" parallel parsing option must be either 'on' or 'off' (was %s)" % type) |
711 return False |
726 return False |
712 |
727 |
713 return True |
728 return True |
714 |
729 |
|
730 def SetRsgCaseFolding(self, TrueOrFalse): |
|
731 self.doCaseFolding_rsg = TrueOrFalse |
|
732 return True |
|
733 |
715 def AddProject(self, projectName): |
734 def AddProject(self, projectName): |
716 self.projects.add(projectName.lower()) |
735 self.projects.add(projectName.lower()) |
717 return True |
736 return True |
718 |
737 |
719 def AddQuery(self, q): |
738 def AddQuery(self, q): |
903 else: |
922 else: |
904 return True |
923 return True |
905 |
924 |
906 return self.toolset.check(evaluator, configname) |
925 return self.toolset.check(evaluator, configname) |
907 |
926 |
908 |
|
909 def CheckConfigs(self, configs): |
927 def CheckConfigs(self, configs): |
910 """ Tool checking for all the buildable configurations |
928 """ Tool checking for all the buildable configurations |
911 NB. We are allowed to use different tool versions for different |
929 NB. We are allowed to use different tool versions for different |
912 configurations.""" |
930 configurations.""" |
913 |
931 |
914 tools_ok = True |
932 tools_ok = True |
|
933 tool_problems = [] |
915 for b in configs: |
934 for b in configs: |
916 self.Debug("Tool check for %s", b.name) |
935 self.Debug("Tool check for %s", b.name) |
917 evaluator = self.GetEvaluator(None, b, gathertools=True) |
936 config_ok = False #default |
918 tools_ok = tools_ok and self.CheckToolset(evaluator, b.name) |
937 try: |
|
938 evaluator = self.GetEvaluator(None, b, gathertools=True) |
|
939 config_ok = self.CheckToolset(evaluator, b.name) |
|
940 except raptor_data.UninitialisedVariableException,e: |
|
941 tool_problems.append(b.name) |
|
942 self.Error("{0} is a bad configuration: {1}".format(b.name,str(e))) |
|
943 |
|
944 tools_ok = tools_ok and config_ok |
|
945 |
|
946 if len(tool_problems) > 0: |
|
947 self.FatalError("Build stopped because the following requested configurations are incomplete or invalid: {0}".format(", ".join(tool_problems))) |
919 |
948 |
920 return tools_ok |
949 return tools_ok |
921 |
|
922 |
|
923 |
950 |
924 def GatherSysModelLayers(self, systemModel, systemDefinitionRequestedLayers): |
951 def GatherSysModelLayers(self, systemModel, systemDefinitionRequestedLayers): |
925 """Return a list of lists of components to be built. |
952 """Return a list of lists of components to be built. |
926 |
953 |
927 components = GatherSysModelLayers(self, configurations) |
954 components = GatherSysModelLayers(self, configurations) |