add global interface "set_default_target"#65
Conversation
add global interface "set_default_target" to let it be able to override target "all" when target isn't specified partly supported by task "build"
|
You can pass the given target name to build or install it. For example: # only build target: bg
$ xmake build bg
# only install target: bg
$ xmake install bg
# only uninstall target: bg
$ xmake uninstall bg |
|
I have added Please try it from the lastest commit from dev branch. For example: target("test1")
set_default(false)
target("test2")
set_default(true)
target("test3")
...If you run commands:
And you can also force to build and install all targets: $ xmake [-a|--all]
$ xmake install [-a|--all]
$ xmake run [-a|--all]I do not apply it to other task like "xmake uninstall", "xmake clean". : ) |
|
Good but I think specifying for each target is a bit cumbersome. Why not a global setting interface? If multiple default has meanings, I think it would be simpler to be |
|
I don't want to add too much apis to global scope and this interface name is a little long. You don't need to set default for each target. All targets will be built by default if don't call You can only call -- it will be built and install by default
target("test1")
...
-- it will be built and install by default
target("test2")
...
-- only `test3` target will be not built and install by default
target("test3")
set_default(false)You need only to set one target. |
|
I know your meaning, but I'm afraid that you don't get my point. My meaning is that to disable target is used more usual than to enable a target, so api to enable could only set once but to disable need to set many times. Also, if one project don't do anything special about this, the behavior will be compatible with older versions as well. |
|
I know, but I think that to enable target is used more usual than to disable a target. And I rarely see the need to manually disable a target. : ) |
|
All right, maybe you're right 😺 I keep my opinion. |
|
I think $ xmake build all
error: assertion failed! |
|
You can try run May be conflict with |
|
I see |
|
And then I thought about it. You can also disable all targets in the root scope and only enable target you need. for example: -- disable all targets by default
set_default(false)
-- only `test1` target will be built and install by default
target("test1")
set_default(true)
-- other targets will be not built and install by default
for _, name in ipairs({"test2", "test3", "test4" ... }) do
target(name)
...
end |
|
😸 |
This pull is a feature adding.
Sometimes I don't want end-users to build all targets by default. Just like my libBG project, the "bg" target for building library is main, and other targets for building test program is meaningless to end-users. So I think it would be better to add a interface to let people like me choose default target manually.
This "set_default_target" is applied to task "build", "package", "install" and "run". I do not apply it to other task like "uninstall" because it might trouble end-user. (They always like to uninstall everything)
Design is that just do such work to
xmake.luajust likeset_projectis OK:Then the default target will be "bg" instead of "all".