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 rbe_instance = args.rbe_instance 21 if rbe_instance: 22 elems = rbe_instance.split("/") 23 if len(elems) == 4 and elems[0] == "projects": 24 project = elems[1] 25 rbe_instance = elems[-1] 26 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 if rbe_instance: 32 f.write("SISO_REAPI_INSTANCE=%s\n" % rbe_instance) 33 return 0 34 35 36if __name__ == "__main__": 37 sys.exit(main()) 38