var pkgconfigs = mmodule.pkgconfigs
var pkg_cflags = ""
if not pkgconfigs.is_empty then
- var cmd = "which pkg-config >/dev/null"
- if system(cmd) != 0 then
- v.fatal "FFI Error: Command `pkg-config` not found. Please install it"
- return false
- end
- for p in pkgconfigs do
- cmd = "pkg-config --exists '{p}'"
- if system(cmd) != 0 then
- v.fatal "FFI Error: package {p} is not found by `pkg-config`. Please install it."
- return false
- end
- end
+ # Check if the pkgconfig packages are available
+ v.modelbuilder.toolcontext.check_pkgconfig_packages pkgconfigs
+ if not v.modelbuilder.toolcontext.check_errors then return false
pkg_cflags = "`pkg-config --cflags {pkgconfigs.join(" ")}`"
ldflags += " `pkg-config --libs {pkgconfigs.join(" ")}`"
var cflags = mmodule.cflags[""].join(" ") + " " + pkg_cflags
var obj = compile_dir / filename.basename(".c") + ".o"
- var cmd = "{v.c_compiler} -Wall -c -fPIC -I {compile_dir} -g -o {obj} {filename} {cflags}"
+ var cmd = "{v.c_compiler} -Wall -c -fPIC -I {compile_dir} -g -o {obj} {compile_dir / filename} {cflags}"
if sys.system(cmd) != 0 then
v.fatal "FFI Error: Failed to compile C code using `{cmd}`"
return false