浏览代码

Merge pull request #105498 from adamscott/add-compiler-launcher

Add `{c,cpp}_compiler_launcher` options
Thaddeus Crews 6 月之前
父节点
当前提交
b45cf573a2
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      SConstruct

+ 10 - 0
SConstruct

@@ -296,6 +296,9 @@ opts.Add("asflags", "Custom flags for the assembler")
 opts.Add("arflags", "Custom flags for the archive tool")
 opts.Add("arflags", "Custom flags for the archive tool")
 opts.Add("rcflags", "Custom flags for Windows resource compiler")
 opts.Add("rcflags", "Custom flags for Windows resource compiler")
 
 
+opts.Add("c_compiler_launcher", "C compiler launcher (e.g. `ccache`)")
+opts.Add("cpp_compiler_launcher", "C++ compiler launcher (e.g. `ccache`)")
+
 # Update the environment to have all above options defined
 # Update the environment to have all above options defined
 # in following code (especially platform and custom_modules).
 # in following code (especially platform and custom_modules).
 opts.Update(env)
 opts.Update(env)
@@ -1122,6 +1125,13 @@ for key in (emitters := env.StaticObject.builder.emitter):
 for key in (emitters := env.SharedObject.builder.emitter):
 for key in (emitters := env.SharedObject.builder.emitter):
     emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key]))
     emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key]))
 
 
+# Prepend compiler launchers
+if "c_compiler_launcher" in env:
+    env["CC"] = " ".join([env["c_compiler_launcher"], env["CC"]])
+
+if "cpp_compiler_launcher" in env:
+    env["CXX"] = " ".join([env["cpp_compiler_launcher"], env["CXX"]])
+
 # Build subdirs, the build order is dependent on link order.
 # Build subdirs, the build order is dependent on link order.
 Export("env")
 Export("env")