通过使用特定于平台的项目文件或使用项目生成器来构建自动化?
有一些构建系统能够生成特定于平台的项目文件,例如 Visual Studio sln
、vcproj
、vcxproj
文件或 XCode< OS X 下的 /code>
xcodeproj
项目。
其中之一是 CMake,但我发现对此的支持非常有限,有缺陷,而且很难用较新的版本(如 VS)保持更新2010)。
此外,至少 CMake 缺少对 Visual Studio 属性页的支持,这使得管理和更改项目范围的配置变得更加困难 - 例如为所有项目启用/禁用代码分析。
解决上述问题的方法是为每个平台手动创建项目文件 - 在我的例子中只有两个,但即使有更多,数量也不应该太大。
将特定于平台的构建命令调用到通用构建自动化脚本中非常容易。例如,我使用 waf
(Python) 在几个项目上自动执行此操作,而不使用其自己的构建部分。
我想看看您会选择什么:尝试修复/维护项目生成器或保留单独的项目文件?
There are some build systems that are able to generate platform specific project files like Visual Studio sln
,vcproj
,vcxproj
files or XCode
xcodeproj
projects under OS X.
One of them is CMake but I found out that the support for this is quite limited, buggy and that is very hard to keep it updated with newer versions (like VS 2010).
Also, at least CMake, is missing support for property pages for Visual Studio and this makes harder to manage and change project wide configurations - like enabling/disabling Code Analysis for all projects.
An workaround to the above issue is to manually create project files for each platform - in my case there are only two, but even with more the number should not be so big.
It is quite easy to call the platform specific build commands into a generic build automation script. For example I used waf
(Python) for automating this on few projects without using its own build part.
I would like to see what you would choose between: trying to repair/maintain project generators or keeping separated project files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我们所做的,它可能不是最好的方法,但它对我们来说确实很好,我们发现维护起来并不太难,也许你会觉得它很有趣。
我们的主要平台是windows,几乎所有的开发都是在VS IDE中完成的。对于其他平台(目前只有一些 Linux 版本),我们专门使用 CMake。基本上我们选择了“尝试修复/维护项目生成器”方式,但以 Visual Studio 项目文件作为起点。
我们最近开始使用VS2010,迁移只花了大约一天的时间:首先我们让VS转换我们所有的项目和属性表,然后我们对脚本进行一些调整以处理新的xml文件格式。
编辑
抱歉,我无法发布脚本、公司政策,希望您理解。
不过,一点伪代码没有问题。在 VS2008 项目文件中添加/删除属性表如下:
对于 CMakeLists 文件,这几乎是相同的,除了脚本在“include(..)”行上工作。
从 vcproj 转换为 CMakeLists:
构建服务器现在是相当先进的材料,但一开始它只是一个 TCP 侦听器:
Here's what we do, it might not be the best way, but it works really good for us and we found that it's not too hard to maintain, maybe you find it interesting.
Our main platform is windows, nearly all development is done in the VS IDE. For the other platforms (only some linux flavors for now) we use CMake exclusively. Basically we chose the "trying to repair/maintain project generators" way, but with Visual Studio project files as a starting point.
We recently started using VS2010, and the migration only took about a day: first we let VS convert all our projects and property sheets, then we made some adjustments to the scripts to handle the new xml file formats.
Edit
sorry but I cannot post the scripts, company policy, hope you understand.
A bit of pseudocode is no problem though. Adding/removing property sheets in VS2008 project files goes like this:
For the CMakeLists files this is pretty much the same, except the script works on the 'include(..)' lines.
Convertig from vcproj to CMakeLists:
The build server is quite advanced material now, but in the beginning it was just a TCP listener:
我的所有项目都是跨平台的,我更喜欢解决方法。
使用 Scons 维护跨平台项目几乎不需要任何工作。一个良好定义的环境适用于大多数项目,并为每个项目/子项目使用一个模板。您还可以完全控制构建过程,从而轻松使用领域特定语言、进行代码生成、管理源代码控制。
当你了解Python时,学习Scons非常简单,如果不了解Python,你就会发现两种伟大的技术,而不是一种;)
All my projects are cross platform, and my preference is the workaround.
With Scons maintaining a cross platform project is little or no work. One good defined environment will work for most project, and use a template for each project/subproject. You also have the benefit of complete control over the building process, allowing you to use domain specific languages, do code generation, manage source control, with ease.
Learning Scons is dead simple when you know python, without knowing python, you are disconvering two great technologies not one ;)
我们将 boost.build 用于我们的平台项目。它适用于 C++ 库项目。我们喜欢它,因为我们只需要维护一个脚本,并且它与 Boost.Test 集成得很好。
它确实有一个非常陡峭的学习曲线,而且文档也很差。但它在我们工作的两个平台 Windows 和 Linux 上运行良好。
We use boost.build for our platform projects. It works well for C++ library projects. We like it because we only need to maintain one script and it integrates with Boost.Test well.
It does have a very steep learning curve and the documentation is quite poor. But it does its work well on Windows and Linux, the two platforms that we work on.