diff options
| author | ruki <[email protected]> | 2023-07-04 23:02:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-07-04 23:02:05 +0800 |
| commit | 6b5f9eca01dfa8cd654014ba537e59a8f2eceeb6 (patch) | |
| tree | 8a467b656d8eadc481698225e9c2dda1c48df424 /xmake/modules | |
| parent | 92f26e98978d36475e49762114fd92c0a2324767 (diff) | |
add objc pch header support #3912
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index b33bf0677..35b296ef0 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -335,7 +335,7 @@ end -- make the c precompiled header flag function nf_pcheader(self, pcheaderfile, target) - if self:kind() == "cc" or self:kind() == "mm" then + if self:kind() == "cc" then local pcoutputfile = target:pcoutputfile("c") if self:name() == "clang" then return {"-include", pcheaderfile, "-include-pch", pcoutputfile} @@ -347,7 +347,7 @@ end -- make the c++ precompiled header flag function nf_pcxxheader(self, pcheaderfile, target) - if self:kind() == "cxx" or self:kind() == "mxx" then + if self:kind() == "cxx" then local pcoutputfile = target:pcoutputfile("cxx") if self:name() == "clang" then return {"-include", pcheaderfile, "-include-pch", pcoutputfile} @@ -357,6 +357,30 @@ function nf_pcxxheader(self, pcheaderfile, target) end end +-- make the objc precompiled header flag +function nf_pmheader(self, pcheaderfile, target) + if self:kind() == "mm" then + local pcoutputfile = target:pcoutputfile("m") + if self:name() == "clang" then + return {"-include", pcheaderfile, "-include-pch", pcoutputfile} + else + return {"-include", path.filename(pcheaderfile), "-I", path.directory(pcoutputfile)} + end + end +end + +-- make the objc++ precompiled header flag +function nf_pmxxheader(self, pcheaderfile, target) + if self:kind() == "mxx" then + local pcoutputfile = target:pcoutputfile("mxx") + if self:name() == "clang" then + return {"-include", pcheaderfile, "-include-pch", pcoutputfile} + else + return {"-include", path.filename(pcheaderfile), "-I", path.directory(pcoutputfile)} + end + end +end + -- add the special flags for the given source file of target -- -- @note only it called when fileconfig is set @@ -631,6 +655,9 @@ function _compargv_pch(self, pcheaderfile, pcoutputfile, flags) if self:kind() == "cxx" then table.insert(pchflags, "-x") table.insert(pchflags, "c++-header") + elseif self:kind() == "mxx" then + table.insert(pchflags, "-x") + table.insert(pchflags, "objective-c++-header") end -- make the compile arguments list |
