Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Sep 5, 2024

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.

@tritao tritao marked this pull request as ready for review September 5, 2024 14:21
@Jarod42
Copy link
Contributor

Jarod42 commented Sep 6, 2024

Should also apply to other toolsets (so currently dotnet and msc, as others use toolset.gcc)
Whereas premake-ninja doesn't support C# yet, it supports msc.

Copy link
Member

@nickclark2016 nickclark2016 left a 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.
@tritao
Copy link
Contributor Author

tritao commented Sep 16, 2024

Updated the msc and dotnet toolsets too, clang has no direct calls to project.getrelative and fowards to gcc.

@tritao tritao changed the title Introduce a gcc.getrelative toolset function to allow customization. Introduce a toolset getrelative toolset function to allow customization. Sep 16, 2024
src/tools/dotnet.lua Outdated Show resolved Hide resolved
@tritao
Copy link
Contributor Author

tritao commented Sep 17, 2024

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.

@nickclark2016
Copy link
Member

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)
Copy link
Contributor

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 :-(

Copy link
Contributor Author

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?

Copy link
Contributor

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))

Copy link
Contributor Author

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?

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants