From a834e72b711c670bd5ce358d8be1ca4cafd55ab7 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 30 May 2025 11:11:45 -0700 Subject: [PATCH] Use sccache for clippy --- build.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/build.py b/build.py index 131c37cb6..ab72cdf86 100755 --- a/build.py +++ b/build.py @@ -313,7 +313,7 @@ def dump_flag_header(): write_if_diff(native_gen_path / "flags.rs", rust_flag_txt) -def build_native(): +def ensure_toolchain(): ensure_paths() # Verify NDK install @@ -323,6 +323,17 @@ def build_native(): except: error('Unmatched NDK. Please install/upgrade NDK with "build.py ndk"') + if sccache := shutil.which("sccache"): + os.environ["RUSTC_WRAPPER"] = sccache + os.environ["NDK_CCACHE"] = sccache + os.environ["CARGO_INCREMENTAL"] = "0" + if ccache := shutil.which("ccache"): + os.environ["NDK_CCACHE"] = ccache + + +def build_native(): + ensure_toolchain() + if "targets" not in vars(args) or not args.targets: targets = default_targets else: @@ -332,13 +343,6 @@ def build_native(): header("* Building: " + " ".join(targets)) - if sccache := shutil.which("sccache"): - os.environ["RUSTC_WRAPPER"] = sccache - os.environ["NDK_CCACHE"] = sccache - os.environ["CARGO_INCREMENTAL"] = "0" - if ccache := shutil.which("ccache"): - os.environ["NDK_CCACHE"] = ccache - dump_flag_header() build_rust_src(targets) build_cpp_src(targets) @@ -532,6 +536,7 @@ def gen_ide(): def clippy_cli(): + ensure_toolchain() args.force_out = True set_archs(default_archs)