From 3b72706120cd2f06ebf4bdb3e3e47723d8ce4067 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 4 Nov 2014 11:35:32 -0500 Subject: [PATCH] ffi/pkgconfig: use the new pkgconfig infrastructure in the Makefile Signed-off-by: Jean Privat --- src/compiler/compiler_ffi.nit | 4 +++- src/ffi/c.nit | 4 ++++ src/ffi/ffi.nit | 6 +++++- src/ffi/pkgconfig.nit | 10 +--------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/compiler/compiler_ffi.nit b/src/compiler/compiler_ffi.nit index e9c740a..6a36b2b 100644 --- a/src/compiler/compiler_ffi.nit +++ b/src/compiler/compiler_ffi.nit @@ -53,7 +53,9 @@ extern void nitni_global_ref_decr(void*); 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 diff --git a/src/ffi/c.nit b/src/ffi/c.nit index 92697f5..44841a8 100644 --- a/src/ffi/c.nit +++ b/src/ffi/c.nit @@ -74,6 +74,10 @@ end 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 diff --git a/src/ffi/ffi.nit b/src/ffi/ffi.nit index a418616..a2dda26 100644 --- a/src/ffi/ffi.nit +++ b/src/ffi/ffi.nit @@ -60,7 +60,11 @@ redef class MModule 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 diff --git a/src/ffi/pkgconfig.nit b/src/ffi/pkgconfig.nit index 335d8d1..dca4fab 100644 --- a/src/ffi/pkgconfig.nit +++ b/src/ffi/pkgconfig.nit @@ -87,15 +87,7 @@ class PkgconfigPhase 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 -- 1.7.9.5