build-libchromiumcontent.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 --defines=''
  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. '--defines', args.defines])
  38. update_gclient_done_marker()
  39. if args.debug:
  40. execute_stdout([sys.executable, build, '-D', '-t', args.target_arch])
  41. execute_stdout([sys.executable, create_dist, '-c', 'shared_library',
  42. '--no_zip', '--keep-debug-symbols',
  43. '-t', args.target_arch])
  44. else:
  45. execute_stdout([sys.executable, build, '-R', '-t', args.target_arch])
  46. execute_stdout([sys.executable, create_dist, '-c', 'static_library',
  47. '--no_zip', '-t', args.target_arch])
  48. def parse_args():
  49. parser = argparse.ArgumentParser(description='Build libchromiumcontent')
  50. parser.add_argument('--target_arch',
  51. help='Specify the arch to build for')
  52. parser.add_argument('--defines', default='',
  53. help='The definetions passed to gyp')
  54. parser.add_argument('-v', '--verbose', action='store_true',
  55. help='Prints the output of the subprocesses')
  56. parser.add_argument('-d', '--debug', action='store_true',
  57. help='Build libchromiumcontent for debugging')
  58. parser.add_argument('--force-update', default=False, action='store_true',
  59. help='Force gclient to update libchromiumcontent')
  60. return parser.parse_args()
  61. if __name__ == '__main__':
  62. sys.exit(main())