summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-05-05 21:53:23 +0800
committerGitHub <[email protected]>2026-05-05 21:53:23 +0800
commitd76ec6af28e29921a986662f1d823a3a3a372f4b (patch)
treefd1d8b42e3e4b59a4342cc9b0d1ebb28ebb74cc9
parent32560e55682648c7b92ee05f804a4dfdfbc168e5 (diff)
parentf484171b2ef5803e9a6b0cd944a16977f3e7863d (diff)
Merge pull request #7529 from tgsong/fix-clang-pch
Move clang pch to its own module
-rw-r--r--xmake/modules/core/tools/clang.lua36
-rw-r--r--xmake/modules/core/tools/gcc.lua24
2 files changed, 40 insertions, 20 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 17e0f6cd6..1250d1a46 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -292,3 +292,39 @@ function nf_runtime(self, runtime, opt)
end
return maps and maps[runtime]
end
+
+-- make the c precompiled header flag
+function nf_pcheader(self, pcheaderfile, opt)
+ if self:kind() == "cc" then
+ local target = opt.target
+ local pcoutputfile = target:pcoutputfile("c")
+ return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
+ end
+end
+
+-- make the c++ precompiled header flag
+function nf_pcxxheader(self, pcheaderfile, opt)
+ if self:kind() == "cxx" then
+ local target = opt.target
+ local pcoutputfile = target:pcoutputfile("cxx")
+ return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
+ end
+end
+
+-- make the objc precompiled header flag
+function nf_pmheader(self, pcheaderfile, opt)
+ if self:kind() == "mm" then
+ local target = opt.target
+ local pcoutputfile = target:pcoutputfile("m")
+ return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
+ end
+end
+
+-- make the objc++ precompiled header flag
+function nf_pmxxheader(self, pcheaderfile, opt)
+ if self:kind() == "mxx" then
+ local target = opt.target
+ local pcoutputfile = target:pcoutputfile("mxx")
+ return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
+ end
+end
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 43d51a1e1..3bd9aefef 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -848,11 +848,7 @@ function nf_pcheader(self, pcheaderfile, opt)
if self:kind() == "cc" then
local target = opt.target
local pcoutputfile = target:pcoutputfile("c")
- if self:name():startswith("clang") then
- return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
- else
- return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
- end
+ return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
end
end
@@ -861,11 +857,7 @@ function nf_pcxxheader(self, pcheaderfile, opt)
if self:kind() == "cxx" then
local target = opt.target
local pcoutputfile = target:pcoutputfile("cxx")
- if self:name():startswith("clang") then
- return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
- else
- return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
- end
+ return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
end
end
@@ -874,11 +866,7 @@ function nf_pmheader(self, pcheaderfile, opt)
if self:kind() == "mm" then
local target = opt.target
local pcoutputfile = target:pcoutputfile("m")
- if self:name():startswith("clang") then
- return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
- else
- return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
- end
+ return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
end
end
@@ -887,11 +875,7 @@ function nf_pmxxheader(self, pcheaderfile, opt)
if self:kind() == "mxx" then
local target = opt.target
local pcoutputfile = target:pcoutputfile("mxx")
- if self:name():startswith("clang") then
- return {"-include", pcheaderfile, "-include-pch", pcoutputfile}
- else
- return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
- end
+ return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)}
end
end