second attempt at pickling functions
authorPhil Blundell <philb@gnu.org>
Sun, 27 Jun 2004 19:16:07 +0000 (19:16 +0000)
committerPhil Blundell <philb@gnu.org>
Sun, 27 Jun 2004 19:16:07 +0000 (19:16 +0000)
bin/oe/make.py
bin/oe/parse/OEHandler.py

index 7cac3d3..21f5fd6 100644 (file)
@@ -111,15 +111,15 @@ def load_oefile( oefile ):
 def pickle_oe( oefile, oe ):
     p = pickle.Pickler( file( "%s/%s" % ( cache, oefile ), "wb" ), -1 )
     p.dump( oe )
-    funcstr = data.getVar('__functions', oe)
-    if funcstr:
-        funcs = funcstr.split()
-        for func in funcs:
-            p.dump(eval(func, globals()))
 
 def unpickle_oe( oefile ):
     p = pickle.Unpickler( file( "%s/%s" % ( cache, oefile ), "rb" ) )
-    return p.load()
+    oe = p.load()
+    funcstr = data.getVar('__functions__', oe)
+    if funcstr:
+        comp = compile(funcstr, "<pickled>", "exec")
+        exec comp in __builtins__
+    return oe
 
 def collect_oefiles( progressCallback ):
     """Collect all available .oe build files"""
index bee257c..5c1c7c7 100644 (file)
@@ -194,6 +194,8 @@ def feeder(lineno, s, fn, d):
             exec comp in __builtins__
             __body__ = []
             __inpython__ = False
+            funcs = data.getVar('__functions__', d) or ""
+            data.setVar('__functions__', "%s\n%s" % (funcs, text), d)
 #           fall through
 
     if s[0] == '#': return          # skip comments
@@ -219,9 +221,6 @@ def feeder(lineno, s, fn, d):
 
     m = __def_regexp__.match(s)
     if m:
-        funcname = m.group(1)
-        funcs = data.getVar('__functions', d) or ""
-        data.setVar('__functions', "%s %s" % (funcs, funcname), d)
         __body__.append(s)
         __inpython__ = True
         return