def _find_libraries(self, name): libraries = [] if self.libs_scan: for prefix in self.prefix: prefix = path.join(prefix, 'lib') if path.exists(prefix): for l in os.listdir(path.host(prefix)): if l.startswith(name + '.'): libraries += [path.join(prefix, l)] break return libraries
def load(self, name): self._log('loading: %s' % (name)) if self.name_: self._clean() self.name_ = name file = self._find_package(name) if file: if file in package.loaded: package._copy(package.loaded[file], self) return self._log('load: %s (%s)' % (name, file)) if self.src: self.src('==%s%s' % ('=' * 80, os.linesep)) self.src(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep)) self.src('==%s%s' % ('=' * 80, os.linesep)) f = open(path.host(file)) tm = False for l in f.readlines(): if self.src: self.src(l) l = l[:-1] hash = l.find('#') if hash >= 0: l = l[:hash] if len(l): d = 0 define = False eq = l.find('=') dd = l.find(':') if eq > 0 and dd > 0: if eq < dd: define = True d = eq else: define = False d = dd elif eq >= 0: define = True d = eq elif dd >= 0: define = False d = dd if d > 0: lhs = l[:d].lower() rhs = l[d + 1:] if tm: print(('define: ' + str(define) + ', lhs: ' + lhs + ', ' + rhs)) if define: self.defines[lhs] = rhs else: self.fields[lhs] = rhs self.file_ = file else: self.libraries = self._find_libraries(name) for nt in package.node_types: requires = self.get(nt, private=False) if requires: for r in package.splitter(requires): if r[0] not in self.nodes[nt]: file = self._find_package(r[0]) if file in package.loaded: pkg = package.loaded[file] else: pkg = package(r[0], self.prefix, self.output) ver = pkg.get('version') self._log(' checking: %s (%s) %s %s' % (r[0], ver, r[1], r[2])) if ver and package.check_versions(ver, r[1], r[2]): self.nodes[nt][r[0]] = pkg else: self._log('failed: %s (%s %s %s)' % (r[0], ver, r[1], r[2])) self.nodes['failed'][r[0]] = pkg if self.exists(): self._log('load: exists and loaded; cache as loaded') package.loaded[self.file_] = self
def load(self, name): if name in package.loaded: package._copy(package.loaded[name], self) return self._log('loading: %s' % (name)) if self.name_: self._clean() self.name_ = name file = self._find_package(name) if file: self._log('load: %s (%s)' % (name, file)) if self.src: self.src('==%s%s' % ('=' * 80, os.linesep)) self.src(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep)) self.src('==%s%s' % ('=' * 80, os.linesep)) f = open(path.host(file)) tm = False for l in f.readlines(): if self.src: self.src(l) l = l[:-1] hash = l.find('#') if hash >= 0: l = l[:hash] if len(l): d = 0 define = False eq = l.find('=') dd = l.find(':') if eq > 0 and dd > 0: if eq < dd: define = True d = eq else: define = False d = dd elif eq >= 0: define = True d = eq elif dd >= 0: define = False d = dd if d > 0: lhs = l[:d].lower() rhs = l[d + 1:] if tm: print(('define: ' + str(define) + ', lhs: ' + lhs + ', ' + rhs)) if define: self.defines[lhs] = rhs else: self.fields[lhs] = rhs self.file_ = file else: self.libraries = self._find_libraries(name) for nt in package.node_types: requires = self.get(nt, private = False) if requires: for r in package.splitter(requires): if r[0] not in self.nodes[nt]: if r[0] in package.loaded: pkg = package.loaded[r[0]] else: pkg = package(r[0], self.prefix, self.output) ver = pkg.get('version') self._log(' checking: %s (%s) %s %s' % (r[0], ver, r[1], r[2])) if ver and package.check_versions(ver, r[1], r[2]): self.nodes[nt][r[0]] = pkg else: self._log('failed: %s (%s %s %s)' % (r[0], ver, r[1], r[2])) self.nodes['failed'][r[0]] = pkg if self.exists(): self._log('load: exists') package.loaded[name] = self