简体   繁体   English

如何使用Eclipse CDT构建SCons项目?

[英]How to build SCons projects with Eclipse CDT?

We have a fairly large C/C++ project using scons for the building. 我们有一个相当大的C / C ++项目,使用scons进行构建。 I'd like to go at an attempt to build this through Eclipse-CDT. 我想通过Eclipse-CDT尝试构建它。 Anyone have any experience with this and can tell me the steps to set up scons as a builder. 任何人都有这方面的经验,可以告诉我将scons设置为构建器的步骤。 (NOT using the SConsBuilder plugin, it will not work with the Eclipse-CDT from Fedora-11). (不使用SConsBuilder插件,它不适用于Fedora-11的Eclipse-CDT)。

One of our students implemented a new SCons integration for Eclipse CDT that works bi-directional, ie, it can import SCons files and populate Eclipse CDT projects with the corresponding settings and it can generate SCons files from Eclipse project settings. 我们的一位学生为Eclipse CDT实现了一个新的SCons集成,它可以双向工作,即它可以导入SCons文件并使用相应的设置填充Eclipse CDT项目,它可以从Eclipse项目设置生成SCons文件。 In addition it provides an interactive SCons mode that speeds up incremental building of larger SCons projects significantly. 此外,它还提供了一种交互式SCons模式,可显着加快大型SCons项目的增量构建。 It will be released to the public for free soon, see http://sconsolidator.com 它将很快免费向公众发布,请访问http://sconsolidator.com

You can use a Makefile that simply delegates the important targets to scons 您可以使用简单地将重要目标委派给scons的Makefile

.PHONY: all clean install
default:    all
all:    
    scons
clean:
    scons -c
install:
    scons install

Then it is possible to use "Standard Make C Project" out of the box. 然后可以开箱即用“标准制作C项目”。

I've tried Waf in Eclipse CDT before now, SCons would be really similar. 我之前在Eclipse CDT中尝试过Waf ,SCons会非常相似。 The solution was to create an empty Makefile project, then simply change "make" to "scons" in the options. 解决方案是创建一个空的Makefile项目,然后在选项中将“make”更改为“scons”。 On Windows that would probably need the scons.bat file in your path. 在Windows上可能需要路径中的scons.bat文件。 That is not much better than creating a dummy Makefile that has an all:\\n\\tscons type pattern in it, but is the least work. 这并不比创建一个具有all:\\n\\tscons类型模式的虚拟Makefile好,但是工作量最少。

The SConsBuilder plugin is not a good idea. SConsBuilder插件不是一个好主意。 It has a whole bunch of hard coded python code in there that it spits out to a SConstruct. 它有一大堆硬编码的python代码,它吐出到SConstruct。 It hasn't been updated in ages and a lot of code is probably deprecated in SCons by now. 它已经很久没有更新了,很多代码可能已经在SCons中被弃用了。 I think a better approach is to do what SCons does for Visual Studio, or what CMake does for Eclipse CDT. 我认为更好的方法是做SCons为Visual Studio做的事情,或CMake为Eclipse CDT做的事情。 That means generating a .cproject file on the fly based on your build configuration. 这意味着根据您的构建配置动态生成.cproject文件。

I wrote an Eclipse project generator for Waf at one point, which walks the build nodes gathering source files and spits out a .project and .cproject file. 我曾经为Waf编写了一个Eclipse项目生成器 ,它可以遍历构建节点收集源文件并吐出.project和.cproject文件。 Similar to how CMake does it, but Waf's default behaviour of creating a variant directory means you don't have to deal with out-of-source build issues. 与CMake的工作方式类似,但Waf创建变体目录的默认行为意味着您不必处理源外构建问题。 This has since been added as an extra in waf itself . 这已经被添加为waf本身额外内容 It uses only part of the Waf API so it would be possible to convert it to SCons with some small-ish amount of work. 它只使用Waf API的一部分,因此可以将它转换为具有一些小工作量的SCons。 In other words, there's nothing much out there. 换句话说,那里没什么。 The .cproject format is not really documented anywhere and is really ugly compared to the Java version. .cproject格式在任何地方都没有真正记录,与Java版本相比真的很难看。

I didn't get on too well with CDT though - it is a long way behind the Java dev tools - and I still use Vim with :make , so it was all a bit academic in the end. 虽然我在CDT方面做得不是很好 - 它远远落后于Java开发工具 - 而且我仍然使用Vim :make ,所以最后它有点学术性。

Just change builder settings, no plugins required. 只需更改构建器设置,无需插件。 Choose external builder and set scons instead of make and set workdir to dir where SConstruct placed. 选择外部构建器并设置scons而不是make并将workdir设置为dirs SConstruct放置的位置。

Now, you can use make targets view to create scons build commands and execute it like make commands. 现在,您可以使用make targets视图来创建scons构建命令并像make命令一样执行它。 Error parsers with scons works fine by default, no additional configuration required. 使用scons的错误解析器默认工作正常,无需其他配置。

http://sconsolidator.com/ Sconsolidator应该可以工作。

Be VERY VERY careful about using Sconsolidator with an existing project!! 在现有项目中使用Sconsolidator非常谨慎! It will blindly overwrite any existing SConstruct/SConscript files you have in the root directory of your project when you click the link to add a SCons nature to your project. 当您单击链接以向项目添加SCons特性时,它将盲目地覆盖项目根目录中的任何现有SConstruct / SConscript文件。 (I'm trying to report this as a bug to the project, but being blocked at every turn so far.) (我试图将此报告为项目的错误,但到目前为止每次都被阻止。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM