1

我在 Meson 的一项基本任务中遇到了麻烦,我需要在构建过程中将多个文件连接成一个;基本上:

cat *.txt > compiled.txt

或者

cat foo.txt bar.txt baz.txt > compiled.txt

custom_target()但是,无论我使用generator()还是任何其他功能,Meson 都找不到compiled.txt或无法处理从多个输入文件到单个输出文件的转换。

有没有简单的方法来实现这一目标?

更新:

使用run_command()我已经设法构建compiled.txt并让它出现在源目录中。最终我希望compiled.txt(我在 gresource.xml 中列出)由gnome.compile_resources(). 有没有办法可以运行此命令并将文件直接传递给该函数进行处理?

4

2 回答 2

1

使用custom_target(),将输出传递给dependenciesof gnome.compile_resources()。请注意,您需要一个相当新glib的版本才能正常工作。

另见: http: //mesonbuild.com/Gnome-module.html#gnomecompile_resources

于 2017-07-10T01:11:49.673 回答
1

将解决方案从一个问题移到另一个答案:

解决方案:

我最终没有使用 gresources,但仍然需要这个解决方案来连接文件

cat_prog = find_program('cat')

parts_of_the_whole = files(
  'part1.txt',
  'part2.txt'
)

concat_parts = custom_target(
  'concat-parts',
  command: [ cat_prog, '@INPUT@' ],
  capture: true,
  input: parts_of_the_whole,
  output: 'compiled.txt',
  install_dir: appdatadir,
  install: true,
  build_by_default: true
)
于 2017-07-14T07:56:56.750 回答