external-run.inc 906 B

123456789101112131415161718192021222324
  1. def external_run(d, cmd, *args):
  2. import subprocess
  3. topdir = d.getVar('TMPDIR', True)
  4. toolchain_path = d.getVar('EXTERNAL_TOOLCHAIN', True)
  5. if toolchain_path:
  6. target_prefix = d.getVar('EXTERNAL_TARGET_SYS', True) + '-'
  7. path = os.path.join(toolchain_path, 'bin', target_prefix + cmd)
  8. args = [path] + list(args)
  9. try:
  10. output = oe.path.check_output(args, cwd=topdir, stderr=subprocess.STDOUT)
  11. except oe.path.CalledProcessError as exc:
  12. import pipes
  13. bb.debug(1, "{0} failed: {1}".format(' '.join(pipes.quote(a) for a in args), exc.output))
  14. except OSError as exc:
  15. import pipes
  16. bb.debug(1, "{0} failed: {1}".format(' '.join(pipes.quote(a) for a in args), str(exc)))
  17. else:
  18. return output
  19. return 'UNKNOWN'
  20. external_run[vardepsexclude] += "EXTERNAL_TOOLCHAIN TMPDIR"