2017-11-20 2 views
1

これに基づいて、異なる出力ディレクトリにwaftで別のvariantsプロジェクトをビルドすることができます。7.2.2。出力ディレクトリの変更/バリアントのコンフィグレーションセットhttps://waf.io/book/#_custom_build_outputswafビルドバリアントで異なるソースを使用

しかし、variantに基づいて異なるファイルやディレクトリを含める方法はわかりません。 このようにwaf-bookからサンプルを変更しましたが、別のソースファイルをビルドする方法や、異なるディレクトリからファイルをインクルードする方法がありません。

def configure(ctx): 
    pass 

def build(ctx): 
    if not ctx.variant: 
     ctx.fatal('call "waf a" or "waf b", and try "waf --help"') 
    # for variant "a" it should build "a.c" and fpr "b" it should build "b.c" 
    # for a: bld.program(source='a.c', target='app', includes='.') 
    # for b: bld.program(source='b.c', target='app', includes='.') 

from waflib.Build import BuildContext 
class a(BuildContext): 
    cmd = 'a' 
    variant = 'a' 

from waflib.Build import BuildContext 
class b(BuildContext): 
    cmd = 'b' 
    variant = 'b' 

答えて

1

あなたは、プロジェクトを構成するpython waf configureを実行します。その後、コマンドでbuild_abuild_b

def configure(ctx): 
    load('compiler_c') 

def build(bld): 
    if not bld.variant: 
     bld.fatal('call "waf build_a" or "waf build_b", and try "waf --help"') 

    if bld.variant == 'a': 
     bld.program(source='a.c', target='app', includes='.') 
    elif bld.variant == 'b': 
     bld.program(source='b.c', target='app', includes='.') 
    else: 
     bld.fatal('"') 

# create build and clean commands for each build context 
from waflib.Build import BuildContext, CleanContext 

for x in 'a b'.split(): 
    for y in (BuildContext, CleanContext): 
     name = y.__name__.replace('Context','').lower() 
     class tmp(y): 
      __doc__ = '''executes the {} of {}'''.format(name, x) 
      cmd = name + '_' + x 
      variant = x 
を含むバリアントがビルドされます。
関連する問題