# HG changeset patch # User Richard Taylor # Date 1272469604 -3600 # Node ID cad3b96a4fb11cfd442201634c4e24ac0111b355 # Parent 564986768b79fe6e1834a35f0ba3bfda1e3866cf refactoring for --query diff -r 564986768b79 -r cad3b96a4fb1 sbsv2/raptor/lib/config/gcc.xml --- a/sbsv2/raptor/lib/config/gcc.xml Tue Apr 27 16:46:48 2010 +0100 +++ b/sbsv2/raptor/lib/config/gcc.xml Wed Apr 28 16:46:44 2010 +0100 @@ -77,7 +77,7 @@ - + @@ -85,8 +85,9 @@ - - + + + @@ -94,10 +95,11 @@ - + + - - + + diff -r 564986768b79 -r cad3b96a4fb1 sbsv2/raptor/lib/config/winscw.xml --- a/sbsv2/raptor/lib/config/winscw.xml Tue Apr 27 16:46:48 2010 +0100 +++ b/sbsv2/raptor/lib/config/winscw.xml Wed Apr 28 16:46:44 2010 +0100 @@ -127,7 +127,7 @@ - + @@ -135,17 +135,19 @@ - - + + + - + + - - + + diff -r 564986768b79 -r cad3b96a4fb1 sbsv2/raptor/python/raptor_api.py --- a/sbsv2/raptor/python/raptor_api.py Tue Apr 27 16:46:48 2010 +0100 +++ b/sbsv2/raptor/python/raptor_api.py Wed Apr 28 16:46:44 2010 +0100 @@ -23,25 +23,41 @@ """object to return values from API calls. """ def __init__(self, text=""): - self.reply_text = text + self.text = text def __str__(self): name = type(self).__name__.lower() - str = "<" + name - end = "/>\n" + string = "<" + name + children = [] + longend = False for attribute,value in self.__dict__.items(): - if attribute != "reply_text": - str += " %s='%s'" % (attribute, value) + if attribute != "text": + if isinstance(value, Reply): + children.append(value) + else: + string += " %s='%s'" % (attribute, value) + + if children or self.text: + string += ">" + longend = True + + if self.text: + string += self.text - if self.reply_text: - str += ">" + self.reply_text - end = "\n" % name + if children: + string += "\n" + + for c in children: + string += str(c) - str += end + if longend: + string += "\n" % name + else: + string += "/>\n" - return str + return string class Alias(Reply): pass @@ -125,38 +141,59 @@ dot-separated list of variants. For example "armv5_urel" or "armv5_urel.savespace.vasco". """ - - r = Config() - names = name.split(".") if names[0] in self.__raptor.cache.aliases: x = self.__raptor.cache.FindNamedAlias(names[0]) if len(names) > 1: - r.fullname = x.meaning + "." + ".".join(names[1:]) + fullname = x.meaning + "." + ".".join(names[1:]) else: - r.fullname = x.meaning + fullname = x.meaning elif names[0] in self.__raptor.cache.variants: - r.fullname = name + fullname = name else: raise BadQuery("'%s' is not an alias or a variant" % names[0]) + # create an evaluator for the named configuration tmp = raptor_data.Alias("tmp") - tmp.SetProperty("meaning", r.fullname) + tmp.SetProperty("meaning", fullname) units = tmp.GenerateBuildUnits(self.__raptor.cache) evaluator = self.__raptor.GetEvaluator(None, units[0]) + # get the outputpath + # this is messy as some configs construct the path inside the FLM + # rather than talking it from the XML: usually because of some + # conditional logic... but maybe some refactoring could avoid that. releasepath = evaluator.Get("RELEASEPATH") - fullvariantpath = evaluator.Get("FULLVARIANTPATH") + if not releasepath: + raise BadQuery("could not get RELEASEPATH for config '%s'" % name) + + variantplatform = evaluator.Get("VARIANTPLATFORM") + varianttype = evaluator.Get("VARIANTTYPE") + featurevariantname = evaluator.Get("FEATUREVARIANTNAME") + + platform = evaluator.Get("TRADITIONAL_PLATFORM") - if releasepath and fullvariantpath: - r.outputpath = str(generic_path.Join(releasepath, fullvariantpath)) + if platform == "TOOLS2": + outputpath = releasepath.replace("$(TOOLPLATFORMDIR)", "") else: - raise BadQuery("could not get outputpath for config '%s'" % name) + if not variantplatform: + raise BadQuery("could not get VARIANTPLATFORM for config '%s'" % name) + + if featurevariantname: + variantplatform += featurevariantname + + if not varianttype: + raise BadQuery("could not get VARIANTTYPE for config '%s'" % name) + + outputpath = str(generic_path.Join(releasepath, variantplatform, varianttype)) + r = Config() + r.fullname = fullname + r.outputpath = outputpath return r def GetProducts(self): diff -r 564986768b79 -r cad3b96a4fb1 sbsv2/raptor/test/config/api.xml --- a/sbsv2/raptor/test/config/api.xml Tue Apr 27 16:46:48 2010 +0100 +++ b/sbsv2/raptor/test/config/api.xml Wed Apr 28 16:46:44 2010 +0100 @@ -18,7 +18,8 @@ - + + diff -r 564986768b79 -r cad3b96a4fb1 sbsv2/raptor/test/smoke_suite/query_cli.py --- a/sbsv2/raptor/test/smoke_suite/query_cli.py Tue Apr 27 16:46:48 2010 +0100 +++ b/sbsv2/raptor/test/smoke_suite/query_cli.py Wed Apr 28 16:46:44 2010 +0100 @@ -65,6 +65,28 @@ t.mustnotmatch_singleline = [] t.run() + t.name = "query_cli_config_bv" + t.command = "sbs --query=config[armv5_urel.test_bv_1] --configpath=test/smoke_suite/test_resources/bv" + t.mustmatch_singleline = [ + "", + "fullname='arm\.v5\.urel\.rvct._.\.test_bv_1'", + "outputpath='.*/epoc32/release/armv5.one/urel'", + "" + ] + t.mustnotmatch_singleline = [] + t.run() + + t.name = "query_cli_config_others" + t.command = "sbs --query=config[winscw_urel] --query=config[tools2_rel]" + t.mustmatch_singleline = [ + "", + "outputpath='.*/epoc32/release/winscw/urel'", + "outputpath='.*/epoc32/release/tools2/rel'", + "" + ] + t.mustnotmatch_singleline = [] + t.run() + t.name = "query_cli_bad" t.command = "sbs --query=nonsense" t.mustmatch_singleline = [