为什么介子用单引号解释我的 ccflags?

Why is meson interpreting my ccflags with the single quotes?

我正在编辑介子构建文件。该文件当前存在的一行运行良好。

if cc.has_argument('-Wno-format-truncation')                                                                                                                                                                                           
default_cflags += '-Wno-format-truncation'
endif

我添加了一行,因为我需要调试信息:

default_cflags += '-ggdb -O0'

但是, 单引号解释,并破坏了 make 命令。

-Wno-missing-field-initializers -D_GNU_SOURCE -march=native '-ggdb -O0' -DALLOW_EXPERIMENTAL_API -MD -MQ

显然,cc 不喜欢这样并抛出错误。是什么导致介子用单引号 解释此输出?我尝试过使用双引号和不使用引号,但这会引发其他错误。

编辑

这是一个dpdk构建文件,所以编译器调用是:

            executable('dpdk-' + name, sources,
                    include_directories: includes,
                    link_whole: link_whole_libs,
                    link_args: ldflags,
                    c_args: default_cflags,
                    dependencies: dep_objs)

介子使用+=语法向数组添加元素(追加)。因此,当数组后来被展平并检测到 space 时 - 我猜会使用引号。所以一一追加:

default_cflags += '-ggdb'
default_cflags += '-O0'

或更新为数组:

default_cflags += ['-ggdb, '-O0']

调试信息,查看meson的core options: buildtype and optimization.您可以在不将相关标志包含到 meson.build 中的情况下配置您的构建(如果它满足您的需要)。

非优化二进制文件使用的选项是 --buildtype=debug,使用 -g -O2 构建的二进制文件使用的选项是 --buildtype=debugoptimized

将这些 CFLAGS 参数作为列表对象传递的推荐方法。例如 shared_library, static_library, executable 与自定义 c_args : default_cflags 其中 default_cflags 声明为

default_cflags = []
...
...
...
if is_debug
  default_cflags += ['-ggdb', '-O0']
endif
...
...