build-qemu 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python3
  2. import os
  3. import common
  4. class QemuComponent(common.Component):
  5. def add_parser_arguments(self, parser):
  6. parser.add_argument(
  7. '--userland',
  8. default=False,
  9. action='store_true',
  10. help='Build QEMU user mode instead of system.',
  11. )
  12. parser.add_argument(
  13. 'extra_config_args',
  14. default=[],
  15. metavar='extra-config-args',
  16. nargs='*'
  17. )
  18. def do_build(self, args):
  19. build_dir = self.get_build_dir(args)
  20. os.makedirs(build_dir, exist_ok=True)
  21. if args.verbose:
  22. verbose = ['V=1']
  23. else:
  24. verbose = []
  25. if args.userland:
  26. target_list = '{}-linux-user'.format(args.arch)
  27. else:
  28. target_list = '{}-softmmu'.format(args.arch)
  29. common.run_cmd(
  30. [
  31. os.path.join(common.qemu_src_dir, 'configure'),
  32. '--enable-debug',
  33. '--enable-trace-backends=simple',
  34. '--target-list={}'.format(target_list),
  35. '--enable-sdl',
  36. '--with-sdlabi=2.0',
  37. ] +
  38. args.extra_config_args,
  39. extra_paths=[common.ccache_dir],
  40. cwd=build_dir
  41. )
  42. common.run_cmd(
  43. (
  44. [
  45. 'make',
  46. '-j', str(args.nproc),
  47. ] +
  48. verbose
  49. ),
  50. cwd=build_dir,
  51. extra_paths=[common.ccache_dir],
  52. )
  53. def get_build_dir(self, args):
  54. return common.qemu_build_dir
  55. if __name__ == '__main__':
  56. QemuComponent().build()