-
-
Notifications
You must be signed in to change notification settings - Fork 790
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
[Feature request] XMake doesn't trigger an error when using an invalid mode #1523
Comments
Because users can set custom modes, xmake will not provide any mode definition standards. $ xmake f -m mymode if is_mode("mymode") then
add_defines("xxxx")
end or user can add custom mode rule, mode.asan mode.debug and so on are just some common mode rules provided by xmake to help users simplify, but they are not standard, and it does not mean that users can only set these modes. Users can also not use them at all and define the debug/release mode rules by themselves. Therefore, xmake will not do any check, because any mode is normal. The user can use rule to define them, or directly use |
It seems weird because if one doesn't use
set_allowedmodes("asan", "debug", "releasedbg")
set_allowedarchs("x86", "x86_64")
I know we can do that ourself in a script, but I'm thinking this could also be used by xmake to set the default mode/arch (to the first entry of allowedX for example), it would also help to set custom modes for VS projects (as I don't think this is possible otherwise?). Plus this would not break compatibility as project not calling set_allowedX would behave like they do now. What do you think? Edit: alternative way of setting the default: set_allowedmodes("asan", "debug", "releasedbg", { default = "debug" })
set_allowedarchs("x86", "x86_64", { debug = "x86_64" }) |
add_rules("mode.debug") only provides a way to quickly configure common debug mode configurations, but it is not the only way. Many of our projects will completely customize the debug mode and do not use mode.debug rules, for example: if is_mode("debug") then
set_optimize("none")
add_defines("xxxx")
end
Of course, if the project author wants to limit the collection of modes and architectures, I can also consider supporting it in the future. |
Oh ok, I though builtin rules were somewhat special, but from xmake internals it seems all you have to do is add a rule named However it seems not to be true for arch, so yeah, here's a feature request:
-- example
set_allowedmodes("asan", "debug", "releasedbg")
set_allowedarchs("x86", "x86_64")
set_allowedmodes("asan", "debug", "releasedbg", { default = "debug" })
set_allowedarchs("x86", "x86_64", { debug = "x86_64" }) Or maybe: set_allowedmodes("asan", "debug", "releasedbg")
set_allowedarchs("x86", "x86_64")
set_defaultmode("debug")
set_defaultarch("x86_64") (adding set_defaultmode and set_defaultarch would allow one to set a default mode/arch without forcing a list of allowed values).
|
I have supported it, can you try it first? #1527 add_allowedmodes("releasedbg", "debug", {default = "releasedbg"})
add_allowedplats("windows", "mingw", {default = "windows"})
add_allowedplats("windows", "mingw", "linux", "macosx")
add_allowedarchs("arm64", "x86_64", {plat = "macosx", default = "arm64"})
add_allowedarchs("i386", {plat = "linux"}) |
Amazing! I'm trying to update to the allowed branch but it seems I can't
Also, I see that you went for the {default=""} option, after thinking about it, wouldn't |
I have improved it. set_defaultmode("releasedbg")
set_defaultplat("linux")
set_defaultarchs("macosx|arm64", "linux|i386", "armv7")
set_allowedmodes("releasedbg", "debug")
set_allowedplats("windows", "linux", "macosx")
set_allowedarchs("macosx|arm64", "macosx|x86_64", "linux|i386", "linux|x86_64")
|
It seems to work great, except for one thing. set_defaultmode("debug")
set_allowedmodes("asan", "debug", "releasedbg")
set_allowedplats("windows", "linux", "macosx")
set_allowedarchs("windows|x64", "linux|x86_64", "macosx|x86_64") I added this to my project, and then ran
It's still generating x86 project here. |
I have improved it, try it again, |
Works great, I found no remaining issue. 👍 |
ok |
I have a xmake project using the following:
So only asan, debug and releasedbg modes. When generating a VS project only those appears in the list for example.
However, when running xmake on a clean folder, it defaults to the "release" mode, which is not configured correctly since I only expect "releasedbg".
That's the first issue, I would expect xmake to default to either debug or releasedbg. Maybe a
set_defaultmode
would help?The second issue is that when you make a typo, xmake doesn't care (notice the missing d):
XMake allows unknown mode without warning/error, which is weird.
This is kinda a follow-up of #1503, as xmake doesn't trigger any warning/error when an invalid (or unexpected) arch is set (for example ("x64" on Linux, which would mostly work but will fail for some things such as xmake run as detailed in #1503).
I think XMake should warn the user when a mistake like this is made, otherwise xmake behavior can be unsettling.
The text was updated successfully, but these errors were encountered: