使用Visual Studio进行跨平台开发的最佳方法是什么?

时间:2022-09-01 08:07:36

We are developing a number of games on multiple paltforms (DS/Wii/Xbox 360/PS3/PC/PSP). Each has their own compiler/linker and debugger. We want to use Visual Studio as the IDE and to manage the build process but use the platform specific compilers (and settings) to generate the appropriate output. We could manage the build process outside of VS (using jam or ant say) but this is not the preffered solution.

我们正在开发多种游戏(DS / Wii / Xbox 360 / PS3 / PC / PSP)。每个都有自己的编译器/链接器和调试器。我们希望使用Visual Studio作为IDE并管理构建过程,但使用特定于平台的编译器(和设置)来生成适当的输出。我们可以在VS之外管理构建过程(使用jam或ant),但这不是优先解决方案。

Trawling the web, this seems to be a common problem but no-one has a good solution. Has anyone solved this problem? What's the best way of handling this.

在网上搜索,这似乎是一个常见的问题,但没有人有一个很好的解决方案。有人解决了这个问题吗?处理这个问题的最佳方法是什么。

A number of solutions spring to mind - auto-generate nant scripts from the solition in a pre-build step (probably the least work but still not ideal), replace cl.exe and link.exe with stub apps, use msbuild (but this is geared towards .net development and not native code), write a custom VS plug-in (lots of work - any pointers to an existing one either commercial or open soruce would be good). Anyone tried any of these? Was it good for you? ;)

我想到了许多解决方案 - 在预构建步骤中从solition自动生成nant脚本(可能是最少的工作但仍然不理想),用存根应用替换cl.exe和link.exe,使用msbuild(但是这个编写一个自定义的VS插件(很多工作 - 任何指向现有的商业或开放式的指针都会很好)是面向.net开发而不是本机代码的。有人试过这些吗?对你有好处吗? ;)

Cheers

4 个解决方案

#1


2  

CMake doesn't do what I'm after. To be clear - when I say "manage the build process" I mean, anyone can grab the project from the repository then from within VS select the platform, compile/run, add files, change settings, etc and it all work by magic ;) So to answer my own question, after a bit of digging this is what I've come up with.

CMake没有做我想做的事。要清楚 - 当我说“管理构建过程”时,我的意思是,任何人都可以从存储库中获取项目,然后从VS中选择平台,编译/运行,添加文件,更改设置等,这一切都可以通过魔法工作; )所以回答我自己的问题,经过一番挖掘,这就是我想出来的。

The 'correct' way to do this is to write a plug-in for VS that adds a new platform which would appear in the configuration manager (as they did for the Xbox, Pocket PC, etc). Unfortunately it would appear that Microsoft in their infinite wisdom have decided not to expose the API for this particular feature to the great unwashed.

“正确”的方法是为VS编写一个插件,添加一个新平台,该平台将出现在配置管理器中(就像他们为Xbox,Pocket PC等所做的那样)。不幸的是,似乎微软凭借其无限的智慧决定不将这一特定功能的API暴露给未经洗涤的伟大。

However, you can write an add-in and in parallel replace cl.exe and link.exe with stub programs which dispatch the actual compliation to the appropriate compilers. It appears there's an open source project VSItanium for this (2003 only though and would have to be modified for custom compilers). Also SNSystems do this with their VSI package for the PSP.

但是,您可以编写加载项并同时将cl.exe和link.exe替换为存根程序,这些存根程序会将实际的编译程序发送给相应的编译器。看起来有一个开源项目VSItanium(仅2003年,并且必须针对自定义编译器进行修改)。 SNSystems也为他们的PSP VSI包做到了这一点。

It would take some time to write a plug-in so in the meantime a quick stop-gap solution is to write a script that parses the solution and project files and pulls out the important bits and generates files to be included by nant (or make, or jam or whatever) - called from a per-build step. Either that or go down the whole makefile solution route :/

编写插件需要一些时间,因此在此期间快速的间隙解决方案是编写一个脚本来解析解决方案和项目文件并提取重要位并生成要包含在nant中的文件(或制作,或堵塞或其他) - 从每个构建步骤调用。无论是那个还是整个makefile解决方案路线:/

MSBuild really should be the way forward. I had a quick play with it and you can (almost) do everything I want but somehow it jsut didn't quite gel. Kept thinking it was a C# project - maybe need to spend more time wit it, unless any MSBuild gurus want to point me in the right direction.

MSBuild确实应该是前进的方向。我有一个快速的玩它,你可以(几乎)做我想要的一切,但不知何故它jsut不太凝胶。保持认为这是一个C#项目 - 可能需要花更多的时间来理解它,除非任何MSBuild大师都想指出我正确的方向。

#2


1  

Have you looked at CMake? It can generate Visual Studio project files from a textual description.

你看过CMake吗?它可以从文本描述生成Visual Studio项目文件。

#3


1  

Another options which is used on the Homebrew PSP SDK (MinPSPW) is to use Makefile projects. You use the code editor from VS but in the end when you invoke the compiler it will use the correct compiler based on your makefile. Most of the output errors will be catched up by VS and highlighted on your sources.

