C ++构建系统 - 使用什么? [英] C++ Build Systems - What to use?

查看:148
本文介绍了C ++构建系统 - 使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待在C ++中开始一个新项目 - 最初只是在我自己的时间 - 我调查了可用的构建系统。这样看来,答案是很多,他们都是可怕的。

I'm looking at starting a new project in C++ - just in my own time initially - and I'm investigating the build systems that are available. It would appear that the answer is "Many, and they're all awful".

这是我特别需要这种特点是:

The features that I specifically need for this are:


  1. C ++ 11的支持

  2. 跨平台(Linux作为主要对象,但能够建立在至少Windows和)

  3. 体面单元测试支持

  4. 为多个模块支持分离code OUT

  5. 为code代(使用ASN1C或protobuf的 - 不是100%肯定没有)支持

  6. 易于维护

现在,我知道我能做到使用的CMake和Autotools的很轻松了那些1-4。或许还与使用SCons和WAF和其他几个了。问题是,我从来没有制定出如何使用它们正确地做code一代 - 这是源文件不存在,直到生成过程是第一次运行,所以源文件编译系统必须能够转换为可执行code,但实际上并不知道,直到构建开始......(ASN1C尤其是产生几十头文件和源文件必须能够一起工作,和文件的实际集中生成依赖于内容cmake并自动工具有自己庞大的一套脚本,你需要管理他们的工作,和WAF和使用SCons要求任何人与他们的合作已经 - 您的ASN文件还有一个事实,即这些都不是特别容易维护)蟒蛇体面知识(我不)与他们合作...

Now, I know I can do 1-4 of those using CMake and Autotools easily enough. Probably also with SCons and Waf and the couple of others too. The problem is that I've never worked out how to correctly do code generation using them - that is source files that do not exist until the build process is first run, so source files that the build system must be able to convert into executable code but doesn't actually know about until the build starts... (ASN1C in particular generates dozens of header and source files that must be able to work together, and the actual set of files generates depends on the contents of your asn file) There's also the fact that none of these are especially easy to maintain - CMake and Autotools have their own huge set of scripts that you need to manage for them to work, and Waf and Scons require that anybody working with them has decent knowledge of python (I don't) to work with them...

那么 - 构建系统,建议这样的事情?或者将我的make文件和Shell脚本被卡住现在?

So - what build systems are recommended for something like this? Or will I be stuck with make files and shell scripts for now?

推荐答案

+1,很多,他们是可怕的。

+1 for, "Many, and they're awful."

但是,在最富有的和最可扩展可能是 CMake的的,这是一种生成文件发生器(也产生本机MSVC ++ *。凸出 / *。SLN )。奇怪的语法,但一旦你了解它,它可以让你很好地建立产生不同的平台。如果我开始新鲜,我可能会使用 CMake的。它应该处理您的名单,虽然你的code一代可能取决于你想做的事采取一个生命 - - 它 - 自己的超越了构建系统。 (见下文)。

