-
-
Notifications
You must be signed in to change notification settings - Fork 624
Add toolsetpath API for specifying tool executable paths #2462
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,13 @@ emcc.tools = { | |
-- flags correctly to emcc builds. | ||
emcc.shared.profile = nil | ||
emcc.ldflags.profile = nil | ||
emcc.getsharedlibarg = function(cfg) return "" end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems unrelated to that PR. |
||
|
||
function emcc.gettoolname(cfg, tool) | ||
-- 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 | ||
|
||
return emcc.tools[tool] | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,16 @@ | |
test.isequal("windres-16", clang.gettoolname(cfg, "rc")) | ||
end | ||
|
||
-- | ||
-- Verify that toolsetpath overrides the default tool name. | ||
-- | ||
function suite.toolsetpathOverridesDefault() | ||
toolset "clang" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it needed? |
||
toolsetpath("clang", "cc", "/path/to/my/custom/clang") | ||
prepare() | ||
test.isequal("/path/to/my/custom/clang", clang.gettoolname(cfg, "cc")) | ||
end | ||
|
||
-- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
-- Check Mac OS X deployment target flags | ||
-- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Specifies the path to a specific tool executable for a given toolset. This allows overriding the default tool lookup behavior of Premake. | ||
|
||
```lua | ||
toolsetpath(toolsetName, toolName, toolPath) | ||
``` | ||
|
||
### Parameters | ||
|
||
`toolsetName` | ||
: The name of the toolset (e.g., `"gcc"`, `"clang"`, `"msc"`). | ||
|
||
`toolName` | ||
: The name of the tool within the toolset (e.g., `"cc"` for C compiler, `"cxx"` for C++ compiler, `"ld"` for linker, `"ar"` for archiver). | ||
|
||
`toolPath` | ||
: The absolute or relative path to the tool executable. | ||
|
||
### Applies To | ||
|
||
Project configurations. | ||
|
||
### Example | ||
|
||
```lua | ||
project "MyProject" | ||
kind "ConsoleApp" | ||
language "C++" | ||
system "Linux" | ||
|
||
configuration "Release" | ||
toolset "gcc" | ||
-- Specify a custom path for the GCC C++ compiler | ||
toolsetpath("gcc", "cxx", "/opt/my_custom_gcc/bin/g++") | ||
|
||
configuration "Debug" | ||
toolset "clang" | ||
-- Specify a custom path for the Clang C compiler | ||
toolsetpath("clang", "cc", "/usr/local/clang-15/bin/clang") | ||
``` | ||
|
||
In this example, the `toolsetpath` function is used to specify custom paths for the C++ compiler in the "Release" configuration (using GCC) and the C compiler in the "Debug" configuration (using Clang). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Specifies custom paths for tool executables for one or more toolsets using a nested table structure. This field is primarily intended for internal use by Premake modules and actions. **End users should generally prefer using [`toolsetpath`](toolsetpath.md)** for specifying custom tool paths, as it provides a more user-friendly syntax. | ||
|
||
```lua | ||
toolsetpaths { | ||
["toolsetName"] = { | ||
["toolName"] = "toolPath", | ||
-- ... more tools for this toolset | ||
}, | ||
-- ... more toolsets | ||
} | ||
``` | ||
|
||
### Parameters | ||
|
||
The `toolsetpaths` field accepts a table where keys are `toolsetName` (the name of the toolset, e.g., `"gcc"`, `"clang"`, `"msc"`) and values are nested tables. | ||
|
||
The nested tables have `toolName` (the name of the tool within the toolset, e.g., `"cc"` for C compiler, `"cxx"` for C++ compiler, `"ld"` for linker, `"ar"`) as keys and `toolPath` (the absolute or relative path to the tool executable) as values. | ||
|
||
### Applies To | ||
|
||
Project configurations. | ||
|
||
### Example | ||
|
||
```lua | ||
project "MyProject" | ||
kind "ConsoleApp" | ||
language "C++" | ||
system "Linux" | ||
|
||
configuration "Release" | ||
toolset "gcc" | ||
-- Example of using the toolsetpaths field (less common for end users) | ||
toolsetpaths { | ||
gcc = { | ||
cc = "/opt/my_custom_gcc/bin/gcc", | ||
cxx = "/opt/my_custom_gcc/bin/g++", | ||
ar = "/opt/my_custom_gcc/bin/ar" | ||
} | ||
} | ||
|
||
configuration "Debug" | ||
toolset "clang" | ||
-- Prefer using the toolsetpath function for clarity | ||
toolsetpath("clang", "cc", "/usr/local/clang-15/bin/clang") | ||
toolsetpath("clang", "ld", "/usr/local/clang-15/bin/ld") | ||
``` | ||
|
||
In this example, both the `toolsetpaths` field and the `toolsetpath` function are shown. The `toolsetpath` function is the recommended approach for end users. | ||
|
||
### See Also ### | ||
|
||
* [toolsetpath](toolsetpath.md) |
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.
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 :-/