• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright 2023 The Chromium Authors
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 used to configure siso."""
6
7import argparse
8import os
9import sys
10
11THIS_DIR = os.path.abspath(os.path.dirname(__file__))
12
13
14def main():
15  parser = argparse.ArgumentParser(description='configure siso')
16  parser.add_argument('--rbe_instance', help='RBE instance to use for Siso')
17  args = parser.parse_args()
18
19  project = None
20  if not args.rbe_instance:
21    return 0
22  rbe_instance = args.rbe_instance
23  elems = rbe_instance.split('/')
24  if len(elems) == 4 and elems[0] == 'projects':
25    project = elems[1]
26    rbe_instance = elems[-1]
27  siso_env_path = os.path.join(THIS_DIR, '.sisoenv')
28  with open(siso_env_path, 'w') as f:
29    if project:
30      f.write('SISO_PROJECT=%s\n' % project)
31    f.write('SISO_REAPI_INSTANCE=%s\n' % rbe_instance)
32  return 0
33
34
35if __name__ == '__main__':
36  sys.exit(main())
37