在WAF构建变体中使用其他来源 [英] Use different source in waf build variant

查看:144
本文介绍了在WAF构建变体中使用其他来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于此,可以在waf中将项目的不同variants构建到不同的输出目录 7.2.2.更改输出目录/变体的配置集( https://waf.io/book/# _custom_build_outputs )

Based on this it is possible to build different variants of a project in waf to different output directories 7.2.2. Changing the output directory / Configuration sets for variants (https://waf.io/book/#_custom_build_outputs)

但是我不理解如何基于variant包括不同的文件或目录. 我像这样从waf-book修改了示例,但我缺少如何构建不同的源文件或包含来自不同目录的文件的方法.

But I do not understand how to include different files or directories based on the variant. I modified the example from the waf-book like this, but I am missing how to build a different sourcefile or include files from different directories.

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'

推荐答案

您运行python waf configure来配置项目.之后,使用命令build_abuild_b

You run python waf configure to configure the project. After that a variant is build with the commands build_a and build_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

这篇关于在WAF构建变体中使用其他来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