gpt4 book ai didi

python - 使用不同的配置源作为 waf 的 doxygen 功能的输入

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:29 25 4
gpt4 key购买 nike

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

该示例保持完全相同,但长度稍长:

<小时/>

目录结构如下:

  • 文档
    • a.conf# 源 a 的 doxygen 源配置
    • b.conf# 源 b 的 doxygen 源配置
    • stylesheetfile # 两者相同
  • 源代码
    • a.c
    • b.c
  • doxygen.py
  • 脚本

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

<小时/>

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)

最佳答案

您的问题是您尚未定义 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

关于python - 使用不同的配置源作为 waf 的 doxygen 功能的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47789371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com