fix tests for resources. Add python dependency manipulation because it's understandable to humans. fix
authortimothy.murphy@nokia.com
Tue, 11 May 2010 13:33:47 +0100
branchfix
changeset 546 e6381a1f4952
parent 545 17733b82d643
child 547 9fe7d0ab0f8f
fix tests for resources. Add python dependency manipulation because it's understandable to humans.
sbsv2/raptor/bin/depcrunch.py
sbsv2/raptor/lib/config/locations.xml
sbsv2/raptor/lib/flm/base.xml
sbsv2/raptor/lib/flm/resource.flm
sbsv2/raptor/test/smoke_suite/gccxml.py
sbsv2/raptor/test/smoke_suite/resource.py
sbsv2/raptor/test/smoke_suite/whatlog_cache.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/bin/depcrunch.py	Tue May 11 13:33:47 2010 +0100
@@ -0,0 +1,101 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+# Minimise the dependencies in a C preprocessor dependency file to
+# those that CPP could not find.  Then add in an assumption about 
+# where to find them.  Output is assumed to be relevant to only one target
+# even if multiple dep files are analysed.
+#
+
+import sys
+from  optparse import OptionParser
+import os
+import re
+
+class NoTargetException(Exception):
+	pass
+
+def depcrunch(file,extensions,assume):
+	target_pattern = r"^\s*(\S+):\s+"
+	target_re = re.compile(target_pattern)
+	extension_pattern = "[ \t]([^\/\\ \t]+\.(" + "|".join(["("+ t + ")" for t in extensions]) + "))\\b"
+	extension_re = re.compile(extension_pattern)
+
+	target = None
+
+	deps = []
+
+	for l in file.xreadlines():
+		l = l.replace("\\","/").rstrip("\n\r")
+
+		if not target:
+			t = target_re.match(l)
+			if t:
+				target = t.groups()[0]
+		
+		m = extension_re.match(l)
+		if m:
+			deps.append(m.groups()[0])
+
+	if not target:
+		raise NoTargetException()
+
+	if len(deps) > 0:
+		print "%s: \\" % target
+		for d in deps[:-1]:
+			print " %s \\" % (assume + "/" + d)
+		print " %s " % (assume + "/" + deps[-1])
+
+
+
+
+## Command Line Interface ####################################################
+
+parser = OptionParser(prog = "depcrunch",
+	usage = "%prog [-h | options] [<depfile>]")
+
+parser.add_option("-e", "--extensions", 
+	 action="store", dest="extensions", type='string', help="comma separated list of file extensions of missing files to keep in the crunched dep file.") 
+
+parser.add_option("-a", "--assume", 
+	 action="store", dest="assume", type='string', help="when cpp reports missing dependencies, assume that they are in this directory") 
+
+(options, args) = parser.parse_args()
+
+
+if not options.extensions:
+	parser.error("you must specify a comma-separated list of file extensions with the -t option.")
+	sys.exit(1)
+
+if not options.assume:
+	parser.error("you must specify an 'assumed directory' for correcting missing dependencies with the -a option.")
+	sys.exit(1)
+
+depfilename="stdin"
+if len(args) > 0:
+	depfilename=args[0]
+	file = open(depfilename,"r")
+else:
+	file = sys.stdin
+try:
+	depcrunch(file,options.extensions.split(","), options.assume)
+except NoTargetException,e:
+	sys.stderr.write("Target name not found in dependency file");
+	sys.exit(2)
+	
+
+if file != sys.stdin:
+	file.close()
+
+sys.exit(0)
--- a/sbsv2/raptor/lib/config/locations.xml	Mon May 10 19:06:11 2010 +0100
+++ b/sbsv2/raptor/lib/config/locations.xml	Tue May 11 13:33:47 2010 +0100
@@ -109,6 +109,7 @@
 
 		<set name='BUILD_INCLUDE' value=''/>
 		<set name='CREATEVMAP' value='$(PYTHON) $(SBS_HOME)/bin/createvmap.py' type='script'/>
+		<set name='DEPCRUNCH' value='$(PYTHON) $(SBS_HOME)/bin/depcrunch.py' type='script'/>
 		<set name='CREATEVMAPCPP' value='$(SBS_BVCPP)' type='tool'/>
 		<set name='FEATURELISTFILES' value=''/>
 		<set name='FEATUREVARIANTNAME' value=''/>
--- a/sbsv2/raptor/lib/flm/base.xml	Mon May 10 19:06:11 2010 +0100
+++ b/sbsv2/raptor/lib/flm/base.xml	Tue May 11 13:33:47 2010 +0100
@@ -33,6 +33,8 @@
 		<param name='GNUSED'/>
 		<param name='GNUSORT'/>
 		<param name='SBS_JAVATC' default=''/>
+		<param name='PYTHON'/>
+		<param name='DEPCRUNCH'/>
 		<param name='ZIP'/>
 		<param name='UNZIP'/>
 		<param name='GNUMD5SUM'/>
