`os.findheader` support relative headerdirs
What does this PR do?
Let os.findheader can support searching relative paths.
Some libraries, by default, install header files within folders. For example, the header files for libfreetype-dev are located in:
/usr/include/freetype2/freetype/*.h
/usr/include/freetype2/ft2build.h
Previously, if a program included the header with #include <ft2build.h>, you had to use:
os.findheader("freetype2/ft2build.h") .. "freetype2"
to locate it.
Now you can simply use:
os.findheader("ft2build.h", "freetype2")
to achieve the same result.
How does this PR change Premake's behavior?
Nothing.
Anything else we should know?
Nothing.
Did you check all the boxes?
- [x] Focus on a single fix or feature; remove any unrelated formatting or code changes
- [x] Add unit tests showing fix or feature works; all tests pass
- [x] Mention any related issues (put
closes #XXXXin comment to auto-close issue when PR is merged) - [x] Follow our coding conventions
- [x] Minimize the number of commits
- [x] Align documentation to your changes
You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!
How does this PR change Premake's behavior?
Nothing.
In fact behavior changes
os.findheader("header.h", "./submodules/library")
would no longer search from local directory.
Maybe creating another API would be cleaner, something like
function os.findheaderleaf(name, userpaths)
local res = os.findheaderleaf(name, userpaths)
if res then
path.join(res, path.getdirectory(name))
else
return nil
end
end