But, the "richest" and "most-scalable" is probably CMake, which is a Makefile-generator (also generates native MSVC++ *.proj/*.sln). Weird syntax, but once you learn it, it can allow you to nicely generate builds for different platforms. If I "started-fresh", I'd probably use CMake. It should handle your list, although your "code-generation" could take on "a-life-of-its-own" beyond the build system depending on what you want to do. (See below.)

对于简单的项目, QMAKE 发电机OK(你不需要使用Qt库使用QMAKE )。但是,你没有描述简单 - code生成和超阶段是指你可能想 CMake的或你自己了丰富的API东西扩展功能,如使用SCons (或 WAF )。

For simple projects, the QMake generator is ok (you don't need to use the Qt libraries to use QMake). But, you're not describing "simple" -- code generation and "extra-phases" means you probably want CMake or something with a rich API for your own extensions, like Scons (or Waf).

我们使用使用SCons 的工作。它生产的防弹-建立,但它真的很慢。没有其他系统将防弹为使用SCons 。但是,它的速度慢。它是用Python编写的,我们已经延长了我们的工作空间组织(在这里我们只指定模块依赖)的接口,那就是使用SCons 设计意图的一部分(通过Python的这种类型的扩展)。方便,但版本是缓慢的。你得到防弹构建(任何开发箱可使最终版本),但它的速度慢。而且,它的速度慢。不要忘了,如果你使用使用SCons ,虽然,它的速度慢。而且,它是缓慢的。

We use Scons at work. It produces "bullet-proof-builds", but it's really slow. No other system will be as bullet-proof as Scons. But, it's slow. It is written in Python and we've extended the interface for our "workspace-organization" (where we merely specify module dependencies), and that is part of the Scons design intent (this type of extension through Python). Convenient, but builds are slow. You get bullet-proof builds (any developer box can make the final release), but it's slow. And, it's slow. Don't forget that if you use Scons, though, that it's slow. And, it's slow.

这让我生病认为,2000年后的十年中,我们还没有会飞的汽车。我们可能得再等百年的东西,让他们。而且,我们会那么所有可能会被周围的那些的还是的正与糟糕的构建系统构建了我们的飞行汽车飞行。

It makes me ill to think that a decade after the Year 2000, we still don't have flying cars. We'll probably have to wait another hundred years or something to get them. And, we will then all probably be flying around in our flying cars that are still being constructed with crappy build systems.

是的,他们都是可怕的。

Yes, they are all awful.

[关于code GENERATION]

[ABOUT CODE GENERATION]

使用SCons 适用于阶段,他们是有些静态。它可以构建作为构建(人在几个不同的方式这样做)的一部分生成code,但是这已经被描述为,一些非常不使用SCons一样。

Scons works on "phases", and they are "somewhat-static". It can build code that is generated as part of the build (people are doing this in a couple of different ways), but this has been described as, "something very un-Scons-like".

如果是简单的preprocess一些文件,并生成源文件,那么根本不算什么(你有很多的选择,这就是为什么的qmake 写 - - 。在 MOC * HPP / * CPP 文件preprocessing)

If it's simple "preprocess some files and generate source files", then no biggie (you have lots of options, and this is why qmake was written -- for the moc preprocessing of *.hpp/*.cpp files).

不过,如果你是在一个沉重的方式这样做,你将需要脚本自己。例如,我们有作为一种部分的最构建查询的数据库和生成的C ++类的层(传统的3层应用程序开发)之间的接口脚本。同样,我们通过生成的IDL服务器/客户端源$ C ​​$ c和嵌入式版本的信息,以允许多个客户端/服务器同时运行不同版本(相同的客户端或服务器)。大量生成的源$ C ​​$ C的。我们可以pretend即是建造系统,但实际上,这是一个不平凡的基础设施的配置管理,其中的一部分是打造系统。例如,该系统必须,记下和启动服务器作为这个过程的一部分。同样,回归测试作为这一进程的一部分执行,重报告和差分测试版本之间 - 这一切作为我们打造的脚本的一部分

However, if you are doing this in a "heavy-manner", you're going to need to script your own. For example, we had as-a-part-of-the-build scripts that queried the databases and generated C++ classes to interface between the "layers" (in traditional 3-tier application development). Similarly, we generated server/client source code through IDLs, and embedded version information to permit multiple clients/servers to run simultaneously with different versions (for the same "client" or "server"). Lots of generated source code. We could "pretend" that is "the-build-system", but really, it's a non-trivial-infrastructure for "configuration management", of which part of it is the "build-system". For example, this system had to, "take-down" and "start-up" servers as a part of this process. Similarly, the regression-tests were executed as a part of this process, with heavy "reporting" and "difference-testing" between versions -- all as a part of our "build-scripts".

这篇关于C ++构建系统 - 使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