THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
-import os
+import os, sys
# The Module we will use here
import bb
return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" or fn[-5:] == ".conf"
def init(fn, data):
- if not data.getVar('TOPDIR'):
- bb.error('TOPDIR is not set')
- if not data.getVar('BBPATH'):
- bb.error('BBPATH is not set')
+ if not bb.data.getVar('TOPDIR', data):
+ bb.data.setVar('TOPDIR', os.getcwd(), data)
+ if not bb.data.getVar('BBPATH', data):
+ bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data)
def handle(fn, d, include):
- print ""
- print "fn: %s" % fn
- print "data: %s" % d
- print dir(d)
- print d.getVar.__doc__
- print "include: %s" % include
+ from bb import data, parse
+
+ #print ""
+ #print "fn: %s" % fn
+ #print "data: %s" % d
+ #print dir(d)
+ #print d.getVar.__doc__
+ #print "include: %s" % fn
+
+ # initialize with some data
+ init(fn,d)
# check if we include or are the beginning
if include:
- oldfile = d.getVar('FILE')
+ oldfile = d.getVar('FILE', False)
else:
- #d.inheritFromOS()
+ if fn[-5:] == ".conf":
+ data.inheritFromOS(d)
oldfile = None
# find the file
if not os.path.isabs(fn):
- bb.error("No Absolute FILE name")
- abs_fn = bb.which(d.getVar('BBPATH'), fn)
+ abs_fn = bb.which(d.getVar('BBPATH', True), fn)
else:
abs_fn = fn
# check if the file exists
if not os.path.exists(abs_fn):
- raise IOError("file '%(fn)' not found" % locals() )
+ raise IOError("file '%(fn)s' not found" % locals() )
# now we know the file is around mark it as dep
if include:
parse.mark_dependency(d, abs_fn)
# now parse this file - by defering it to C++
- parsefile(fn, d)
+ parsefile(abs_fn, d)
# restore the original FILE
if oldfile:
return d
+
+# Needed for BitBake files...
+__pkgsplit_cache__={}
+def vars_from_file(mypkg, d):
+ if not mypkg:
+ return (None, None, None)
+ if mypkg in __pkgsplit_cache__:
+ return __pkgsplit_cache__[mypkg]
+
+ myfile = os.path.splitext(os.path.basename(mypkg))
+ parts = myfile[0].split('_')
+ __pkgsplit_cache__[mypkg] = parts
+ exp = 3 - len(parts)
+ tmplist = []
+ while exp != 0:
+ exp -= 1
+ tmplist.append(None)
+ parts.extend(tmplist)
+ return parts
+
+
+
+
# Inform bitbake that we are a parser
# We need to define all three
from bb.parse import handlers