2016-10-04 8 views
0

나는, SCons는 우리 자신의 결정자 함수를 작성하는 방법을 인터넷에서 검색 소스 파일은 다음과 같이 다시 작성해야 할 때 어떻게 /에 관해서 :scons 맞춤식 결정 기능은 반원이어야합니까?

나는에서는 hello.c있어
Program('hello.c') 
def decide_if_changed(dependency,target,prev_ni): 
if self.get_timestamp()!=prev_ni.timestamp: 
    dep=str(dependency) 
    tgt=str(target) 
    if specific_part_of_file_has_changed(dep,tgt): 
    return true; 
return false; 
Decider(decide_if_changed) 

, 아무 문제 SCons는 실행시,하지만 파이썬 오류 메시지를 표시 :

$ scons -Q 
scons: *** [o.o] NameError : global name 'self' is not defined 

자체가 클래스 멤버 함수를 언급 파이썬 키워드입니다. 여기 SContruct 파일에는 클래스가 있지만 단지 decide_if_changed 함수가 있습니다. 질문 :

Do I have to add a class here? Why it prompts python error saying 'self' is not defined?

This example script a function call of specific_part_of_file_has_changed, is it a scons's own file that can be called by any pythong statement?

답변

1

설명서에 오타가 있기 때문에 self 이름이 정의되지 않았습니다. 결정자의 두 번째 줄 읽어야합니다

if dependency.get_timestamp()!=prev_ni.timestamp: 

specific_part_of_file_has_changed() 방법 (또는 파일이 변경되었는지 여부를 확인하는 단계의 유사한 시리즈) 구현 ... "고객"당신에게 완전히이다. 결국 "커스텀 디 사이더"를 원한다, 그렇지? ;)