Merge: doc: fixed some typos and other misc. corrections
[nit.git] / src / interpreter / dynamic_loading_ffi / on_demand_compiler.nit
index 3ac05af..acd783a 100644 (file)
@@ -138,19 +138,10 @@ redef class AModule
                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(" ")}`"
@@ -413,7 +404,7 @@ redef class ExternCFile
                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