summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiangang Song <[email protected]>2026-05-03 11:36:08 -0700
committerTiangang Song <[email protected]>2026-05-04 20:30:09 -0700
commitf484171b2ef5803e9a6b0cd944a16977f3e7863d (patch)
tree89042047fdfcb465e18f700725d107d98dfd4e26
parent8bbbb2860fdd1910db466fe318ee8d465728ca32 (diff)
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