|
@@ -14,7 +14,7 @@ does handle import statements, but it can't handle conditional setting of build
|
|
|
settings.
|
|
|
"""
|
|
|
|
|
|
-import uuid
|
|
|
+import importlib.util
|
|
|
import logging
|
|
|
import multiprocessing
|
|
|
import os
|
|
@@ -25,6 +25,7 @@ import shutil
|
|
|
import subprocess
|
|
|
import sys
|
|
|
import time
|
|
|
+import uuid
|
|
|
import warnings
|
|
|
|
|
|
import build_telemetry
|
|
@@ -53,6 +54,22 @@ _UNSAFE_FOR_CMD = set("^<>&|()%")
|
|
|
_ALL_META_CHARS = _UNSAFE_FOR_CMD.union(set('"'))
|
|
|
|
|
|
|
|
|
+def _import_from_path(module_name, file_path):
|
|
|
+ try:
|
|
|
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
|
|
|
+ module = importlib.util.module_from_spec(spec)
|
|
|
+ sys.modules[module_name] = module
|
|
|
+ spec.loader.exec_module(module)
|
|
|
+ except Exception:
|
|
|
+ raise ImportError(
|
|
|
+ 'Could not import module "{}" from "{}"'.format(
|
|
|
+ module_name, file_path),
|
|
|
+ name=module_name,
|
|
|
+ path=file_path,
|
|
|
+ )
|
|
|
+ return module
|
|
|
+
|
|
|
+
|
|
|
def _is_google_corp_machine():
|
|
|
"""This assumes that corp machine has gcert binary in known location."""
|
|
|
return shutil.which("gcert") is not None
|
|
@@ -116,6 +133,30 @@ def _print_cmd(cmd):
|
|
|
print(*[shell_quoter(arg) for arg in cmd], file=sys.stderr)
|
|
|
|
|
|
|
|
|
+def _get_use_siso_default(output_dir):
|
|
|
+ # TODO(379584977): move this in depot_tools
|
|
|
+ # once gn rule for action_remote.py, which check use_siso` is removed.
|
|
|
+ root_dir = gclient_paths.GetPrimarySolutionPath()
|
|
|
+ if not root_dir:
|
|
|
+ return False
|
|
|
+ script_path = os.path.join(root_dir, "build/toolchain/use_siso_default.py")
|
|
|
+ if not os.path.exists(script_path):
|
|
|
+ return False
|
|
|
+
|
|
|
+ script = _import_from_path("use_siso_default", script_path)
|
|
|
+ try:
|
|
|
+ r = script.use_siso_default(output_dir)
|
|
|
+ except Exception:
|
|
|
+ raise RuntimeError(
|
|
|
+ 'Could not call method "use_siso_default" in {}"'.format(
|
|
|
+ script_path))
|
|
|
+ if not isinstance(r, bool):
|
|
|
+ raise TypeError(
|
|
|
+ 'Method "use_siso_default" in "{}" returns invalid result. Expected bool, got "{}" (type "{}")'
|
|
|
+ .format(script_path, r, type(r)))
|
|
|
+ return r
|
|
|
+
|
|
|
+
|
|
|
def _main_inner(input_args, build_id, should_collect_logs=False):
|
|
|
# if user doesn't set PYTHONPYCACHEPREFIX and PYTHONDONTWRITEBYTECODE
|
|
|
# set PYTHONDONTWRITEBYTECODE=1 not to create many *.pyc in workspace
|
|
@@ -161,7 +202,7 @@ def _main_inner(input_args, build_id, should_collect_logs=False):
|
|
|
|
|
|
use_remoteexec = False
|
|
|
use_reclient = None
|
|
|
- use_siso = False
|
|
|
+ use_siso = _get_use_siso_default(output_dir)
|
|
|
|
|
|
# Attempt to auto-detect remote build acceleration. We support gn-based
|
|
|
# builds, where we look for args.gn in the build tree, and cmake-based
|