Search code examples
cadagprbuild

Shell command to compile C in Gprbuild


Using GtkAda, I'm trying to use the resource API to include the Glade file directly inside my code.

For this, we can generate C code from a set of resources using glib-compile-resources which can then be linked to the Ada code.

The problem is that this C code requires Gtk includes which we usually get from the pkg-config command under Linux such as

gcc -c -x c `pkg-config --cflags gio-2.0` myglade.gresource.c

I'd like to know how to provide the same kind of information in a GPRBuild project file.

FYI, I already tried to use the pkg-config command inside the compiler package for C language without any success. Of course, I managed to build by hand but that's a bit long :)


Solution

  • This might work for you:

    project Config_Demo is
       Pkg_Config := external_as_list ("PKG_CONFIG", " ");
       package Compiler is
          --  only this file needs the extra switches
          for Switches ("myglade.gresource.c") use Pkg_Config;
       end Compiler;
    end Config_Demo;
    

    and then

    gprbuild -P config_demo -XPKG_CONFIG="`pkg-config -cflags gio-2.0`"