summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-27 00:43:47 +0800
committerruki <[email protected]>2026-01-27 00:43:47 +0800
commit8ba2870f97ce1213f4a95f95cee1e6b1369916c2 (patch)
treecb44954df589c6da4343738567af8cd0570fb19a
parent7f68201e903054c42a5820c3d9ede6851d9d8821 (diff)
fix pch header extension
-rw-r--r--xmake/modules/core/tools/gcc.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 6fc7a641b..9cc46e9f2 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -23,6 +23,7 @@ import("core.base.option")
import("core.base.tty")
import("core.base.colors")
import("core.base.global")
+import("core.base.hashset")
import("core.cache.memcache")
import("core.project.config")
import("core.project.policy")
@@ -980,13 +981,30 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt)
end
end
+-- check if the file is a header file
+function _is_header_file(extension)
+ if extension:startswith(".h") then
+ return true
+ end
+
+ local headerexts = _g.headerexts
+ if not headerexts then
+ local other_header_extensions = {
+ ".inl", ".ipp", ".tcc", ".tpl", ".inc"
+ }
+ headerexts = hashset.from(other_header_extensions)
+ _g.headerexts = headerexts
+ end
+ return headerexts:has(extension) or false
+end
+
-- make the compile arguments list
function compargv(self, sourcefile, objectfile, flags, opt)
opt = opt or {}
-- is precompiled header or module files? remove the force includes.
local extension = path.extension(sourcefile)
- if (extension:startswith(".h") or extension == ".inl") then
+ if _is_header_file(extension) then
flags = _translate_flags_for_pch(self, flags)
elseif support.has_module_extension(sourcefile, {extension = extension}) then
flags = _translate_flags_for_mpp(self, flags)