2011-09-28 2 views
0

저는 빌드 시스템으로 scons를 사용하고 있으며 scons를 사용하여 프로젝트의 개발 헤더를 설치하려고합니다. 필자는 필요한 모든 헤더와 그 포함 종속성 목록을 유지하지 않고 대신이 목록을 제공하기 위해 내장 된 종속성 구문 분석 마법을 사용하고 싶습니다. 예를 들어 은 scons를 사용하여 헤더 및 종속 헤더를 프로그램 적으로 설치합니다.

내가 설치 내가 원하는 두 헤더가 명시 적으로, Foo1.h 및 Foo2.h :

/* Foo1.h */ 
#ifndef FOO1_H_ 
#define FOO1_H_ 

#include "Bar.h" 
#include <somelibrary.h> 

/* header contents */ 

#endif /* FOO1_H_ */ 

및 Bar.h이 FOO1이 요구되기 때문에

/* Foo2.h */ 
#ifndef FOO2_H_ 
#define FOO2_H_ 

/* header contents */ 

#endif /* FOO2_H_ */ 

. h, 나는 자동적으로 그것도 설치되기를 원한다. somelibrary.h는 설치된 헤더의 일부가 아니어야합니다. 이 일을 이루기 위해서는 어떤 방법이 있어야합니다. 또는 거기에 내가하려고하는 것이 옳지 않은 이유가 있어야합니다.

도움 주셔서 감사합니다.

답변

1

글쎄, 나는 대답을 알아 냈다. 내가 말한 것을 정확히 할 수있는 코드 스 니펫은 다음과 같습니다.

def getDependentIncludes(environ, explicit_includes, search_path, depincludes): 
    for inc in explicit_includes: 
     if inc not in depincludes: 
      depincludes.add(inc) 
      incs = SCons.Defaults.CScan(inc, environ, search_path) 
      getDependentIncludes(environ, incs, search_path, depincludes) 
# create a set of all the headers 
development_headers = set() 
# call function, with development_headers storing the result 
getDependentIncludes(env, 
       external_facing_headers, 
       include_dirs, development_headers) 
# print the glorious results 
names = map(lambda x : '"./' + os.path.relpath(str(x), Dir("#").abspath) + '"', development_headers) 
names.sort() 
print " ".join(names) 
관련 문제