0

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

  • 下载并解压 tarball
  • 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 脚本,没有任何依赖管理。

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

4

1 回答 1

1

它恰好是介子的限制,它被报告为一个问题并且仍然存在。但是,对于您的 Doxyfile 修改自定义目标,替换应该有效:

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

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

subdir('extracted_docs_dir')

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

于 2018-12-07T23:05:40.080 回答