ninja_reclient.py 857 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python3
  2. # Copyright 2023 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """This script is a wrapper around the ninja.py script that also
  6. handles the client lifecycle safely. It will automatically start
  7. reproxy before running ninja and stop reproxy when ninja stops
  8. for any reason eg. build completes, keyboard interupt etc."""
  9. import sys
  10. import ninja
  11. import reclient_helper
  12. def main(argv):
  13. with reclient_helper.build_context(argv, "ninja_reclient") as ret_code:
  14. if ret_code:
  15. return ret_code
  16. try:
  17. return ninja.main(argv)
  18. except KeyboardInterrupt:
  19. print("Shutting down reproxy...", file=sys.stderr)
  20. return 1
  21. if __name__ == "__main__":
  22. sys.exit(main(sys.argv))