Re: [Vala] Setting prefix and paths at configure time.



On Tue, 2008-09-23 at 23:55 +0200, Federico Pelloni wrote:
In my project I need to load some custom pixmaps that will be
installed into $prefix/share/projectname/pixmaps, with $prefix being
set at configure time. Classical situation for many applications. How
can I make my program find that files?
I'm using Waf to configure/build/install my application, and I can
have created a config.h file with those paths defined, but I don't
know how to access them within my .vala files.
I saw some projects (Valaide for example) using a "Config" namespace
or class, but I could not understand how it works.
I'd be glad if someone could explain me which direction I've to go to
solve this problem.

Thank you.

Federico Pelloni
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list

Hi Federico,

to use your generated config.h file you have to wrap it in a vapi file
and the compile it with your project.

E.g. you have to write a config.vapi file like this:

[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename =
"config.h")]
namespace Config {
        public const string VERSION;
        public const string PACKAGE_VERSION;
        public const string PACKAGE_STRING;
        public const string PACKAGE_DATA_DIR;
        public const string GETTEXT_PACKAGE;

        .... etc etc ....
}

and then compile it with your sources.

eg.

valac <your source files> --vapidir ./ --pkg config

or

valac <your source files> config.vapi

Cheers,
Andrea





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]