Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _pkgconfig_check(self, test):
# Hack to by pass pkgconfig checks when just wanting to download the
# source.
if self.macros['_dry_run'] == '1' and \
('with_download' in self.macros and self.macros['with_download'] == '1'):
return '0'
ok = False
log.trace('pkgconfig: check: crossc=%d pkg_crossc=%d prefix=%s' % ( self._cross_compile(),
self.pkgconfig_crosscompile,
self.pkgconfig_prefix))
log.trace('pkgconfig: check: test=%s' % (test))
if type(test) == str:
test = test.split()
if not self._cross_compile() or self.pkgconfig_crosscompile:
try:
pkg = pkgconfig.package(test[0],
prefix = self.pkgconfig_prefix,
output = self._output,
src = log.trace)
if len(test) != 1 and len(test) != 3:
self._error('malformed check: %s' % (' '.join(test)))
else:
op = '>='
ver = '0'
if len(test) == 3:
op = test[1]
ver = self.macros.expand(test[2])
ok = pkg.check(op, ver)
except pkgconfig.error as pe:
self._error('pkgconfig: check: %s' % (pe))
except:
raise error.internal('pkgconfig failure')
def _pkgconfig_flags(self, package, flags):
pkg_flags = None
if not self._cross_compile() or self.pkgconfig_crosscompile:
try:
pkg = pkgconfig.package(package,
prefix = self.pkgconfig_prefix,
output = self._output,
src = log.trace)
pkg_flags = pkg.get(flags)
if pkg_flags and self.pkgconfig_filter_flags:
fflags = []
for f in pkg_flags.split():
if not f.startswith('-W'):
fflags += [f]
pkg_flags = ' '.join(fflags)
log.trace('pkgconfig: %s: %s' % (flags, pkg_flags))
except pkgconfig.error as pe:
self._error('pkgconfig: %s: %s' % (flags, pe))
except:
raise error.internal('pkgconfig failure')
if pkg_flags is None:
def _load_flags(conf, arch_bsp, path):
if not os.path.exists(path):
ctx.fatal('RTEMS path not found.')
if os.path.exists(_pkgconfig_path(path)):
pc = os.path.join(_pkgconfig_path(path), arch_bsp + '.pc')
conf.to_log('Opening and load pkgconfig: ' + pc)
pkg = pkgconfig.package(pc)
config = None
elif os.path.exists(os.path.join(path, 'rtems-config')):
config = os.path.join(path, 'rtems-config')
pkg = None
flags = {}
_log_header(conf)
flags['CFLAGS'] = _load_flags_set('CFLAGS', arch_bsp, conf, config, pkg)
flags['LDFLAGS'] = _load_flags_set('LDFLAGS', arch_bsp, conf, config, pkg)
flags['LIB'] = _load_flags_set('LIB', arch_bsp, conf, config, pkg)
return flags