-
-
Notifications
You must be signed in to change notification settings - Fork 617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a toolset getrelative
toolset function to allow customization.
#2244
base: master
Are you sure you want to change the base?
Conversation
Should also apply to other toolsets (so currently dotnet and msc, as others use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be applied to other toolsets (clang, msc)
This just centralizes all `getrelative`, allowing for customization by external code, by overriding this function. This is needed for instance in Ninja generators, where the location of a project is not the workspace location, but the code of the Ninja file itself should still refer to workspace-relative paths.
37d1cd0
to
6d817ad
Compare
Updated the |
gcc.getrelative
toolset function to allow customization.getrelative
toolset function to allow customization.
e0868af
to
2ad4923
Compare
Updated this again with some more thorough testing to at least make sure these exist and continue to exist for all toolsets. @nickclark2016 Please take another look when you have a chance. |
Will leave open for comment for a few days. Barring any change requests, will merge. Thank you! |
prepare() | ||
local toolset = p.config.toolset(cfg) | ||
print(toolset) | ||
test.isnotnil(toolset.getrelative) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your test is really unit,
and I think it doesn't test what you want to check, i.e clang.some_function_which_uses_getrelative()
calls actually clang.getrelative
(especially with gcc redirection)
And I think that test would currently fail :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what you mean by that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant, if user (or premake.ninja) does clang.getrelative = function (cfg, path) return p.workspace.getrelative(cfg.workspace, value) end
then clang.getincludedirs(cfg.includedirs, ..)
would call gcc.getincludedirs(cfg.includedirs, ..)
which will call
gcc.getrelative
and not clang.getrelative
.
As bug happens with premake.ninja, can you test your changes with problematic case (project location != workspace location) with clang toolset? (https://github.com/Jarod42/premake-sample-projects/tree/location/projects/project-location is one such project (not the main branch))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah thats an issue.
What do you think, should we forgo this approach and instead have a global overrideable p.tools.getrelative
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A priori, I don't see issue with p.tools.getrelative
This just centralizes all
project.getrelative
in the GCC toolset, allowing for customization by external code, by overriding this function.This is needed for instance in Ninja generators, when the location of a project is not the workspace location, but the code of the Ninja file itself should still refer to workspace-relative paths.