Homebrew PSP SDK(MinPSPW)上使用的另一个选项是使用Makefile项目。您使用VS中的代码编辑器,但最后在调用编译器时,它将使用基于您的makefile的正确编译器。大多数输出​​错误将由VS捕获并在您的源上突出显示。

#4


0  

Seconded the recommendation for CMake, with the caveat that you're not going to be able to manage projects in VS for other platforms. It's just not written to manage library paths, defines, etc etc for anything other than the current project/target/platform. You'll almost certainly need to say "platform X's libraries live here", and I just don't see a way of doing that through VS.

支持CMake的建议,但需要注意的是,您无法在VS中管理其他平台的项目。除了当前项目/目标/平台之外,其他任何内容都不是为了管理库路径,定义等而编写的。你几乎肯定需要说“平台X的库存在这里”,我只是没有看到通过VS做到这一点的方法。

#1


2  

CMake doesn't do what I'm after. To be clear - when I say "manage the build process" I mean, anyone can grab the project from the repository then from within VS select the platform, compile/run, add files, change settings, etc and it all work by magic ;) So to answer my own question, after a bit of digging this is what I've come up with.

CMake没有做我想做的事。要清楚 - 当我说“管理构建过程”时,我的意思是,任何人都可以从存储库中获取项目,然后从VS中选择平台,编译/运行,添加文件,更改设置等,这一切都可以通过魔法工作; )所以回答我自己的问题,经过一番挖掘,这就是我想出来的。

The 'correct' way to do this is to write a plug-in for VS that adds a new platform which would appear in the configuration manager (as they did for the Xbox, Pocket PC, etc). Unfortunately it would appear that Microsoft in their infinite wisdom have decided not to expose the API for this particular feature to the great unwashed.

“正确”的方法是为VS编写一个插件,添加一个新平台,该平台将出现在配置管理器中(就像他们为Xbox,Pocket PC等所做的那样)。不幸的是,似乎微软凭借其无限的智慧决定不将这一特定功能的API暴露给未经洗涤的伟大。

However, you can write an add-in and in parallel replace cl.exe and link.exe with stub programs which dispatch the actual compliation to the appropriate compilers. It appears there's an open source project VSItanium for this (2003 only though and would have to be modified for custom compilers). Also SNSystems do this with their VSI package for the PSP.

但是,您可以编写加载项并同时将cl.exe和link.exe替换为存根程序,这些存根程序会将实际的编译程序发送给相应的编译器。看起来有一个开源项目VSItanium(仅2003年,并且必须针对自定义编译器进行修改)。 SNSystems也为他们的PSP VSI包做到了这一点。

It would take some time to write a plug-in so in the meantime a quick stop-gap solution is to write a script that parses the solution and project files and pulls out the important bits and generates files to be included by nant (or make, or jam or whatever) - called from a per-build step. Either that or go down the whole makefile solution route :/

编写插件需要一些时间,因此在此期间快速的间隙解决方案是编写一个脚本来解析解决方案和项目文件并提取重要位并生成要包含在nant中的文件(或制作,或堵塞或其他) - 从每个构建步骤调用。无论是那个还是整个makefile解决方案路线:/

MSBuild really should be the way forward. I had a quick play with it and you can (almost) do everything I want but somehow it jsut didn't quite gel. Kept thinking it was a C# project - maybe need to spend more time wit it, unless any MSBuild gurus want to point me in the right direction.

MSBuild确实应该是前进的方向。我有一个快速的玩它,你可以(几乎)做我想要的一切,但不知何故它jsut不太凝胶。保持认为这是一个C#项目 - 可能需要花更多的时间来理解它,除非任何MSBuild大师都想指出我正确的方向。

#2


1  

Have you looked at CMake? It can generate Visual Studio project files from a textual description.

你看过CMake吗?它可以从文本描述生成Visual Studio项目文件。

#3


1  

Another options which is used on the Homebrew PSP SDK (MinPSPW) is to use Makefile projects. You use the code editor from VS but in the end when you invoke the compiler it will use the correct compiler based on your makefile. Most of the output errors will be catched up by VS and highlighted on your sources.

Homebrew PSP SDK(MinPSPW)上使用的另一个选项是使用Makefile项目。您使用VS中的代码编辑器,但最后在调用编译器时,它将使用基于您的makefile的正确编译器。大多数输出​​错误将由VS捕获并在您的源上突出显示。

#4


0  

Seconded the recommendation for CMake, with the caveat that you're not going to be able to manage projects in VS for other platforms. It's just not written to manage library paths, defines, etc etc for anything other than the current project/target/platform. You'll almost certainly need to say "platform X's libraries live here", and I just don't see a way of doing that through VS.

支持CMake的建议,但需要注意的是,您无法在VS中管理其他平台的项目。除了当前项目/目标/平台之外,其他任何内容都不是为了管理库路径,定义等而编写的。你几乎肯定需要说“平台X的库存在这里”,我只是没有看到通过VS做到这一点的方法。