--- a/sbsv2/raptor/lib/flm/resource.flm	Mon May 10 19:06:11 2010 +0100
+++ b/sbsv2/raptor/lib/flm/resource.flm	Tue May 11 13:33:47 2010 +0100
@@ -118,25 +118,7 @@
     # files etc.  In the end don't print anything at all if we did not find the target.
 
 define  DEPENDENCY_CORRECTOR
-{ set +x; $(GNUSED) -rn '\% ([^ /]+)\.((rsg)|(mbg))%I {y%\\\\%\\/%;p;}'  |  \
-    { \
-    ENDL='\\\\\n'; \
-    DEPTXT="$$$$RPP: $$$${ENDL}" ; \
-    DEPCOUNT=0; \
-    DEPS=''; read L; \
-    while [ $$$$? -eq 0 ]; do \
-        for i in $$$${L}; do \
-          if [[ ( "$$$${i%%.[Rr][Ss][Gg]}" != "$$$$i"  || "$$$${i%%.[Mm][Bb][Gg]}" != "$$$$i" ) && ( "$$$${i:1:1}" != ':' && "$$$${i:0:1}" != '/' ) ]];  then \
-            DEPTXT="$$$$DEPTXT \$$$$(EPOCROOT)/epoc32/include/$$$$i $$$${ENDL}"; \
-            (( DEPCOUNT += 1 )) ; \
-          fi; \
-        done; \
-      read L; \
-    done; \
-    if [ $$$$DEPCOUNT -ne 0 ]; then  \
-      echo -e "$$$${DEPTXT:0:$$$$[ $$$${#DEPTXT} - 4 ]}\n"; fi ;\
-  } ;\
-} 
+{ $(DEPCRUNCH) --extensions rsg,mbg --assume '$$$$(EPOCROOT)/epoc32/include' ; } 
 endef
 
 else
--- a/sbsv2/raptor/test/smoke_suite/gccxml.py	Mon May 10 19:06:11 2010 +0100
+++ b/sbsv2/raptor/test/smoke_suite/gccxml.py	Tue May 11 13:33:47 2010 +0100
@@ -34,7 +34,7 @@
 		"helloworld_exe/gccxml/HelloWorld.mmp.xml",
 		"helloworld_exe/helloworld_HelloWorld_sc.rpp.d",
 		"helloworld_exe/gccxml/HelloWorld.rss.rfi",
-		"helloworld_reg_exe/helloworld_reg_sc.rpp.d",
+		"helloworld_reg_exe/helloworld_reg_HelloWorld_reg_sc.rpp.d",
 		"helloworld_exe/gccxml/HelloWorld_reg.rss.rfi",
 		"helloworld_exe/gccxml/urel/HelloWorld_Application.xml.d",
 		"helloworld_exe/gccxml/urel/HelloWorld_Application.xml",
--- a/sbsv2/raptor/test/smoke_suite/resource.py	Mon May 10 19:06:11 2010 +0100
+++ b/sbsv2/raptor/test/smoke_suite/resource.py	Tue May 11 13:33:47 2010 +0100
@@ -82,7 +82,7 @@
 	t.mustnotmatch = []
 
 	t.mustmatch = [
-			"3 .*.dependentresource_.dependentresource_dependentresource_sc.rpp.d"
+			"[23] .*.dependentresource_.dependentresource_dependentresource_sc.rpp.d"
 		      ]
 
 	t.run()
--- a/sbsv2/raptor/test/smoke_suite/whatlog_cache.py	Mon May 10 19:06:11 2010 +0100
+++ b/sbsv2/raptor/test/smoke_suite/whatlog_cache.py	Tue May 11 13:33:47 2010 +0100
@@ -61,8 +61,8 @@
 		]
 	t.addbuildtargets('smoke_suite/test_resources/simple_gui/Bld.inf', [
 		"helloworld_exe/helloworld.mbm_bmconvcommands",
-		"helloworld_exe/helloworld_sc.rpp",
-		"helloworld_exe/helloworld_sc.rpp.d",
+		"helloworld_exe/helloworld_HelloWorld_sc.rpp",
+		"helloworld_exe/helloworld_HelloWorld_sc.rpp.d",
 		"helloworld_exe/armv5/udeb/HelloWorld_Application.o",
 		"helloworld_exe/armv5/udeb/HelloWorld_Application.o.d",
 		"helloworld_exe/armv5/udeb/HelloWorld_AppUi.o",
@@ -123,7 +123,7 @@
 		"helloworld_exe/winscw/urel/helloworld_UID_.dep",
 		"helloworld_exe/winscw/urel/helloworld_UID_.o",
 		"helloworld_exe/winscw/urel/helloworld_UID_.o.d",
-		"helloworld_reg_exe/helloworld_reg_sc.rpp.d"
+		"helloworld_reg_exe/helloworld_reg_HelloWorld_reg_sc.rpp.d"
 	])
 	t.countmatch = [
 		["\$self->{abldcache}->{.*\\\\test\\\\smoke_suite\\\\test_resources\\\\simple_gui target (armv5|winscw) (udeb|urel) -what\'} =", 4],