@@ -1007,12 +1007,34 @@ to your build configuration.
if not self.bitbake_e:
self.load_bitbake_env()
- native_vars = ['STAGING_DIR_NATIVE']
- for nv in native_vars:
- s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
- if s and s.group(1) != self.get(nv):
- logger.info('Overriding conf file setting of %s to %s from Bitbake environment' % (nv, s.group(1)))
- self.set(nv, s.group(1))
+ if self.bitbake_e:
+ native_vars = ['STAGING_DIR_NATIVE']
+ for nv in native_vars:
+ s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
+ if s and s.group(1) != self.get(nv):
+ logger.info('Overriding conf file setting of %s to %s from Bitbake environment' % (nv, s.group(1)))
+ self.set(nv, s.group(1))
+ else:
+ # when we're invoked from environment with no bitbake (e.g., SDK),
+ # we won't be able to call `bitbake -e`, then try:
+ # - get OE_TMPDIR from environment and guess paths based on it
+ # - get OECORE_NATIVE_SYSROOT from environment (for sdk)
+ tmpdir = self.get('OE_TMPDIR')
+ oecore_native_sysroot = self.get('OECORE_NATIVE_SYSROOT')
+ if tmpdir:
+ logger.info('Setting STAGING_DIR_NATIVE and STAGING_BINDIR_NATIVE relative to OE_TMPDIR (%s)' % tmpdir)
+ hostos, _, _, _, machine = os.uname()
+ buildsys = '%s-%s' % (machine, hostos.lower())
+ staging_dir_native = '%s/sysroots/%s' % (tmpdir, buildsys)
+ self.set('STAGING_DIR_NATIVE', staging_dir_native)
+ elif oecore_native_sysroot:
+ logger.info('Setting STAGING_DIR_NATIVE to OECORE_NATIVE_SYSROOT (%s)' % oecore_native_sysroot)
+ self.set('STAGING_DIR_NATIVE', oecore_native_sysroot)
+ if self.get('STAGING_DIR_NATIVE'):
+ # we have to assume that STAGING_BINDIR_NATIVE is at usr/bin
+ staging_bindir_native = '%s/usr/bin' % self.get('STAGING_DIR_NATIVE')
+ logger.info('Setting STAGING_BINDIR_NATIVE to %s' % staging_bindir_native)
+ self.set('STAGING_BINDIR_NATIVE', '%s/usr/bin' % self.get('STAGING_DIR_NATIVE'))
def print_config(self):
logoutput = ['Continuing with the following parameters:']
@@ -1691,6 +1713,9 @@ to your build configuration.
self.cleaned = True
def run_bitbake_env(self, mach=None, target=''):
+ bitbake = shutil.which('bitbake')
+ if not bitbake:
+ return
if not mach:
mach = self.get('MACHINE')
@@ -1707,10 +1732,6 @@ to your build configuration.
else:
cmd = 'bitbake -e %s %s' % (multiconfig, target)
- bitbake = shutil.which('bitbake')
- if not bitbake:
- raise OEPathError("Bitbake is needed to run '%s', but it is not found in PATH. Please source the bitbake build environment." % cmd.strip())
-
logger.info('Running %s...' % cmd)
try:
return subprocess.check_output(cmd, shell=True).decode('utf-8')
@@ -1722,7 +1743,11 @@ to your build configuration.
cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target)
else:
cmd = 'bitbake -e %s %s' % (multiconfig, target)
- return subprocess.check_output(cmd, shell=True).decode('utf-8')
+ try:
+ return subprocess.check_output(cmd, shell=True).decode('utf-8')
+ except subprocess.CalledProcessError as err:
+ logger.warning("Couldn't run '%s' to gather environment information, giving up with 'bitbake -e':\n%s" % (cmd, err.output.decode('utf-8')))
+ return ''
def load_bitbake_env(self, mach=None, target=None):