Eclipse C++ 프로젝트에서 test
대상을 makefile.targets
에 추가했습니다. 이제 디버그 및 릴리스 빌드 구성의 일부로 빌드되기를 원하므로 유닛 테스트를 정상 빌드 프로세스의 일부로 실행할 수 있습니다.Eclipse의 빌드 구성에 make 대상을 추가하려면 어떻게합니까?
자동 생성 된 Debug/makefile
및 Release/makefile
을 편집 할 수 없다면 어떻게해야합니까?
Eclipse C++ 프로젝트에서 test
대상을 makefile.targets
에 추가했습니다. 이제 디버그 및 릴리스 빌드 구성의 일부로 빌드되기를 원하므로 유닛 테스트를 정상 빌드 프로세스의 일부로 실행할 수 있습니다.Eclipse의 빌드 구성에 make 대상을 추가하려면 어떻게합니까?
자동 생성 된 Debug/makefile
및 Release/makefile
을 편집 할 수 없다면 어떻게해야합니까?
아직 열지 않은 경우 Make Target
보기를 엽니 다. 단추는 New Make Target
입니다.
또는 메이크 파일에서 대상 이름을 강조 표시하고 마우스 오른쪽 버튼을 클릭 한 다음 Make Targets -> 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.init"
GREP := /bin/grep
예 "makefile.defs"
ifndef ProjDirPath
$(error "ProjDirPath" undefined as a "make variable" or "environment variable".)
endif
생성 된 메이크 디버그/SRC/subdir.mk가에 종속성을 추출 $ {ProjDirPath}/Debug/src/$ {ProjName} .d 파일이지만 종속성의 초기 생성을 위해 추가 대상을 추가해야합니다. 당신은의 대상을 추가 할 수 있습니다 : $ {ProjDirPath} /makefile.targets에 타겟을 추가하여
#include "automated_headers.h"
.
예 "makefile.targets는"
# targets to generate a header file
%/src/automated_headers.h: %/src/generate_headers.py $(external_library_info)
@echo "Generating [email protected]"
%/src/generate_headers.py $(extrnal_library_info) [email protected]
src/$(ProjName).o: $(ProjDirPath)/src/automated_headers.h
OK, 난 내 빌드 구성에 포함되는'makefile.targets'에 추가 대상을 야기 할 않습니다. 나는 그 질문을 정리하고 당신의 제안을 시도 할 것이다. :) –
Hrm, 빌드 구성 편집은 적어도 프로젝트> 빌드 구성 메뉴 - 빌드 구성 관리에서 회색으로 비활성화되어있는 것처럼 보이지 않습니다. 어떤 충고? –
@Josh : 죄송합니다. 자동 생성 된 메이크 파일을 직접 사용하지 않으므로이 문제를 해결할 수 없습니다. 수동 메이크 파일을 사용하는 것과 비슷하다고 생각했지만 아니오. – eriktous