【问题标题】:How can I concatenate multiple files into one in Meson?如何在 Meson 中将多个文件连接成一个文件?
【发布时间】:2017-07-08 20:05:30
【问题描述】:

我在 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() 编译。有没有办法可以运行此命令并将文件直接传递给该函数进行处理?

【问题讨论】:

    标签: meson-build


    【解决方案1】:

    使用custom_target(),将输出传递给gnome.compile_resources()dependencies。请注意,您需要一个相当新的 glib 才能使用它。

    另请参阅:http://mesonbuild.com/Gnome-module.html#gnomecompile_resources

    【讨论】:

      【解决方案2】:

      从问题到答案的移动解决方案:

      解决方案:

      我最终没有使用 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
      )
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-08-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-08
        • 1970-01-01
        相关资源
        最近更新 更多