【问题标题】:Use different configuration sources as input to waf's doxygen feature使用不同的配置源作为 waf 的 doxygen 功能的输入
【发布时间】:2018-05-27 03:03:20
【问题描述】:

根据我提出的问题here,我想根据指定的构建变体使用不同的源,现在看来我在构建 doxygen 文档时遇到了同样的问题,因为我需要基于不同的配置构建变体。

示例保持不变,但更长一点:


目录结构如下:

  • 文档
    • a.conf # 为源 a 配置 doxygen 源
    • b.conf # 为源 b 配置 doxygen 源
    • stylesheetfile # 两者都一样
    • 交流
    • b.c
  • doxygen.py
  • 脚本

waf doxygen.py 的实现与 wa​​f 项目 doxygen.py 的 GitHub 上的存储库相同。


waf 脚本扩展为接受doxygen 选项。但在 doxygen 的定义中,无法检查构建变体(此处为 bld.variant),这会导致错误,因为 doxygen 功能中似乎没有定义构建变体。

我检查构建变体的部分在示例中用箭头标记。

我必须在何处以及如何实施更改,doxygen 功能可以工作并使用基于构建变体的正确配置。

MWE:

def options(opt):
    opt.load(['doxygen'], tooldir=os.path.join('doxygen.py'))

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='.',  features=['doxygen'])
    elif bld.variant == 'b':
        bld.program(source='b.c', target='app', includes='.', features=['doxygen'])
    else:
        bld.fatal('err')

# 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

def doxygen(bld):
    import sys
    import logging
    from waflib import Logs

    if bld.env.DOXYGEN:
        if bld.variant == 'a':    # <=================
            _conf = 'src/a.conf'  # <=================
        elif bld.variant == 'b':  # <=================
            _conf = 'src/b.conf'  # <=================
        else:                     # <=================
            bld.fatal('err')      # <=================

        bld.logger = Logs.make_logger('doxy.log', out)
        hdlr = logging.StreamHandler(sys.stdout)
        formatter = logging.Formatter('%(message)s')
        hdlr.setFormatter(formatter)
        bld.logger.addHandler(hdlr)

        bld(features='doxygen', doxyfile=_conf)

【问题讨论】:

    标签: python doxygen waf


    【解决方案1】:

    您的问题是您没有为 doxygen 命令定义变体。您应该添加如下内容:

    variants = ['a', 'b']
    
    for variant in variants:
        dox = "doxygen"
        class tmp(BuildContext):
            __doc__ = '''executes the {} of {}'''.format(dox, variant)
            cmd = dox + '_' + variant
            fun = dox
            variant = variant
    

    一个最小的工作示例:

    def configure(conf):
        pass
    
    def doxygen(bld):
        print "variant =", bld.variant
    
    # Create build commands with variants
    
    from waflib.Build import BuildContext
    
    variants = ['a', 'b']
    for variant in variants:
        dox = "doxygen"
        class tmp(BuildContext):
            __doc__ = '''executes the {} of {}'''.format(dox, variant)
            cmd = dox + '_' + variant
            fun = dox
            variant = variant
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-22
      • 1970-01-01
      • 1970-01-01
      • 2022-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多