Add toolsetpath API for specifying tool executable paths#2462
Open
tritao wants to merge 1 commit intopremake:masterfrom
Open
Add toolsetpath API for specifying tool executable paths#2462tritao wants to merge 1 commit intopremake:masterfrom
tritao wants to merge 1 commit intopremake:masterfrom
Conversation
8fd8b95 to
c0187fd
Compare
Introduces a new API function `toolsetpath(toolsetName, toolName, toolPath)` that allows users to specify custom paths for tool executables within their Premake scripts. This provides a mechanism to override the default tool lookup behavior for specific toolsets and tools, offering greater flexibility in build configurations. Changes include: - Registering the `toolsetpaths` field in `_premake_init.lua` to store the custom paths. - Implementing the `toolsetpath` function in `base/api.lua` to process and store the provided paths. - Modifying the `gettoolname` functions in the GCC, Clang, MSVC, SNC, .NET, and Emscripten toolset modules to check for and use paths defined via `toolsetpaths` before falling back to default lookup logic. - Adding tests in the corresponding toolset test files (`tests/tools/`) to verify that the `toolsetpath` setting correctly overrides the default behavior. - Creating a new documentation page (`website/docs/toolsetpath.md`) detailing the API function, its parameters, and usage. - Adding an entry for the new documentation page in the website sidebar (`website/sidebars.js`).
c0187fd to
315ca63
Compare
Jarod42
reviewed
Apr 24, 2025
| -- Check toolsetpaths first | ||
| if cfg.toolsetpaths and cfg.toolsetpaths[cfg.toolset] and cfg.toolsetpaths[cfg.toolset][tool] then | ||
| return cfg.toolsetpaths[cfg.toolset][tool] | ||
| end |
Contributor
There was a problem hiding this comment.
Would be fine to have something like:
function toolset.gettoolname(toolset, config, tool) to factorize that code.
but probably not possible as it is already used by exporters :-/
| -- flags correctly to emcc builds. | ||
| emcc.shared.profile = nil | ||
| emcc.ldflags.profile = nil | ||
| emcc.getsharedlibarg = function(cfg) return "" end |
Contributor
There was a problem hiding this comment.
Seems unrelated to that PR.
| -- Verify that toolsetpath overrides the default tool name. | ||
| -- | ||
| function suite.toolsetpathOverridesDefault() | ||
| toolset "clang" |
| test.isequal("/path/to/my/custom/clang", clang.gettoolname(cfg, "cc")) | ||
| end | ||
|
|
||
| -- |
Contributor
There was a problem hiding this comment.
toolsetpaths is not tested.
How it behaves if we mix toolsetpath and toolsetpaths?
At which level the table are merged?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a new API function
toolsetpath(toolsetName, toolName, toolPath)that allows users to specify custom paths for tool executables within their Premake scripts.This provides a mechanism to override the default tool lookup behavior for specific toolsets and tools, offering greater flexibility in build configurations.
Changes include:
toolsetpathsfield in_premake_init.luato store the custom paths.toolsetpathfunction inbase/api.luato process and store the provided paths.gettoolnamefunctions in the GCC, Clang, MSVC, SNC, .NET, and Emscripten toolset modules to check for and use paths defined viatoolsetpathsbefore falling back to default lookup logic.tests/tools/) to verify that thetoolsetpathsetting correctly overrides the default behavior.website/docs/toolsetpath.md) detailing the API function, its parameters, and usage.website/sidebars.js).