build-libchromiumcontent.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env python
  2. import argparse
  3. import os
  4. import sys
  5. from lib.config import enable_verbose_mode, get_target_arch
  6. from lib.util import execute_stdout
  7. from bootstrap import get_libchromiumcontent_commit
  8. SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
  9. LIBCC_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'libchromiumcontent')
  10. GCLIENT_DONE_MARKER = os.path.join(SOURCE_ROOT, '.gclient_done')
  11. LIBCC_COMMIT = get_libchromiumcontent_commit()
  12. def update_gclient_done_marker():
  13. with open(GCLIENT_DONE_MARKER, 'wb') as f:
  14. f.write(LIBCC_COMMIT)
  15. def libchromiumcontent_outdated():
  16. if not os.path.exists(GCLIENT_DONE_MARKER):
  17. return True
  18. with open(GCLIENT_DONE_MARKER, 'rb') as f:
  19. return f.read() != LIBCC_COMMIT
  20. def main():
  21. os.chdir(LIBCC_DIR)
  22. args = parse_args()
  23. if args.verbose:
  24. enable_verbose_mode()
  25. # ./script/bootstrap
  26. # ./script/update -t x64
  27. # ./script/build --no_shared_library -t x64
  28. # ./script/create-dist -c static_library -t x64 --no_zip
  29. script_dir = os.path.join(LIBCC_DIR, 'script')
  30. bootstrap = os.path.join(script_dir, 'bootstrap')
  31. update = os.path.join(script_dir, 'update')
  32. build = os.path.join(script_dir, 'build')
  33. create_dist = os.path.join(script_dir, 'create-dist')
  34. if args.force_update or libchromiumcontent_outdated():
  35. execute_stdout([sys.executable, bootstrap])
  36. execute_stdout([sys.executable, update, '-t', args.target_arch])
  37. update_gclient_done_marker()
  38. if args.debug:
  39. execute_stdout([sys.executable, build, '-D', '-t', args.target_arch])
  40. execute_stdout([sys.executable, create_dist, '-c', 'shared_library',
  41. '--no_zip', '--keep-debug-symbols',
  42. '-t', args.target_arch])
  43. else:
  44. execute_stdout([sys.executable, build, '-R', '-t', args.target_arch])
  45. execute_stdout([sys.executable, create_dist, '-c', 'static_library',
  46. '--no_zip', '-t', args.target_arch])
  47. def parse_args():
  48. parser = argparse.ArgumentParser(description='Build libchromiumcontent')
  49. parser.add_argument('--target_arch',
  50. help='Specify the arch to build for')
  51. parser.add_argument('-v', '--verbose', action='store_true',
  52. help='Prints the output of the subprocesses')
  53. parser.add_argument('-d', '--debug', action='store_true',
  54. help='Build libchromiumcontent for debugging')
  55. parser.add_argument('--force-update', default=False, action='store_true',
  56. help='Force gclient to update libchromiumcontent')
  57. return parser.parse_args()
  58. if __name__ == '__main__':
  59. sys.exit(main())