是否有任何工具(cli、在线等)可以从一个
meson_options.txt
文件获取所有使用默认值填充的选项?
例如
$ meson_get_all_options
CMD -Doption=true -Doption2=42
meson setup
创建默认构建配置meson introspect --buildoptions
以 JSON 格式转储所有选项section=user
Lua 中的示例代码:
-- some JSON decoder required
local json = require"json"
local projdir = "/path/to/project"
local tempdir = "/tmp/build"
assert(os.execute(string.format("meson setup %s %s >/dev/null", tempdir, projdir)))
local handle = io.popen(string.format("meson introspect %s --buildoptions", tempdir))
local data = json.decode(handle:read("*all"))
handle:close()
for i, v in ipairs(data) do
if v.section == "user" then
io.write(string.format("-D%s=%s ", v.name, v.value))
end
end
os.execute(string.format("rm -r %s", tempdir))