build-qemu 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python3
  2. import os
  3. import common
  4. from shell_helpers import LF
  5. class Main(common.BuildCliFunction):
  6. def __init__(self):
  7. super().__init__()
  8. self.add_argument(
  9. 'extra_config_args',
  10. default=[],
  11. metavar='extra-config-args',
  12. nargs='*'
  13. )
  14. def build(self):
  15. build_dir = self.get_build_dir()
  16. os.makedirs(build_dir, exist_ok=True)
  17. if self.env['verbose']:
  18. verbose = ['V=1']
  19. else:
  20. verbose = []
  21. if self.env['mode'] == 'userland':
  22. target_list = '{}-linux-user'.format(self.env['arch'])
  23. else:
  24. target_list = '{}-softmmu'.format(self.env['arch'])
  25. self.sh.run_cmd(
  26. [
  27. os.path.join(self.env['qemu_source_dir'], 'configure'), LF,
  28. '--enable-debug', LF,
  29. '--enable-trace-backends=simple', LF,
  30. '--target-list={}'.format(target_list), LF,
  31. '--enable-sdl', LF,
  32. ] +
  33. self.sh.add_newlines(self.env['extra_config_args']),
  34. extra_paths=[self.env['ccache_dir']],
  35. cwd=build_dir
  36. )
  37. self.sh.run_cmd(
  38. (
  39. [
  40. 'make', LF,
  41. '-j', str(self.env['nproc']), LF,
  42. ] +
  43. verbose
  44. ),
  45. cwd=build_dir,
  46. extra_paths=[self.env['ccache_dir']],
  47. )
  48. def get_build_dir(self):
  49. return self.env['qemu_build_dir']
  50. if __name__ == '__main__':
  51. Main().cli()