3 OpenEmbedded 'Make' implementations
5 Functions for reading OE files, building a dependency graph and
6 building a set of OE files while walking along the dependency graph.
8 This file is part of the OpenEmbedded (http://openembedded.org) build infrastructure.
11 from oe import debug, digraph, data, fetch, fatal, error, note, event, parse
12 import copy, oe, re, sys, os, glob
14 # These variables are allowed to be reinitialized by client code
19 ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
21 def get_oefiles( path = os.getcwd() ):
22 """Get list of default .oe files by reading out the current directory"""
23 contents = os.listdir(path)
26 (root, ext) = os.path.splitext(f)
28 oefiles.append(os.path.abspath(os.path.join(os.getcwd(),f)))
31 def find_oefiles( path ):
32 """Find all the .oe files in a directory (uses find)"""
33 findcmd = 'find ' + path + ' -name *.oe | grep -v SCCS/'
35 finddata = os.popen(findcmd)
38 return finddata.readlines()
40 def load_oefile( oefile ):
41 """Load and parse one .oe build file"""
42 oepath = data.getVar('OEPATH', cfg)
43 topdir = data.getVar('TOPDIR', cfg)
45 topdir = os.path.abspath(os.getcwd())
47 data.setVar('TOPDIR', topdir, cfg)
48 oefile = os.path.abspath(oefile)
49 oefile_loc = os.path.abspath(os.path.dirname(oefile))
50 # expand tmpdir to include this topdir
51 data.setVar('TMPDIR', data.getVar('TMPDIR', cfg, 1) or "", cfg)
52 # add topdir to oepath
53 oepath += ":%s" % topdir
54 # set topdir to location of .oe file
56 #data.setVar('TOPDIR', topdir, cfg)
57 # add that topdir to oepath
58 oepath += ":%s" % topdir
60 oldpath = os.path.abspath(os.getcwd())
62 data.setVar('OEPATH', oepath, cfg)
63 oe = copy.deepcopy(cfg)
65 parse.handle(oefile, oe) # read .oe data
71 def collect_oefiles( progressCallback ):
72 """Collect all available .oe build files"""
74 files = (data.getVar( "OEFILES", cfg, 1 ) or "").split()
75 data.setVar("OEFILES", " ".join(files), cfg)
81 oe.error("no files to build.")
86 dirfiles = find_oefiles(f)
90 newfiles += glob.glob(f) or [ f ]
92 for i in xrange( len( newfiles ) ):
94 oemask = oe.data.getVar('OEMASK', cfg, 1)
96 if re.search(oemask, f):
97 oe.debug(1, "oemake: skipping %s" % f)
100 progressCallback( i + 1, len( newfiles ), f )
101 debug(1, "oemake: parsing %s" % f)
103 # read a file's metadata
105 pkgdata[f] = load_oefile(f)
107 if pkgdata[f] is not None:
108 # allow metadata files to add items to OEFILES
109 #data.update_data(pkgdata[f])
110 addoefiles = data.getVar('OEFILES', pkgdata[f]) or None
112 for aof in addoefiles.split():
113 if not files.count(aof):
114 if not os.path.isabs(aof):
115 aof = os.path.join(os.path.dirname(f),aof)
117 for var in pkgdata[f].keys():
118 if data.getVarFlag(var, "handler", pkgdata[f]) and data.getVar(var, pkgdata[f]):
119 event.register(data.getVar(var, pkgdata[f]))
121 oe.error("opening %s" % f)
123 except oe.parse.SkipPackage:
126 def explode_version(s):
129 alpha_regexp = re.compile('^([a-zA-Z]+)(.*)$')
130 numeric_regexp = re.compile('^(\d+)(.*)$')
133 m = numeric_regexp.match(s)
134 r.append(int(m.group(1)))
137 if s[0] in ascii_letters:
138 m = alpha_regexp.match(s)
145 def vercmp_part(a, b):
146 va = explode_version(a)
147 vb = explode_version(b)
157 if ca == None and cb == None:
168 r = vercmp_part(va, vb)
170 r = vercmp_part(ra, rb)