diff options
| author | ruki <[email protected]> | 2022-05-29 16:01:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-29 16:01:44 +0800 |
| commit | 53e8d28f6f8f1ebe5bd33b7733aef9c878251f78 (patch) | |
| tree | b8b4317c652563767ef52c68d7d9e46a16564c44 | |
| parent | ef6baaf4b1d333d330d6c44810fc3544c1e5d8f5 (diff) | |
add linemarkers policy
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 14 |
3 files changed, 30 insertions, 0 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index e8921cefb..7f3b19ad0 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -47,6 +47,8 @@ function policy.policies() ["build.merge_archive"] = {description = "Enable merge archive intead of linking for all dependent targets.", default = false, type = "boolean"}, -- C/C++ build cache ["build.ccache"] = {description = "Enable C/C++ build cache.", default = true, type = "boolean"}, + -- preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess + ["preprocessor.linemarkers"] = {description = "Enable linemarkers for preprocessor.", default = true, type = "boolean"}, -- we need enable longpaths when building target or installing package ["platform.longpaths"] = {description = "Enable long paths when building target or installing package on windows.", default = false, type = "boolean"}, -- lock required packages diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index a832dab4c..fdcce6d45 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -450,6 +450,17 @@ function _preprocess(program, argv, opt) return false end + -- disable linemarkers? + local linemarkers = _g.linemarkers + if linemarkers == nil then + if os.isfile(os.projectfile()) and project.policy("preprocessor.linemarkers") == false then + linemarkers = false + else + linemarkers = true + end + _g.linemarkers = linemarkers + end + -- do preprocess local cppfile = path.join(path.directory(objectfile), path.basename(objectfile) .. path.extension(sourcefile)) local cppfiledir = path.directory(cppfile) @@ -457,6 +468,9 @@ function _preprocess(program, argv, opt) os.mkdir(cppfiledir) end table.insert(cppflags, "-P") + if linemarkers == false then + table.insert(cppflags, "-EP") + end table.insert(cppflags, "-Fi" .. cppfile) table.insert(cppflags, sourcefile) return try{ function() diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 79bc6a776..f154fb1ee 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -448,6 +448,17 @@ function _preprocess(program, argv, opt) fdirectives_only = true end + -- disable linemarkers? + local linemarkers = _g.linemarkers + if linemarkers == nil then + if os.isfile(os.projectfile()) and project.policy("preprocessor.linemarkers") == false then + linemarkers = false + else + linemarkers = true + end + _g.linemarkers = linemarkers + end + -- do preprocess local cppfile = path.join(path.directory(objectfile), path.basename(objectfile) .. path.extension(sourcefile)) local cppfiledir = path.directory(cppfile) @@ -460,6 +471,9 @@ function _preprocess(program, argv, opt) if fdirectives_only then table.insert(cppflags, "-fdirectives-only") end + if linemarkers == false then + table.insert(cppflags, "-P") + end table.insert(cppflags, "-o") table.insert(cppflags, cppfile) table.insert(cppflags, sourcefile) |
