xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.87k stars 776 forks source link

Make binary target the startup project in vsxmake generator if possible #5401

Closed xq114 closed 2 months ago

xq114 commented 2 months ago

你在什么场景下需要该功能?

在vsxmake 生成vs项目时,默认的target顺序与xmake中一致,这样vs会选择第一个target作为默认startup target;然而第一个target通常并不是binary,如果第一个target是phony类型,打开直接点运行就会报错 无法启动程序 xxx 。(因为xxx并不存在)

描述可能的解决方案

https://stackoverflow.com/questions/694730/why-is-set-as-startup-option-stored-in-the-suo-file-and-not-the-sln-file

vs将startup信息存在.suo文件(二进制数据)里,不好修改,但可以调整target顺序来指定默认startup target。这样当项目中有binary类型时,将其中一个放到.sln里第一位即可指定为default startup target,直接打开点运行就可以。

描述你认为的候选方案

从xmake run的默认行为(比如跑哪些target)出发,将这些target设置为startup target,存到.suo里,但尚不清楚做法

其他信息

No response

xq114 commented 2 months ago

https://github.com/xmake-io/xmake/issues/2969 或者存在 BuildAll 时把BuildAll作为第一个;但 BuildAll 如果是phony target,点运行还是会报错。有没有什么办法在试图运行phony target的时候给出正确的报错信息?

waruqi commented 2 months ago

但可以调整target顺序来指定默认startup target。这样当项目中有binary类型时,将其中一个放到.sln里第一位即可指定为default startup target,直接打开点运行就可以。

原本就有做处理,如果不 work ,可以调下这里

https://github.com/xmake-io/xmake/blob/69ea60450564fc93c65f111b526c872689656f9c/xmake/plugins/project/vsxmake/getinfo.lua#L582

Issues-translate-bot commented 2 months ago

Bot detected the issue body's language is not English, translate it automatically.


But the target order can be adjusted to specify the default startup target. In this way, when there is a binary type in the project, put one of them first in .sln and specify it as the default startup target. Just open it and run it.

It is already processed. If it does not work, you can adjust it here.

https://github.com/xmake-io/xmake/blob/69ea60450564fc93c65f111b526c872689656f9c/xmake/plugins/project/vsxmake/getinfo.lua#L582