【问题标题】:custom_target() to extract and build external sourcecustom_target() 提取和构建外部源
【发布时间】:2018-11-09 16:55:53
【问题描述】:

我有一个介子项目,需要几个步骤:

  • 下载并解压压缩包
  • cd 进入其中,./configure - 这会在上游存档目录中生成某个文件
  • 调整存档目录中的文件
  • 更多构建步骤

我遇到的问题是如何设置输入/输出文件和依赖项。到目前为止,我有:

src_archive = 'extracted-dir' # this is what comes out of the upstream archive

# wget and untar a tarball (produces the 'extracted-dir' dir in the build directory)
dl_tgt = custom_target('download',
  command : [files('scripts/download.sh')],
  output : src_archive
)

# cd to the directory, .configure
# when this is complete, a file 'extracted-dir/docs/Doxyfile' will exist

upstream_doxyfile = 'Doxyfile' # can't set a path on this file
conf_tgt = custom_target('configure_src',
    input : dl_tgt,
    command : [files('scripts/configure.sh'), '@INPUT@'],
    output : doxy_out
)

# Modify the upstream Doxyfile (copy it and append some settings to the copy)

mod_doxyfile = 'Doxyfile.mod'

mod_doxy_tgt = custom_target('configure_doxy',
    build_by_default : true,
    input : conf_tgt,
    command : [files('scripts/configure-doxy.sh'), '@INPUT@'],
    output : mod_doxyfile
)

# ... and so on to run more steps as needed (in reality, some of these steps might be combined)

如果允许 Meson 避免重复下载(例如,如果文件已下载),则有单独步骤的原因。

如果您尝试运行它,它将无法找到Doxyfiles(因为它们位于子目录中)。

如果你用路径指定它们,那就是错误:

ERROR:  Output 'extracted-dir/docs/Doxyfile' must not contain a path segment.

我也可以通过手动指定脚本中的路径来做到这一点,但是介子构建基本上只是一个过于复杂的 shell 脚本,没有任何依赖管理。

如何像这样在构建目录中链接文件的依赖关系?

【问题讨论】:

    标签: ninja meson-build


    【解决方案1】:

    它恰好是介子的限制,它被报告为issue并且仍然打开。但是,对于您的 Doxyfile 修改自定义目标,替换应该可以工作:

    mod_doxy_tgt = custom_target('configure_doxy',
        input : doxy_out,
        ...
        output : '@BASENAME@.mod'
    )
    

    但是,为了解决一般问题,请考虑在某个目录中创建另一个 meson.build 文件,您可以在其中提取上游存档并将其包含到主目录中:

    subdir('extracted_docs_dir')
    

    因此 Doxyfile 与 meson.build 位于同一级别。因此,您可以直接在output : 中使用文件名,这也有助于将此特定任务与主要构建规则隔离开来。

    【讨论】:

    猜你喜欢
    • 2010-09-13
    • 2017-05-07
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 2010-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多