1 <refentry id="glib-compile-resources" lang="en">
4 <title>glib-compile-schemas</title>
5 <productname>GIO</productname>
8 <contrib>Developer</contrib>
9 <firstname>Alexander</firstname>
10 <surname>Larsson</surname>
16 <refentrytitle>glib-compile-resources</refentrytitle>
17 <manvolnum>1</manvolnum>
18 <refmiscinfo class="manual">User Commands</refmiscinfo>
22 <refname>glib-compile-resources</refname>
23 <refpurpose>GLib resource compiler</refpurpose>
28 <command>glib-compile-resources</command>
29 <arg choice="opt" rep="repeat">OPTION</arg>
30 <arg choice="req">FILE</arg>
34 <refsect1><title>Description</title>
35 <para><command>glib-compile-resources</command> reads the resource description from
36 <replaceable>FILE</replaceable> and the files that it references
37 and creates a binary resource bundle that is suitable for use with the
38 <link linkend="GResource"><type>GResource</type></link> API.
39 The resulting bundle is then written out as-is, or as C source for linking into
43 The XML resource files normally have the filename extension <filename>.gresource.xml</filename>.
44 For a detailed description of the XML file format, see the
45 <link linkend="GResource"><type>GResource</type></link> documentation.
49 <refsect1><title>Options</title>
53 <term><option>-h</option>, <option>--help</option></term>
60 <term><option>--version</option></term>
62 Print program version and exit
67 <term><option>--target=<replaceable>TARGET</replaceable></option></term>
69 Store the compiled resources in the file <replaceable>TARGET</replaceable>.
70 If not specified a filename based on the <replaceable>FILE</replaceable>
76 <term><option>--sourcedir=<replaceable>DIRECTORY</replaceable></option></term>
78 The files referenced in <replaceable>FILE</replaceable> are loaded from
79 this directory. If not specified, the current directory is used.
84 <term><option>--generate</option></term>
86 Write the output file in the format selected for by its filename extension:
89 <term><literal>.c</literal></term>
90 <listitem><para>C source</para></listitem>
93 <term><literal>.h</literal></term>
94 <listitem><para>C header</para></listitem>
97 <term><literal>.gresource</literal></term>
98 <listitem><para>resource bundle</para></listitem>
105 <term><option>--generate-source</option></term>
107 Instead of a writing the resource bundle in binary form create a C source file
108 that contains the resource bundle. This can then be compiled into an
109 application for easy access.
114 <term><option>--generate-header</option></term>
116 Generate a header file for use with C code generated by
117 <option>--generate-source</option>.
122 <term><option>--generate-dependencies</option></term>
124 Prints the list of files that the resource bundle references to standard output.
125 This can be used to track dependencies in the build system. For example, the
126 following make rule would mark <replaceable>test.gresource</replaceable> as
127 depending on all the files that <replaceable>test.gresource.xml</replaceable>
128 includes, so that is is automatically rebuilt if any of them change:
130 test.gresource: test.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies test.gresource.xml)
132 Note that this may or may not be portable to non-GNU <command>make</command>.
135 Also see <option>--dependency-file</option>.
141 <term><option>--c-name</option></term>
143 Specify the prefix used for the C identifiers in the code generated by
144 <option>--generate-source</option> and <option>--generate-header</option>.
149 <term><option>--manual-register</option></term>
151 By default code generated by <option>--generate-source</option> uses automatic
152 initialization of the resource. This works on most systems by using the
153 compiler support for constructors. However, some (uncommon) compilers may not
154 support this, you can then specify <option>--manual-register</option>,
155 which will generate custom register and unregister functions that your code
156 can manually call at initialization and uninitialization time.
161 <term><option>--internal</option></term>
163 By default code generated by <option>--generate-source</option> declares all
164 initialization functions as <type>extern</type>. So they are exported
165 unless this is prevented by a link script or other means. Since libraries
166 usually want to use the functions only internally it can be more useful to
168 <link linkend="G-GNUC-INTERNAL:CAPS"><literal>G_GNUC_INTERNAL</literal></link>
169 which is what <option>--internal</option> does.
174 <term><option>--dependency-file=<replaceable>FILE</replaceable></option></term>
176 Write dependencies in the same style as gcc -M -MF to the given file.
177 If <option>FILE</option> is -, the dependencies are written to the standard
178 output. Unlike <option>--generate-dependencies</option>, this option can be
179 combined with other <option>--generate</option> options to generate dependencies
180 as a side-effect of generating sources.
185 <term><option>--generate-phony-targets</option></term>
187 When creating a dependency file with <option>--dependency-file</option>
188 include phony targets in the same style as gcc -MP. This would typically
189 be used with <literal>make</literal>.
196 <refsect1><title>Environment</title>
200 <term><envar>XMLLINT</envar></term>
202 The full path to the <command>xmllint</command> executable. This is used to
203 preprocess resources with the <literal>xml-stripblanks</literal> preprocessing
204 option. If this environment variable is not set, <command>xmllint</command> is
205 searched for in the <envar>PATH</envar>.
210 <term><envar>GDK_PIXBUF_PIXDATA</envar></term>
212 The full path to the <command>gdk-pixbuf-pixdata</command> executable. This is
213 used to preprocess resources with the <literal>to-pixdata</literal> preprocessing
214 option. If this environment variable is not set, <command>gdk-pixbuf-pixdata</command>
215 is searched for in the <envar>PATH</envar>.
220 <term><envar>JSON_GLIB_FORMAT</envar></term>
222 The full path to the <command>json-glib-format</command> executable. This is used
223 to preprocess resources with the <literal>json-stripblanks</literal> preprocessing
224 option. If this environment variable is not set, <command>json-glib-format</command>
225 is searched for in the <envar>PATH</envar>.