ffi/pkgconfig: use the new pkgconfig infrastructure in the Makefile
authorJean Privat <jean@pryen.org>
Tue, 4 Nov 2014 16:35:32 +0000 (11:35 -0500)
committerJean Privat <jean@pryen.org>
Tue, 4 Nov 2014 18:02:19 +0000 (13:02 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/compiler_ffi.nit
src/ffi/c.nit
src/ffi/ffi.nit
src/ffi/pkgconfig.nit

index e9c740a..6a36b2b 100644 (file)
@@ -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
index 92697f5..44841a8 100644 (file)
@@ -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
index a418616..a2dda26 100644 (file)
@@ -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
index 335d8d1..dca4fab 100644 (file)
@@ -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