Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Eclipse中将make目标添加到构建配置中?_Eclipse_Makefile_Eclipse Cdt - Fatal编程技术网

如何在Eclipse中将make目标添加到构建配置中?

如何在Eclipse中将make目标添加到构建配置中?,eclipse,makefile,eclipse-cdt,Eclipse,Makefile,Eclipse Cdt,我在Eclipse C++项目中添加了测试/目标到MaFix.Abjult。现在,我希望它作为调试和发布构建配置的一部分构建,这样我就可以让我的单元测试作为正常构建过程的一部分运行 如果我无法编辑自动生成的Debug/makefile和Release/makefile,我该怎么做?如果尚未打开,请打开maketarget视图。它有一个新建目标按钮 或者,在makefile中高亮显示目标的名称,右键单击,然后转到maketargets->Create… 编辑:我可能误解了你的问题。如果希望生成目标

我在Eclipse C++项目中添加了测试/<代码>目标到MaFix.Abjult<代码>。现在,我希望它作为调试和发布构建配置的一部分构建,这样我就可以让我的单元测试作为正常构建过程的一部分运行


如果我无法编辑自动生成的
Debug/makefile
Release/makefile
,我该怎么做?

如果尚未打开,请打开
maketarget
视图。它有一个
新建目标
按钮

或者,在makefile中高亮显示目标的名称,右键单击,然后转到
maketargets->Create…


编辑:我可能误解了你的问题。如果希望生成目标,单击“构建”时,请转到“构建首选项”并将其添加到那里。

下面的伪代码有望回答有关目标添加的问题,并另外说明如何在makefile和源代码中使用变量

我花了一天时间,通过网络资源,特别是stackoverflow.com和eclipse.org论坛,弄明白了这一点。CDT的Eclipse文档在某些方面有点模糊

// pseudo-code for Eclipse version Kepler
if ("Project.Properties.C/C++ Build.Generate Makefiles automatically" == true) {
  // when using the automatically generated makefiles,
  //   use the -include's in the generated Debug/makefile
  cp <your makefile init statements> $(ProjDirPath)/makefile.init
  cp <your makefile definitions>     $(ProjDirPath)/makefile.defs
  cp <your makefile targets>         $(ProjDirPath)/makefile.targets
} else {
  // when using a makefile that you maintain, alter your own makefile
  cp <your makefile targets>         <your makefile>
}
// Additionally, you may want to provide variables for use in the makefile 
//   commands, whether it's your own makefile or the generated one:
//    Note that:
//    - "Preferences.C/C++.Build.Build Variables" and
//      "Project.Properties.C/C++ Build.Build Variables" 
//       are *NOT directly available* to the makefile commands.
//    - "Preferences.C/C++.Build.Environment" variables and
//      "Project.Properties.C/C++ Build.Environment" variables
//      *ARE available* to the makefile commands.
//    - To make "Build Variables" available to the makefile and source files,
//      add an environment variable as shown below. Especially useful are the
//      built-in ones visible when "Show system variables" is checked.

// assign the build system variable "ProjDirPath" as a *user preference*
"Preferences.C/C++.Build.Environment".AddKeyValue("ProjDirPath",
                                                  "${ProjDirPath}"}

// assign the build system variable "ProjDirPath" as a *project property*
"Project.Properties.C/C++ Build.Environment".AddKeyValue("ProjDirPath",
                                                         ${ProjDirPath}")
“makefile.defs”示例:

生成的makefile Debug/src/subdir.mk将依赖项提取到 文件${ProjDirPath}/Debug/src/${ProjName}.d,但是您需要为依赖项的初始生成添加一个额外的目标。您可以为以下内容添加目标:

#include "automated_headers.h"
通过将目标添加到${ProjDirPath}/makefile.targets

“makefile.targets”示例:


好的,我确实希望将添加到
makefile.targets
的目标包含在生成配置中。我会澄清这个问题并尝试你的建议。:)Hrm,编辑构建配置对我来说似乎是禁用的,至少在项目>构建配置菜单中——管理构建配置是灰色的。有什么建议吗?@Josh:对不起,我自己不使用自动生成的makefile,所以我不能帮你。我认为这类似于使用手动生成文件,但不是。
ifndef ProjDirPath
  $(error "ProjDirPath" undefined as a "make variable" or "environment variable".)
endif
#include "automated_headers.h"
# targets to generate a header file
%/src/automated_headers.h: %/src/generate_headers.py $(external_library_info)
    @echo "Generating $@"
    %/src/generate_headers.py $(extrnal_library_info) $@

src/$(ProjName).o: $(ProjDirPath)/src/automated_headers.h