blob: 451ae9967bd842403b9d23c3a28129fb24561287 [file] [log] [blame]
Ben Segalleb2866e2023-01-20 20:14:44 +00001#!/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
6handles the client lifecycle safely. It will automatically start
7reproxy before running ninja and stop reproxy when ninja stops
8for any reason eg. build completes, keyboard interupt etc."""
9
Ben Segallbb670642023-09-06 14:44:21 +000010import os
Ben Segalleb2866e2023-01-20 20:14:44 +000011import sys
12
13import ninja
Junji Watanabe607284d2023-04-20 03:14:52 +000014import reclient_helper
Ben Segallc4efd8a2023-02-13 17:17:33 +000015
16
Ben Segalleb2866e2023-01-20 20:14:44 +000017def main(argv):
Ben Segallbb670642023-09-06 14:44:21 +000018 os.environ.setdefault("RBE_exec_strategy", "racing")
Mike Frysinger124bb8e2023-09-06 05:48:55 +000019 with reclient_helper.build_context(argv, 'ninja_reclient') as ret_code:
20 if ret_code:
21 return ret_code
22 try:
23 return ninja.main(argv)
24 except KeyboardInterrupt:
25 return 1
Ben Segalleb2866e2023-01-20 20:14:44 +000026
27
28if __name__ == '__main__':
Mike Frysinger124bb8e2023-09-06 05:48:55 +000029 sys.exit(main(sys.argv))