diff --git a/Meta/gn/build/toolchain/BUILD.gn b/Meta/gn/build/toolchain/BUILD.gn index 82a937fa262..aad40d8621c 100644 --- a/Meta/gn/build/toolchain/BUILD.gn +++ b/Meta/gn/build/toolchain/BUILD.gn @@ -21,6 +21,9 @@ template("unix_toolchain") { ]) tool("cc") { + if (enable_ccache) { + command_launcher = "ccache" + } depfile = "{{output}}.d" command = "$cc -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" depsformat = "gcc" @@ -29,6 +32,9 @@ template("unix_toolchain") { } tool("cxx") { + if (enable_ccache) { + command_launcher = "ccache" + } depfile = "{{output}}.d" command = "$cxx -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" depsformat = "gcc" @@ -37,6 +43,9 @@ template("unix_toolchain") { } tool("objcxx") { + if (enable_ccache) { + command_launcher = "ccache" + } depfile = "{{output}}.d" command = "$cxx -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}}" depsformat = "gcc" @@ -45,6 +54,9 @@ template("unix_toolchain") { } tool("asm") { + if (enable_ccache) { + command_launcher = "ccache" + } depfile = "{{output}}.d" command = "$cc -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{asmflags}}" depsformat = "gcc" @@ -53,6 +65,9 @@ template("unix_toolchain") { } tool("alink") { + if (enable_ccache) { + command_launcher = "ccache" + } if (current_os == "ios" || current_os == "mac") { command = "libtool -D -static -no_warning_for_no_symbols {{arflags}} -o {{output}} {{inputs}}" not_needed([ "ar" ]) @@ -78,6 +93,9 @@ template("unix_toolchain") { lib_dir_switch = "-L" tool("solink") { + if (enable_ccache) { + command_launcher = "ccache" + } outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { command = "$ld -shared {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}} -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}" @@ -98,6 +116,9 @@ template("unix_toolchain") { } tool("solink_module") { + if (enable_ccache) { + command_launcher = "ccache" + } outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { command = "$ld -shared {{ldflags}} -Wl,-flat_namespace -Wl,-undefined,suppress -o $outfile {{inputs}} {{libs}} {{frameworks}} -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}" @@ -117,6 +138,9 @@ template("unix_toolchain") { } tool("link") { + if (enable_ccache) { + command_launcher = "ccache" + } outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { command = "$ld {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}} -Wl,-rpath,@executable_path/../lib" diff --git a/Meta/gn/build/toolchain/compiler.gni b/Meta/gn/build/toolchain/compiler.gni index 66d41343b25..b63399ecb8f 100644 --- a/Meta/gn/build/toolchain/compiler.gni +++ b/Meta/gn/build/toolchain/compiler.gni @@ -5,4 +5,7 @@ declare_args() { # Enable setting -fuse-ld and other flags for using the lld linker. # Should not be set on macOS when using the default system compiler. use_lld = false + + # Use ccache as a compiler launcher for compile and link jobs + enable_ccache = true }