xref: /aosp_15_r20/external/angle/build/toolchain/use_remoteexec_value.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker#!/usr/bin/env python3
2*8975f5c5SAndroid Build Coastguard Worker# Copyright 2024 The Chromium Authors
3*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker"""Script to decide use_remoteexec value.
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard WorkerIt is called by rbe.gni via exec_script,
8*8975f5c5SAndroid Build Coastguard Workeror used in depot_tools' autoninja or siso wrapper.
9*8975f5c5SAndroid Build Coastguard Worker"""
10*8975f5c5SAndroid Build Coastguard Worker
11*8975f5c5SAndroid Build Coastguard Workerimport os
12*8975f5c5SAndroid Build Coastguard Workerimport sys
13*8975f5c5SAndroid Build Coastguard Worker
14*8975f5c5SAndroid Build Coastguard Workersys.path.insert(0, os.path.join(os.path.dirname(__file__)))
15*8975f5c5SAndroid Build Coastguard Workerimport use_siso_default
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard Worker# instead of finding depot_tools in PATH,
18*8975f5c5SAndroid Build Coastguard Worker# just use pinned third_party/depot_tools.
19*8975f5c5SAndroid Build Coastguard Workersys.path.insert(
20*8975f5c5SAndroid Build Coastguard Worker    0,
21*8975f5c5SAndroid Build Coastguard Worker    os.path.join(os.path.dirname(__file__), "..", "..", "third_party",
22*8975f5c5SAndroid Build Coastguard Worker                 "depot_tools"))
23*8975f5c5SAndroid Build Coastguard Workerimport gn_helper
24*8975f5c5SAndroid Build Coastguard Worker
25*8975f5c5SAndroid Build Coastguard Worker
26*8975f5c5SAndroid Build Coastguard Workerdef _gn_bool(value):
27*8975f5c5SAndroid Build Coastguard Worker  if value == "true":
28*8975f5c5SAndroid Build Coastguard Worker    return True
29*8975f5c5SAndroid Build Coastguard Worker  if value == "false":
30*8975f5c5SAndroid Build Coastguard Worker    return False
31*8975f5c5SAndroid Build Coastguard Worker  raise Exception("invalid bool value %s" % value)
32*8975f5c5SAndroid Build Coastguard Worker
33*8975f5c5SAndroid Build Coastguard Worker
34*8975f5c5SAndroid Build Coastguard Workerdef use_remoteexec_value(output_dir):
35*8975f5c5SAndroid Build Coastguard Worker  """Returns use_remoteexec value."""
36*8975f5c5SAndroid Build Coastguard Worker  use_remoteexec = None
37*8975f5c5SAndroid Build Coastguard Worker  for k, v in gn_helper.args(output_dir):
38*8975f5c5SAndroid Build Coastguard Worker    if k == "use_remoteexec":
39*8975f5c5SAndroid Build Coastguard Worker      use_remoteexec = _gn_bool(v)
40*8975f5c5SAndroid Build Coastguard Worker  # If args.gn has use_remoteexec, use it.
41*8975f5c5SAndroid Build Coastguard Worker  if use_remoteexec is not None:
42*8975f5c5SAndroid Build Coastguard Worker    return use_remoteexec
43*8975f5c5SAndroid Build Coastguard Worker
44*8975f5c5SAndroid Build Coastguard Worker  # TODO(crbug.com/341167943): Use remoteexec by default.
45*8975f5c5SAndroid Build Coastguard Worker  return False
46*8975f5c5SAndroid Build Coastguard Worker
47*8975f5c5SAndroid Build Coastguard Worker
48*8975f5c5SAndroid Build Coastguard Workerif __name__ == "__main__":
49*8975f5c5SAndroid Build Coastguard Worker  # exec_script runs in output directory.
50*8975f5c5SAndroid Build Coastguard Worker  print(str(use_remoteexec_value(".")).lower())
51