2012-09-05 3 views
1

SCons 빌드 중에 파일 컴파일, 파일 링키지 등의 상황이 발생했을 때 알림을 받으려면 SCons 빌드에 첨부해야합니다.SCons : 리스너를 어떻게 부착 할 수 있습니까?

-listener 옵션을 통해 ANT 빌드를 수행하는 경우에도 비슷한 작업이 가능하다는 것을 알고 있습니다. 당신은 SCons 빌드를 위해 그것을 어떻게하는지 말해 주시겠습니까?

답변

2

대상이 SCons로 작성된 경우 here과 같이 AddPostAction (대상, 작업) 기능을 통해 게시 작업을 연결할 수 있습니다.

# Create yourAction here: 
# can be a python function or external (shell) command line 

def helloWorldAction(target = None, source = None, env = None): 
    ''' 
     target: a Node object representing the target file 
     source: a Node object representing the source file 
     env: the construction environment used for building the target file 
     The target and source arguments may be lists of Node objects if there 
     is more than one target file or source file. 
    ''' 

    print "PostAction for target: %s" % str(target) 

    # you can get a map of the source files like this: 
    # source_file_names = map(lambda x: str(x), source) 
    # compilation options, etc can be retrieved from the env 

    return 0 

env = Environment() 
progTarget = env.Program(target = "helloWorld", source = "helloWorld.cc") 
env.AddPostAction(progTarget, helloWorldAction) 
# Or create the action object like this: 
# a = Action(helloWorldAction) 

이어서 helloworld를 내장 될 때마다 상기 helloWorldAction 파이썬 함수 afterwords 실행된다 : 여기

파이썬 기능 동작 간단한 예이다.

주어진 SConstruct를 수정하지 않고이 작업을 수행하는 것에 관해서는 어떻게 그럴 수 있는지 보지 못합니다.

+0

감사합니다. 간단한 작업 (예 : helloWorld.cc '컴파일 옵션 인쇄)의 예도 제공 할 수 있습니까? 또한 SConstruct 스크립트 (기존 일 수 있음)를 수정하지 않고 유사한 작업을 수행 할 수있는 방법이 있는지 묻고 싶습니다. – Nelly

+0

@Nelly, 파이썬 함수 액션을 추가했습니다. 테스트해야합니다. – Brady

관련 문제