Programing

C ++에 대한 Maven과 같은 종속성 관리?

lottogame 2020. 9. 19. 11:53
반응형

C ++에 대한 Maven과 같은 종속성 관리? [닫은]


여러 하위 프로젝트로 분할 된 C ++ 프로젝트가 있다고 가정 해 보겠습니다. 하위 프로젝트는 모두 DLL을 생성하고 서로 다른 개발자 팀이 각 하위 프로젝트에서 작업합니다. 이제 메인 프로젝트를 빌드하려는 경우 모든 하위 프로젝트를 혼자서 빌드하지 않아도되는 방법이 있습니까?

요컨대, Maven이 Java에서하는 것과 유사한 방식으로 종속성 관리 (즉, 바이너리 파일 및 헤더)를 수행하는 것을 찾고 있습니다.

사실, 나는 이것을 위해 Maven을 사용하려고했지만 이것은 패키지를 수동으로 꽤 자주 만들어야하기 때문에 다소 번거 롭습니다. Maven은 가장 최근의 변경 사항을 선택하지 못합니다. 또한 Maven 내에서 NAnt를 호출해야하므로 컴파일을 실행하는 것은 약간의 해킹입니다 (NAnt의 기능을 사용하여 Visual Studio 솔루션을 직접 빌드합니다).

이를 수행하는 방법에 대한 힌트와 아이디어가 있습니까?


초기 답변 : CMake를 사용하는 것이 좋습니다. 다중 플랫폼 make 파일 생성기입니다 (Visual Studio 또는 Eclipse CDT 프로젝트도 생성).

http://www.cmake.org/

정말 좋은 경험을했습니다. 내가 좋아하는 가장 좋은 점은 일반적인 프로젝트 구조를 생성하는 능력이었습니다. 따라서 매번 스크립트를 변경하지 않고 일반적으로 단위 테스트 등에 대한 하위 프로젝트 조회를 포함 할 수 있습니다.

또한 프로젝트에 필요한 사전 설치된 빌드 라이브러리를 찾는 방법에 대한 많은 모듈 (예 : Boost, QT 등)이 있습니다.


업데이트 : 그동안 C ++ 용 패키지 관리를 도입하려는 노력이있었습니다. 살펴볼 가치가있는 몇 가지 프로젝트 :

  • conan.io 는 주요 빌드 도구와 통합됩니다.
    • CMake
    • 비주얼 스튜디오
    • Makefile
    • XCode
    • ...
  • CMake 기반 cpm
  • Buckaroo

주석 에서 @RAM이 지적했듯이 cpm은 더 이상 적극적으로 유지되지 않습니다.


종속성 관리를 위해 https://www.biicode.com/(C++ 종속성 관리자) 과 같은 유형의 도구를 구현하는 새로운 프로젝트 (스타트 업 회사)가 있습니다. 종속성을 추가 할 수 있으며 작동합니다.

현재 프로젝트의 이름입니다 conan.io , 그들에 의해 인수되었다 JFrog .

업데이트 : 프로젝트가 죽었습니다 ... 불행히도 스타트 업은 충분한 프리미엄 지불 고객을 얻지 못했지만 서버는 정상적으로 작동하는 것 같습니다 ...

UPDATE2 : 대체 프로젝트가있는 것 같습니다 : conan.io (@mucaho에게 감사드립니다)


다음과 같은 고급 빌드 시스템을 권장합니다.


의존성 관리 만 원한다면 Ivy를 사용 해보세요. Ant와 잘 통합됩니다 (그리고 NAnt가 Ivy 사이트에서 링크 된 블로그를 기반으로 동일한 작업을 수행 할 수 있다고 가정 합니다).

Maven의 .Net 버전 인 Byldan 도 있습니다 . 그래도 얼마나 잘 작동할지 모르겠습니다.


Make와 GCC는 정말 좋은 종속성 검사를위한 훌륭한 콤보입니다.

GCC는 예를 들어 주어진 헤더에 의존하는 모든 소스 파일을 다시 빌드 할 수 있도록 'make'종속성 파일을 자동으로 생성 할 수 있습니다 (-MD 명령 줄 스위치).

메이크 파일에 잘라서 붙여 넣는 몇 가지 간단한 규칙이 있습니다.

# compile c files   
%.o:    %.c
    ${CC} ${CFLAGS} -c $< -MD -MF $(<:%.c=%.dep) -o $@

# compile c++ files
%.opp:  %.cpp
    ${CPP} ${CPPFLAGS} -c $< -MD -MF $(<:%.cpp=%.dep) -o $@

이제 개체 파일이 OBJ_C 및 OBJ_CPP 목록으로 선언 된 경우 :

.PHONY: cleandep
cleandep:
    rm -f $(OBJ_C:%.o=%.dep) $(OBJ_CPP:%.opp=%.dep)

-include $(OBJ_C:%.o=%.dep) $(OBJ_CPP:%.opp=%.dep)

물론 Make는 다른 프로젝트와의 종속성을 추적 할 수 있습니다. 예를 들어 필요에 따라 공유 라이브러리를 다시 빌드 할 수도 있습니다.

예를 들어 다른 팀이 항상 일부 공유 폴더에 최신 DLL을 저장하는 경우 :

myapp: ${SRC_CPP} ${LIB_DIR}other_team.lib
  ...

${LIB_DIR}other_team.lib: /shared_folder/latest/other_team.lib
  cp /shared_folder/latest/other_team.lib ${LIB_DIR}other_team.lib

최근 출시 : biicode 개발자를 위한 다중 플랫폼 도구 및 호스팅 서비스

편집하다:

Biicode는 더 이상 사용되지 않습니다.

대안 : Conan.io


I recommend conan, which I was using these days. It's very powerful to maintain all the dependent libraries and binaries in your project.


You can create NuGet package for used libraries and use NuGet for dependency management.

See also, NuGet for C++


There is a number of tools sitting on top of SCons, providing higher-level functionality similar to that of Autotools which are trying to make the developers life easier (e.g. WAF, SNOCS). Unfortunately, SCons itself has the major drawback - longer compilation time for the large projects.

I can recommend to try out SNOCS (which is a SCons reversed) for those of you looking for an easy dependency management and choosing compilation options in the single command (compiler, x86/x64, Debug/Release, static/shared libraries, test/install targets, etc.).

SNOCS also tries to tackle the long compilation time problem by storing the projects configuration output in the separate files, which allows the consequent builds to skip configuration phase altogether and go straight to the building phase (last feature is under construction now)

CMake's configuration becomes tedious in a larger solutions, so the build system maintenance takes a large fraction of the developer time. Luckily as Martijn already mentioned there is biicode which "uses CMake to generate your project with its dependencies".


Try SCons

SCons is an Open Source software construction tool—that is, a next-generation build tool. Think of SCons as an improved, cross-platform substitute for the classic Make utility with integrated functionality similar to autoconf/automake and compiler caches such as ccache. In short, SCons is an easier, more reliable and faster way to build software.


I recommend to use the mother of all build dependency systems: make.


Try scons, you will be hooked. Make is outdated, difficult and expensive to maintain.

참고URL : https://stackoverflow.com/questions/1136065/maven-like-dependency-management-for-c

반응형