eclipse 从命令行构建多个 CDT C++ 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/344797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:33:10  来源:igfitidea点击:

Build several CDT C++ projects from commandline

eclipsecommand-lineeclipse-cdt

提问by James Blackburn

What is the best solution to build several CDT C++ projects from the command line? The projects have references and so it is not possible to just build single projects.

从命令行构建多个 CDT C++ 项目的最佳解决方案是什么?项目有引用,因此不可能只构建单个项目。

回答by James Blackburn

This feature has been added in CDT 6 (Final build due June 15th 2009). You can download the final release candidate from builds page: download.eclipse.org/tools/cdt/builds/6.0.0/.

此功能已添加到 CDT 6(最终版本于 2009 年 6 月 15 日到期)中。您可以从构建页面下载最终候选版本:download.eclipse.org/tools/cdt/builds/6.0.0/。

Using a release of Eclipse 3.5 + CDT 6, you can import, build and clean-build projects and the workspace using the following options sent to Eclipse at the command line:

使用 Eclipse 3.5 + CDT 6 的发行版,您可以使用以下在命令行发送到 Eclipse 的选项来导入、构建和清理构建项目和工作区:

eclipse -nosplash 
        -application org.eclipse.cdt.managedbuilder.core.headlessbuild 
        -import {[uri:/]/path/to/project} 
        -build {project_name | all} 
        -cleanBuild {projec_name | all}

On Windows, use eclipsec.exeinstead of eclipse.exeto have build output written to stdout/stderr and so that the call blocks until completion.

在 Windows 上,使用eclipsec.exe而不是eclipse.exe将构建输出写入 stdout/stderr,以便调用阻塞直到完成。

The '-application' switch instructs Eclipse to run the CDT headless builder rather than starting the workbench. The other switches can be used individually or together. This means you can checkout a project using a shell script of your own, '-import' it into a workspace, and '-build' it using the Managedbuilder's headless builder.

' -application' 开关指示 Eclipse 运行 CDT 无头构建器,而不是启动工作台。其他开关可以单独使用或一起使用。这意味着您可以使用自己的 shell 脚本检出项目,将其“ -import”到工作区中,然后使用 Managedbuilder 的无头构建器“ -build”它。

Use the '-data' switch to specify the workspace to use, which can be an empty temporary directory, see the runtime documentation for other switches supported by the platform runtime: help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html

使用' -data'开关指定要使用的工作空间,可以是一个空的临时目录,平台运行时支持的其他开关请参见运行时文档: help.eclipse.org/galileo/index.jsp?topic=/ org.eclipse.platform.doc.isv/reference/misc/runtime-options.html

See bug 186847 comment 24and onwards for more detail on the committed functionality.

有关已提交功能的更多详细信息,请参阅错误 186847 评论 24及以后的内容。

回答by James Blackburn

Pre CDT 6 you could use the JDT's AptBuilder(included with classic Eclipse, for example).

在 CDT 6 之前,您可以使用 JDT 的AptBuilder(例如,包含在经典 Eclipse 中)。

This lets you build an already configured workspace. So you: checkout your source, configure a workspace which points to the checked-out projects. Your automated build scripts can then update the checkouts and run the AptBuilder without needing to start the GUI.

这使您可以构建已配置的工作区。所以你:签出你的源代码,配置一个指向签出项目的工作区。然后,您的自动构建脚本可以更新检出并运行 AptBuilder,而无需启动 GUI。

回答by Paulo Lopes

If you created a Make project under CDT you can just use your favorite shell and execute make in all the projects dirs.

如果你在 CDT 下创建了一个 Make 项目,你可以使用你最喜欢的 shell 并在所有项目目录中执行 make。

回答by lothar

Headless build with the manage builder is currently not supported, see bug 186847 - CDT internal builder does not support automated command line builds.

当前不支持使用管理构建器的无头构建,请参阅错误 186847 - CDT 内部构建器不支持自动命令行构建

If you use the unmanaged (make) builder, then you already have Makefiles that you can use from the command line.

如果您使用非托管 (make) 构建器,那么您已经拥有可以从命令行使用的 Makefile。

回答by Jeff Lamb

We do this in our existing build.

我们在现有构建中执行此操作。

Put a makefile in all your external references and your toplevel project. In your "all" rule, have it run: make -C ./externalref1 make -C ./externalref2 etc

将 makefile 放在所有外部引用和顶级项目中。在你的“全部”规则中,让它运行:make -C ./externalref1 make -C ./externalref2 etc

we actually define the external dependencies in a variable: EXT_DEP = externalref1 externalref2 then use the subst (substitute) command to kick off all the sub-makes using the correct call.

我们实际上在一个变量中定义了外部依赖: EXT_DEP = externalref1 externalref2 然后使用 subst (substitute) 命令使用正确的调用启动所有 sub-make。