nitni_ccu.write_as_nitni(self, v.compiler.modelbuilder.compile_dir)
for file in nitni_ccu.files do
- v.compiler.extern_bodies.add(new ExternCFile(file, c_compiler_options))
+ var f = new ExternCFile(file, c_compiler_options)
+ f.pkgconfigs.add_all pkgconfigs
+ v.compiler.extern_bodies.add(f)
end
# reset FFI things so the next compilation job, if any, starts with a clean context
redef class MModule
var c_compiler_options = "" is writable
var c_linker_options = "" is writable
+
+ # Additional libraries needed for the compilation
+ # Will be used with pkg-config
+ var pkgconfigs = new Array[String]
end
class ForeignCType
end
ffi_ccu.write_as_impl(self, compdir)
- for filename in ffi_ccu.files do ffi_files.add(new ExternCFile(filename, c_compiler_options))
+ for filename in ffi_ccu.files do
+ var f = new ExternCFile(filename, c_compiler_options)
+ f.pkgconfigs.add_all pkgconfigs
+ ffi_files.add(f)
+ end
end
# Avoid the compile a ffi propdef more than once
return
end
- # compiler
- var proc = new IProcess("pkg-config", "--cflags", pkg)
- var compiler_opts = proc.read_all
- mmodule.c_compiler_options = "{mmodule.c_compiler_options} {compiler_opts.replace("\n", " ")}"
-
- # linker
- proc = new IProcess("pkg-config", "--libs", pkg)
- var linker_opts = proc.read_all
- mmodule.c_linker_options = "{mmodule.c_linker_options} {linker_opts.replace("\n", " ")}"
+ mmodule.pkgconfigs.add pkg
end
end