Mercurial > lcfOS
diff python/c3/builder.py @ 272:e64bae57cda8
refactor ir
author | Windel Bouwman |
---|---|
date | Sat, 31 Aug 2013 17:58:54 +0200 |
parents | 7416c923a02a |
children | 1c7c1e619be8 |
line wrap: on
line diff
--- a/python/c3/builder.py Tue Aug 20 18:56:02 2013 +0200 +++ b/python/c3/builder.py Sat Aug 31 17:58:54 2013 +0200 @@ -10,6 +10,7 @@ Reports errors to the diagnostics system """ def __init__(self, diag): + self.pack_dir = None self.logger = logging.getLogger('c3') self.diag = diag self.parser = Parser(diag) @@ -24,11 +25,17 @@ return self.packages[pname] else: # Try to lookup package from file - fns = glob.glob('./*/{}.c3'.format(pname)) + fns = glob.glob('./**/{}.c3'.format(pname)) if fns: with open(fns[0]) as f: src = f.read() self.build(src) + if self.pack_dir: + fns = glob.glob('{}/{}.c3'.format(self.pack_dir, pname)) + if fns: + with open(fns[0]) as f: + src = f.read() + self.build(src) if pname in self.packages: return self.packages[pname] @@ -48,8 +55,9 @@ self.packages[pkg.name] = pkg return pkg - def build(self, src): + def build(self, src, pack_dir=None): """ Create IR-code from sources """ + self.pack_dir = pack_dir pkg = self.parse(src) # Only return ircode when everything is OK