shell.py: Update to use cooker.buildFile()
authorRichard Purdie <rpurdie@linux.intel.com>
Tue, 26 Feb 2008 17:09:20 +0000 (17:09 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 26 Feb 2008 17:09:20 +0000 (17:09 +0000)
ChangeLog
lib/bb/cooker.py
lib/bb/shell.py

index f1f1a67..1bcd27e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ Changes in BitBake 1.8.x:
          the parsing loop and factoring some getVar calls outside a for loop
        - Cooker: Remove a debug message from the parsing loop to lower overhead
        - Convert build.py exec_task to use getVarFlags
+       - Update shell to use cooker.buildFile
 
 Changes in BitBake 1.8.10:
        - Psyco is available only for x86 - do not use it on other architectures.
index b51aabc..1d24261 100644 (file)
@@ -125,7 +125,6 @@ class BBCooker:
         build_depends is a list of previous build dependencies (not runtime)
         If build_depends is empty, we're dealing with a runtime depends
         """
-
         the_data = self.bb_cache.loadDataFull(fn, self.configuration.data)
 
         item = self.status.pkg_fn[fn]
@@ -184,6 +183,8 @@ class BBCooker:
             self.cb = None
             self.bb_cache = bb.cache.init(self)
             fn = self.matchFile(buildfile)
+            if not fn:
+                sys.exit(1)
         elif len(pkgs_to_build) == 1:
             self.updateCache()
 
@@ -220,7 +221,7 @@ class BBCooker:
         except Exception, e:
             bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
         # emit the metadata which isnt valid shell
-        data.expandKeys( envdata )     
+        data.expandKeys( envdata )
         for e in envdata.keys():
             if data.getVarFlag( e, 'python', envdata ):
                 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, envdata, 1)))
@@ -273,7 +274,7 @@ class BBCooker:
             if fnid not in seen_fnids:
                 seen_fnids.append(fnid)
                 packages = []
-                print >> depends_file, '"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn)             
+                print >> depends_file, '"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn)
                 for depend in self.status.deps[fn]:
                     print >> depends_file, '"%s" -> "%s"' % (pn, depend)
                 rdepends = self.status.rundeps[fn]
@@ -459,21 +460,24 @@ class BBCooker:
                 bb.msg.error(bb.msg.domain.Parsing, "Unable to match %s (%s matches found):" % (buildfile, len(matches)))
                 for f in matches:
                     bb.msg.error(bb.msg.domain.Parsing, "    %s" % f)
-                sys.exit(1)
-            return matches[0]              
+                return False
+            return matches[0]
 
     def buildFile(self, buildfile):
         """
         Build the file matching regexp buildfile
         """
 
-        bf = self.matchFile(buildfile)
+        # Make sure our target is a fully qualified filename
+        fn = self.matchFile(buildfile)
+        if not fn:
+            return False
 
-        bbfile_data = bb.parse.handle(bf, self.configuration.data)
+        bbfile_data = bb.parse.handle(fn, self.configuration.data)
 
         # Remove stamp for target if force mode active
         if self.configuration.force:
-            bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (self.configuration.cmd, bf))
+            bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (self.configuration.cmd, fn))
             bb.build.del_stamp('do_%s' % self.configuration.cmd, bbfile_data)
 
         item = bb.data.getVar('PN', bbfile_data, 1)
@@ -482,7 +486,7 @@ class BBCooker:
         except bb.build.EventException:
             bb.msg.error(bb.msg.domain.Build,  "Build of '%s' failed" % item )
 
-        sys.exit(0)
+        return True
 
     def buildTargets(self, targets):
         """
@@ -564,7 +568,9 @@ class BBCooker:
             self.interactiveMode()
 
         if self.configuration.buildfile is not None:
-            return self.buildFile(self.configuration.buildfile)
+            if not self.buildFile(self.configuration.buildfile):
+                sys.exit(1)
+            sys.exit(0)
 
         # initialise the parsing status now we know we will need deps
         self.updateCache()
index 745091f..feba3f2 100644 (file)
@@ -243,27 +243,13 @@ class BitBakeShellCommands:
         oldcmd = cooker.configuration.cmd
         cooker.configuration.cmd = cmd
 
-        thisdata = data.createCopy(cooker.configuration.data)
-        data.update_data(thisdata)
-        data.expandKeys(thisdata)
-
         try:
-            bbfile_data = parse.handle( bf, thisdata )
+            cooker.buildFile(bf)
         except parse.ParseError:
             print "ERROR: Unable to open or parse '%s'" % bf
-        else:
-            # Remove stamp for target if force mode active
-            if cooker.configuration.force:
-                bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (cmd, bf))
-                bb.build.del_stamp('do_%s' % cmd, bbfile_data)
-
-            item = data.getVar('PN', bbfile_data, 1)
-            data.setVar( "_task_cache", [], bbfile_data ) # force
-            try:
-                cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True )
-            except build.EventException, e:
-                print "ERROR: Couldn't build '%s'" % name
-                last_exception = e
+        except build.EventException, e:
+            print "ERROR: Couldn't build '%s'" % name
+            last_exception = e
 
         cooker.configuration.cmd = oldcmd
     fileBuild.usage = "<bbfile>"
@@ -586,6 +572,7 @@ SRC_URI = ""
 
 def completeFilePath( bbfile ):
     """Get the complete bbfile path"""
+    if not cooker.status: return bbfile
     if not cooker.status.pkg_fn: return bbfile
     for key in cooker.status.pkg_fn.keys():
         if key.endswith( bbfile ):