fix pkgconfig

This commit is contained in:
kbkpbot 2025-08-22 11:41:46 +08:00
parent 893bae8423
commit ed948d63c0
2 changed files with 13 additions and 5 deletions

View file

@ -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
}

View file

@ -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)