Move clang pch to its own module - #7529
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors precompiled header (PCH) flag generation by moving Clang-specific logic from gcc.lua to clang.lua. New functions were added to clang.lua to handle C, C++, ObjC, and ObjC++ respectively. Feedback suggests improving the robustness of these new functions by using 'opt.target or opt' to retrieve the target object, ensuring consistency with existing patterns in the codebase.
| -- make the c precompiled header flag | ||
| function nf_pcheader(self, pcheaderfile, opt) | ||
| if self:kind() == "cc" then | ||
| local target = opt.target |
There was a problem hiding this comment.
To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.
local target = opt.target or opt
| -- make the c++ precompiled header flag | ||
| function nf_pcxxheader(self, pcheaderfile, opt) | ||
| if self:kind() == "cxx" then | ||
| local target = opt.target |
There was a problem hiding this comment.
To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.
local target = opt.target or opt
| -- make the objc precompiled header flag | ||
| function nf_pmheader(self, pcheaderfile, opt) | ||
| if self:kind() == "mm" then | ||
| local target = opt.target |
There was a problem hiding this comment.
To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.
local target = opt.target or opt
| -- make the objc++ precompiled header flag | ||
| function nf_pmxxheader(self, pcheaderfile, opt) | ||
| if self:kind() == "mxx" then | ||
| local target = opt.target |
There was a problem hiding this comment.
To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.
local target = opt.target or opt
This PR refactors clang pch related logic to its own module instead of hardcoded in gcc. This fixes pch support for tools that inherit from clang like zig cc.