1#!/usr/bin/env python3 2# Copyright 2024 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"""Script to decide use_siso default value. 6 7It is called by siso.gni via exec_script, 8or used in depot_tools' autoninja or siso wrapper. 9""" 10# TODO(crbug.com/379584977): move this to depot_tools once `use_siso` 11# is not used for build graph. 12 13import os 14import shutil 15import sys 16 17 18def _is_google_corp_machine(): 19 """This assumes that corp machine has gcert binary in known location.""" 20 return shutil.which("gcert") is not None 21 22 23def use_siso_default(output_dir): 24 """Returns use_siso default value.""" 25 # This output directory is already using Siso. 26 if os.path.exists(os.path.join(output_dir, ".siso_deps")): 27 return True 28 29 # This output directory is already using Ninja. 30 if os.path.exists(os.path.join(output_dir, ".ninja_deps")): 31 return False 32 33 # If no .sisoenv, use Ninja. 34 if not os.path.exists( 35 os.path.join(os.path.dirname(__file__), "../config/siso/.sisoenv")): 36 return False 37 38 # Use Siso by default for Googlers working on corp machine. 39 if _is_google_corp_machine(): 40 return True 41 42 # Otherwise, use Ninja, until we are ready to roll it out 43 # on non-corp machines, too. 44 # TODO(378078715): enable True by default. 45 return False 46 47 48if __name__ == "__main__": 49 # exec_script runs in output directory. 50 print(str(use_siso_default(".")).lower()) 51