xref: /aosp_15_r20/external/angle/build/toolchain/use_remoteexec_value.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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_remoteexec value.
6
7It is called by rbe.gni via exec_script,
8or used in depot_tools' autoninja or siso wrapper.
9"""
10
11import os
12import sys
13
14sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
15import use_siso_default
16
17# instead of finding depot_tools in PATH,
18# just use pinned third_party/depot_tools.
19sys.path.insert(
20    0,
21    os.path.join(os.path.dirname(__file__), "..", "..", "third_party",
22                 "depot_tools"))
23import gn_helper
24
25
26def _gn_bool(value):
27  if value == "true":
28    return True
29  if value == "false":
30    return False
31  raise Exception("invalid bool value %s" % value)
32
33
34def use_remoteexec_value(output_dir):
35  """Returns use_remoteexec value."""
36  use_remoteexec = None
37  for k, v in gn_helper.args(output_dir):
38    if k == "use_remoteexec":
39      use_remoteexec = _gn_bool(v)
40  # If args.gn has use_remoteexec, use it.
41  if use_remoteexec is not None:
42    return use_remoteexec
43
44  # TODO(crbug.com/341167943): Use remoteexec by default.
45  return False
46
47
48if __name__ == "__main__":
49  # exec_script runs in output directory.
50  print(str(use_remoteexec_value(".")).lower())
51