xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.21k stars 790 forks source link

Support ccache when debug package #5874

Open star-hengxing opened 6 days ago

star-hengxing commented 6 days ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

if true then
    local ccache
    ccache = find_tool("ccache")
    if not ccache then
        ccache = find_tool("sccache")
    end

    if ccache then
        local name = path.basename(ccache.program)
        package:data_set("ccache", name)
        local ccache_dir = path.join(path.directory(path.directory(os.curdir())), name)
        os.setenv(name:upper() .. "_DIR", ccache_dir)
        print("ccache enabled, cache dir:", ccache_dir)
    end
end

local ccache = package:data("ccache")
if ccache then
    table.insert(configs, "-DCMAKE_C_COMPILER_LAUNCHER=" .. ccache)
    table.insert(configs, "-DCMAKE_CXX_COMPILER_LAUNCHER=" .. ccache)
end

Describe alternatives you've considered

No response

Additional context

No response

waruqi commented 6 days ago

可以提个 pr 过来,通过 policy 配置,不过不建议默认开,还是用户按需开比较好,比如大部分情况下,用户都不会去调试包。仅仅一次编译。

Issues-translate-bot commented 6 days ago

Bot detected the issue body's language is not English, translate it automatically.


You can submit a PR and configure it through policy, but it is not recommended to enable it by default. It is better for users to enable it on demand. For example, in most cases, users will not debug packages. Just compile once.