From ed948d63c045ebd84fdd156a10a41bae7897868d Mon Sep 17 00:00:00 2001 From: kbkpbot Date: Fri, 22 Aug 2025 11:41:46 +0800 Subject: [PATCH] fix pkgconfig --- vlib/v/ast/ast.v | 2 ++ vlib/v/checker/comptime.v | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 0ddea4adca..179a5a29ee 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -2130,6 +2130,8 @@ pub fn (cc ComptimeCall) expr_str() string { if arg.expr.is_pure_literal() { str = "\$${cc.method_name}('${cc.args_var}', ${arg})" } + } else if cc.kind == .pkgconfig { + str = "\$${cc.method_name}('${cc.args_var}')" } return str } diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index 3761461b67..d7068269d5 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -1662,13 +1662,19 @@ fn (mut c Checker) comptime_if_cond(mut cond ast.Expr, mut sb strings.Builder) ( } ast.ComptimeCall { if cond.kind == .pkgconfig { - mut m := pkgconfig.main([cond.args_var]) or { + if mut m := pkgconfig.main([cond.args_var]) { + if _ := m.run() { + is_true = true + } else { + // pkgconfig not found, do not issue error, just set false + is_true = false + } + } else { c.error(err.msg(), cond.pos) - return false, true + is_true = false } - m.run() or { return false, true } - sb.write_string('true') - return true, true + sb.write_string('${is_true}') + return is_true, true } if cond.kind == .d { t := c.expr(mut cond)