2012-11-29 42 views
3

我有一個waf文件,它爲多個目標,多個平臺以及某些情況下的多個體繫結構構建了多個庫。waf 1.7:你如何複製環境?

我現在有根據WAF 1.7對,像這樣的變體文件設置環境:

def configure(conf): 
    # set up one platform, multiple variants, multiple archs 
    for arch in ['x86', 'x86_64']: 
     for tgt in ['dbg', 'rel']: 
     conf.setenv('platform_' + arch + '_' + tgt) 
     conf.load('gcc') # or some other compiler, such as msvc 
     conf.load('gxx') 
     #set platform arguments 

然而,這會導致WAF輸出多行尋找配置過程中的編譯器。這也意味着我經常將關閉多次設置到同一個環境。我想如果可能的話做一次,例如:

def configure(conf): 
    # set up platform 
    conf.setenv('platform') 
    conf.load('gcc') 
    conf.load('gxx') 
    # set platform arguments 
    for arch in ['x86', 'x86_64']: 
     for tgt in ['dbg', 'rel']: 
      conf.setenv('platform_' + arch + '_' + tgt, conf.env.derive()) 
      # set specific arguments as needed 

然而,conf.env.derive是一個淺拷貝,並conf.env.copy()給我的錯誤「列表」對象是不可回收的

這是怎麼做到WAF 1.7?

回答

4

事實證明,答案是從頂級體系結構派生,然後分離以允許您向配置添加更多標誌。例如:

def configure(conf): 
    conf.setenv('platform') 
    conf.load('gcc') 
    conf.load('gxx') 
    for arch, tgt in itertools.product(['x86', 'x86_64'], ['dbg', 'rel']): 
     conf.setenv('platform') 
     new_env = conf.env.derive() 
     new_env.detach() 
     conf.setenv('platform_' + arch + '_' + tgt, new_env) 
     # Set architecture/target specifics 
相關問題