⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.10
Server IP:
157.245.101.34
Server:
Linux skvinfotech-website 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_64
Server Software:
Apache/2.4.41 (Ubuntu)
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
gtk-doc
/
html
/
gobject
/
View File Name :
glib-mkenums.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>glib-mkenums: GObject Reference Manual</title> <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> <link rel="home" href="index.html" title="GObject Reference Manual"> <link rel="up" href="rn02.html" title="Tools Reference"> <link rel="prev" href="rn02.html" title="Tools Reference"> <link rel="next" href="glib-genmarshal.html" title="glib-genmarshal"> <meta name="generator" content="GTK-Doc V1.32 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> <td width="100%" align="left" class="shortcuts"></td> <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> <td><a accesskey="u" href="rn02.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> <td><a accesskey="p" href="rn02.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> <td><a accesskey="n" href="glib-genmarshal.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> </tr></table> <div lang="en" class="refentry"> <a name="glib-mkenums"></a><div class="titlepage"></div> <div class="refnamediv"><table width="100%"><tr> <td valign="top"> <h2><span class="refentrytitle">glib-mkenums</span></h2> <p>glib-mkenums — C language enum description generation utility</p> </td> <td class="gallery_image" valign="top" align="right"></td> </tr></table></div> <div class="refsynopsisdiv"> <h2>Synopsis</h2> <div class="cmdsynopsis"><p><code class="command">glib-mkenums</code> [OPTION...] [FILE...]</p></div> </div> <div class="refsect1"> <a name="id-1.5.2.5"></a><h2>Description</h2> <p><span class="command"><strong>glib-mkenums</strong></span> is a small utility that parses C code to extract enum definitions and produces enum descriptions based on text templates specified by the user. Typically, you can use this tool to generate enumeration types for the GType type system, for GObject properties and signal marshalling; additionally, you can use it to generate enumeration values of GSettings schemas. </p> <p><span class="command"><strong>glib-mkenums</strong></span> takes a list of valid C code files as input. The options specified control the text that generated, substituting various keywords enclosed in <code class="literal">@</code> characters in the templates. </p> <div class="refsect2"> <a name="id-1.5.2.5.4"></a><h3>Production text substitutions</h3> <p> Certain keywords enclosed in <code class="literal">@</code> characters will be substituted in the emitted text. For the substitution examples of the keywords below, the following example enum definition is assumed: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5</pre></td> <td class="listing_code"><pre class="programlisting"><span class="k">typedef</span> <span class="k">enum</span> <span class="p">{</span> <span class="n">PREFIX_THE_XVALUE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o"><<</span> <span class="mi">3</span><span class="p">,</span> <span class="n">PREFIX_ANOTHER_VALUE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o"><<</span> <span class="mi">4</span> <span class="p">}</span> <span class="n">PrefixTheXEnum</span><span class="p">;</span></pre></td> </tr> </tbody> </table> </div> <div class="variablelist"><table border="0" class="variablelist"> <colgroup> <col align="left" valign="top"> <col> </colgroup> <tbody> <tr> <td><p><span class="term"><code class="literal">@EnumName@</code>></span></p></td> <td><p> The name of the enum currently being processed, enum names are assumed to be properly namespaced and to use mixed capitalization to separate words (e.g. <code class="literal">PrefixTheXEnum</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@enum_name@</code></span></p></td> <td><p> The enum name with words lowercase and word-separated by underscores (e.g. <code class="literal">prefix_the_xenum</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@ENUMNAME@</code></span></p></td> <td><p> The enum name with words uppercase and word-separated by underscores (e.g. <code class="literal">PREFIX_THE_XENUM</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@ENUMSHORT@</code></span></p></td> <td><p> The enum name with words uppercase and word-separated by underscores, prefix stripped (e.g. <code class="literal">THE_XENUM</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@ENUMPREFIX@</code></span></p></td> <td><p> The prefix of the enum name (e.g. <code class="literal">PREFIX</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@VALUENAME@</code></span></p></td> <td><p> The enum value name currently being processed with words uppercase and word-separated by underscores, this is the assumed literal notation of enum values in the C sources (e.g. <code class="literal">PREFIX_THE_XVALUE</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@valuenick@</code></span></p></td> <td><p> A nick name for the enum value currently being processed, this is usually generated by stripping common prefix words of all the enum values of the current enum, the words are lowercase and underscores are substituted by a minus (e.g. <code class="literal">the-xvalue</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@valuenum@</code></span></p></td> <td><p> The integer value for the enum value currently being processed. If the evaluation fails then <span class="command"><strong>glib-mkenums</strong></span> will exit with an error status, but this only happens if <code class="literal">@valuenum@</code> appears in your value production template. (Since: 2.26) </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@type@</code></span></p></td> <td><p> This is substituted either by "enum" or "flags", depending on whether the enum value definitions contained bit-shift operators or not (e.g. <code class="literal">flags</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@Type@</code></span></p></td> <td><p> The same as <code class="literal">@type@</code> with the first letter capitalized (e.g. <code class="literal">Flags</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@TYPE@</code></span></p></td> <td><p> The same as <code class="literal">@type@</code> with all letters uppercased (e.g. <code class="literal">FLAGS</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@filename@</code></span></p></td> <td><p> The full path of the input file currently being processed (e.g. <code class="literal">/build/environment/project/src/foo.h</code>). </p></td> </tr> <tr> <td><p><span class="term"><code class="literal">@basename@</code></span></p></td> <td><p> The base name of the input file currently being processed (e.g. <code class="literal">foo.h</code>). Typically you want to use <code class="literal">@basename@</code> in place of <code class="literal">@filename@</code> in your templates, to improve the reproducibility of the build. (Since: 2.22) </p></td> </tr> </tbody> </table></div> </div> <hr> <div class="refsect2"> <a name="id-1.5.2.5.5"></a><h3>Trigraph extensions</h3> <p> Some C comments are treated specially in the parsed enum definitions, such comments start out with the trigraph sequence <code class="literal">/*<</code> and end with the trigraph sequence <code class="literal">>*/</code>. Per enum definition, the options <code class="literal">skip</code> and <code class="literal">flags</code> can be specified, to indicate this enum definition to be skipped, or for it to be treated as a flags definition, or to specify the common prefix to be stripped from all values to generate value nicknames, respectively. The <code class="literal">underscore_name</code> option can be used to specify the word separation used in the <code class="function">*_get_type()</code> function. For instance, <code class="literal">/*< underscore_name=gnome_vfs_uri_hide_options >*/</code>. </p> <p> Per value definition, the options <code class="literal">skip</code> and <code class="literal">nick</code> are supported. The former causes the value to be skipped, and the latter can be used to specify the otherwise auto-generated nickname. Examples: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10 11</pre></td> <td class="listing_code"><pre class="programlisting"><span class="k">typedef</span> <span class="k">enum</span> <span class="cm">/*< skip >*/</span> <span class="p">{</span> <span class="n">PREFIX_FOO</span> <span class="p">}</span> <span class="n">PrefixThisEnumWillBeSkipped</span><span class="p">;</span> <span class="k">typedef</span> <span class="k">enum</span> <span class="cm">/*< flags,prefix=PREFIX >*/</span> <span class="p">{</span> <span class="n">PREFIX_THE_ZEROTH_VALUE</span><span class="p">,</span> <span class="cm">/*< skip >*/</span> <span class="n">PREFIX_THE_FIRST_VALUE</span><span class="p">,</span> <span class="n">PREFIX_THE_SECOND_VALUE</span><span class="p">,</span> <span class="n">PREFIX_THE_THIRD_VALUE</span><span class="p">,</span> <span class="cm">/*< nick=the-last-value >*/</span> <span class="p">}</span> <span class="n">PrefixTheFlagsEnum</span><span class="p">;</span></pre></td> </tr> </tbody> </table> </div> </div> </div> <div class="refsect1"> <a name="id-1.5.2.6"></a><h2>Options</h2> <div class="variablelist"><table border="0" class="variablelist"> <colgroup> <col align="left" valign="top"> <col> </colgroup> <tbody> <tr> <td><p><span class="term"><code class="option">--fhead</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td> <p> Emits <em class="replaceable"><code>TEXT</code></em> prior to processing input files. </p> <p> You can specify this option multiple times, and the <em class="replaceable"><code>TEXT</code></em> will be concatenated. </p> <p> When used along with a template file, <em class="replaceable"><code>TEXT</code></em> will be prepended to the template's <code class="literal">file-header</code> section. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--fprod</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td> <p> Emits <em class="replaceable"><code>TEXT</code></em> every time a new input file is being processed. </p> <p> You can specify this option multiple times, and the <em class="replaceable"><code>TEXT</code></em> will be concatenated. </p> <p> When used along with a template file, <em class="replaceable"><code>TEXT</code></em> will be appended to the template's <code class="literal">file-production</code> section. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--ftail</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td> <p> Emits <em class="replaceable"><code>TEXT</code></em> after all input files have been processed. </p> <p> You can specify this option multiple times, and the <em class="replaceable"><code>TEXT</code></em> will be concatenated. </p> <p> When used along with a template file, <em class="replaceable"><code>TEXT</code></em> will be appended to the template's <code class="literal">file-tail</code> section. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--eprod</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td><p> Emits <em class="replaceable"><code>TEXT</code></em> every time an enum is encountered in the input files. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">--vhead</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td> <p> Emits <em class="replaceable"><code>TEXT</code></em> before iterating over the set of values of an enum. </p> <p> You can specify this option multiple times, and the <em class="replaceable"><code>TEXT</code></em> will be concatenated. </p> <p> When used along with a template file, <em class="replaceable"><code>TEXT</code></em> will be prepended to the template's <code class="literal">value-header</code> section. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--vprod</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td> <p> Emits <em class="replaceable"><code>TEXT</code></em> for every value of an enum. </p> <p> You can specify this option multiple times, and the <em class="replaceable"><code>TEXT</code></em> will be concatenated. </p> <p> When used along with a template file, <em class="replaceable"><code>TEXT</code></em> will be appended to the template's <code class="literal">value-production</code> section. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--vtail</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td> <p> Emits <em class="replaceable"><code>TEXT</code></em> after iterating over all values of an enum. </p> <p> You can specify this option multiple times, and the <em class="replaceable"><code>TEXT</code></em> will be concatenated. </p> <p> When used along with a template file, <em class="replaceable"><code>TEXT</code></em> will be appended to the template's <code class="literal">value-tail</code> section. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--comments</code> <em class="replaceable"><code>TEXT</code></em></span></p></td> <td><p> Template for auto-generated comments, the default (for C code generations) is <code class="literal">"/* @comment@ */"</code>. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">--template</code> <em class="replaceable"><code>FILE</code></em></span></p></td> <td> <p> Read templates from the given file. The templates are enclosed in specially-formatted C comments: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2</pre></td> <td class="listing_code"><pre class="programlisting"><span class="cm">/*** BEGIN section ***/</span> <span class="cm">/*** END section ***/</span></pre></td> </tr> </tbody> </table> </div> <p> <em class="replaceable"><code>section</code></em> may be <code class="literal">file-header</code>, <code class="literal">file-production</code>, <code class="literal">file-tail</code>, <code class="literal">enumeration-production</code>, <code class="literal">value-header</code>, <code class="literal">value-production</code>, <code class="literal">value-tail</code> or <code class="literal">comment</code>. </p> </td> </tr> <tr> <td><p><span class="term"><code class="option">--identifier-prefix</code> <em class="replaceable"><code>PREFIX</code></em></span></p></td> <td><p> Indicates what portion of the enum name should be interpreted as the prefix (eg, the "<code class="literal">Gtk</code>" in "<code class="literal">GtkDirectionType</code>"). Normally this will be figured out automatically, but you may need to override the default if your namespace is capitalized oddly. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">--symbol-prefix</code> <em class="replaceable"><code>PREFIX</code></em></span></p></td> <td><p> Indicates what prefix should be used to correspond to the identifier prefix in related C function names (eg, the "<code class="literal">gtk</code>" in "<code class="literal">gtk_direction_type_get_type</code>". Equivalently, this is the lowercase version of the prefix component of the enum value names (eg, the "<code class="literal">GTK</code>" in "<code class="literal">GTK_DIR_UP</code>". The default value is the identifier prefix, converted to lowercase. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">--help</code></span></p></td> <td><p> Print brief help and exit. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">--version</code></span></p></td> <td><p> Print version and exit. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">--output=FILE</code></span></p></td> <td><p> Write output to FILE instead of stdout. </p></td> </tr> <tr> <td><p><span class="term"><code class="option">@RSPFILE</code></span></p></td> <td><p> When passed as the sole argument, read and parse the actual arguments from <code class="literal">RSPFILE</code>. Useful on systems with a low command-line length limit. For example, Windows has a limit of 8191 characters. </p></td> </tr> </tbody> </table></div> </div> <div class="refsect1"> <a name="id-1.5.2.7"></a><h2>Using templates</h2> <p> Instead of passing the various sections of the generated file to the command line of <span class="command"><strong>glib-mkenums</strong></span>, it's strongly recommended to use a template file, especially for generating C sources. </p> <p> A C header template file will typically look like this: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22</pre></td> <td class="listing_code"><pre class="programlisting"><span class="cm">/*** BEGIN file-header ***/</span> <span class="cp">#pragma once</span> <span class="cm">/* Include the main project header */</span> <span class="cp">#include</span> <span class="cpf">"project.h"</span><span class="cp"></span> <span class="n">G_BEGIN_DECLS</span> <span class="cm">/*** END file-header ***/</span> <span class="cm">/*** BEGIN file-production ***/</span> <span class="cm">/* enumerations from "@basename@" */</span> <span class="cm">/*** END file-production ***/</span> <span class="cm">/*** BEGIN value-header ***/</span> <span class="n">GType</span> <span class="err">@</span><span class="n">enum_name</span><span class="err">@</span><span class="n">_get_type</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">G_GNUC_CONST</span><span class="p">;</span> <span class="cp">#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())</span> <span class="cm">/*** END value-header ***/</span> <span class="cm">/*** BEGIN file-tail ***/</span> <span class="n">G_END_DECLS</span> <span class="cm">/*** END file-tail ***/</span></pre></td> </tr> </tbody> </table> </div> <p> A C source template file will typically look like this: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38</pre></td> <td class="listing_code"><pre class="programlisting"><span class="cm">/*** BEGIN file-header ***/</span> <span class="cp">#include</span> <span class="cpf">"config.h"</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">"enum-types.h"</span><span class="cp"></span> <span class="cm">/*** END file-header ***/</span> <span class="cm">/*** BEGIN file-production ***/</span> <span class="cm">/* enumerations from "@basename@" */</span> <span class="cm">/*** END file-production ***/</span> <span class="cm">/*** BEGIN value-header ***/</span> <span class="n">GType</span> <span class="err">@</span><span class="n">enum_name</span><span class="err">@</span><span class="n">_get_type</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span> <span class="k">static</span> <span class="k">volatile</span> <span class="n">gsize</span> <span class="n">g_</span><span class="err">@</span><span class="n">type</span><span class="err">@</span><span class="n">_type_id__volatile</span><span class="p">;</span> <span class="k">if</span> <span class="p">(</span><span class="n">g_once_init_enter</span> <span class="p">(</span><span class="o">&</span><span class="n">g_define_type_id__volatile</span><span class="p">))</span> <span class="p">{</span> <span class="k">static</span> <span class="k">const</span> <span class="n">G</span><span class="err">@</span><span class="n">Type</span><span class="err">@</span><span class="n">Value</span> <span class="n">values</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="cm">/*** END value-header ***/</span> <span class="cm">/*** BEGIN value-production ***/</span> <span class="p">{</span> <span class="err">@</span><span class="n">VALUENAME</span><span class="err">@</span><span class="p">,</span> <span class="s">"@VALUENAME@"</span><span class="p">,</span> <span class="s">"@valuenick@"</span> <span class="p">},</span> <span class="cm">/*** END value-production ***/</span> <span class="cm">/*** BEGIN value-tail ***/</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span> <span class="p">}</span> <span class="p">};</span> <span class="n">GType</span> <span class="n">g_</span><span class="err">@</span><span class="n">type</span><span class="err">@</span><span class="n">_type_id</span> <span class="o">=</span> <span class="n">g_</span><span class="err">@</span><span class="n">type</span><span class="err">@</span><span class="n">_register_static</span> <span class="p">(</span><span class="n">g_intern_static_string</span> <span class="p">(</span><span class="s">"@EnumName@"</span><span class="p">),</span> <span class="n">values</span><span class="p">);</span> <span class="n">g_once_init_leave</span> <span class="p">(</span><span class="o">&</span><span class="n">g_</span><span class="err">@</span><span class="n">type</span><span class="err">@</span><span class="n">_type_id__volatile</span><span class="p">,</span> <span class="n">g_</span><span class="err">@</span><span class="n">type</span><span class="err">@</span><span class="n">_type_id</span><span class="p">);</span> <span class="p">}</span> <span class="k">return</span> <span class="n">g_</span><span class="err">@</span><span class="n">type</span><span class="err">@</span><span class="n">_type_id__volatile</span><span class="p">;</span> <span class="p">}</span> <span class="cm">/*** END value-tail ***/</span></pre></td> </tr> </tbody> </table> </div> <p> Template files are easier to modify and update, and can be used to generate various types of outputs using the same command line or tools during the build. </p> </div> <div class="refsect1"> <a name="id-1.5.2.8"></a><h2>Using glib-mkenums with Meson</h2> <p> Meson supports generating enumeration types using <span class="command"><strong>glib-mkenums</strong></span> out of the box in its "gnome" module. </p> <p> In your <code class="filename">meson.build</code> file you will typically call the <code class="literal">gnome.mkenums_simple()</code> method to generate idiomatic enumeration types from a list of headers to inspect: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10</pre></td> <td class="listing_code"><pre class="programlisting"><span class="n">project_headers</span> <span class="o">=</span> <span class="p">[</span> <span class="err">'</span><span class="n">project</span><span class="o">-</span><span class="n">foo</span><span class="p">.</span><span class="n">h</span><span class="err">'</span><span class="p">,</span> <span class="err">'</span><span class="n">project</span><span class="o">-</span><span class="n">bar</span><span class="p">.</span><span class="n">h</span><span class="err">'</span><span class="p">,</span> <span class="err">'</span><span class="n">project</span><span class="o">-</span><span class="n">baz</span><span class="p">.</span><span class="n">h</span><span class="err">'</span><span class="p">,</span> <span class="p">]</span> <span class="n">gnome</span> <span class="o">=</span> <span class="n">import</span><span class="p">(</span><span class="err">'</span><span class="n">gnome</span><span class="err">'</span><span class="p">)</span> <span class="n">enum_files</span> <span class="o">=</span> <span class="n">gnome</span><span class="p">.</span><span class="n">mkenums_simple</span><span class="p">(</span><span class="err">'</span><span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="err">'</span><span class="p">,</span> <span class="nl">sources</span><span class="p">:</span> <span class="n">project_headers</span><span class="p">,</span> <span class="p">)</span></pre></td> </tr> </tbody> </table> </div> <p> The <code class="literal">enum_files</code> variable will contain an array of two elements in the following order: </p> <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"><p>a build target for the source file</p></li> <li class="listitem"><p>a build target for the header file</p></li> </ul></div> <p> You should use the returned objects to provide a dependency on every other build target that references the source or header file; for instance, if you are using the source to build a library: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4</pre></td> <td class="listing_code"><pre class="programlisting"><span class="n">mainlib</span> <span class="o">=</span> <span class="n">library</span><span class="p">(</span><span class="err">'</span><span class="n">project</span><span class="err">'</span><span class="p">,</span> <span class="nl">sources</span><span class="p">:</span> <span class="n">project_sources</span> <span class="o">+</span> <span class="n">enum_files</span><span class="p">,</span> <span class="p">...</span> <span class="p">)</span></pre></td> </tr> </tbody> </table> </div> <p> Additionally, if you are including the generated header file inside a build target that depends on the library you just built, you must ensure that the internal dependency includes the generated header as a required source file: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1</pre></td> <td class="listing_code"><pre class="programlisting"><span class="n">mainlib_dep</span> <span class="o">=</span> <span class="n">declare_dependency</span><span class="p">(</span><span class="nl">sources</span><span class="p">:</span> <span class="n">enum_files</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nl">link_with</span><span class="p">:</span> <span class="n">mainlib</span><span class="p">)</span></pre></td> </tr> </tbody> </table> </div> <p> You should not include the generated source file as well, otherwise it will be built separately for every target that depends on it, causing build failures. To know more about why all this is required, please refer to the <a class="ulink" href="https://mesonbuild.com/FAQ.html#how-do-i-tell-meson-that-my-sources-use-generated-headers" target="_top"> corresponding Meson FAQ entry</a>. </p> <p> If you are generating C header and source files that require special templates, you can use <code class="literal">gnome.mkenums()</code> to provide those headers, for instance: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6</pre></td> <td class="listing_code"><pre class="programlisting"><span class="n">enum_files</span> <span class="o">=</span> <span class="n">gnome</span><span class="p">.</span><span class="n">mkenums</span><span class="p">(</span><span class="err">'</span><span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="err">'</span><span class="p">,</span> <span class="nl">sources</span><span class="p">:</span> <span class="n">project_headers</span><span class="p">,</span> <span class="nl">h_template</span><span class="p">:</span> <span class="err">'</span><span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span><span class="p">.</span><span class="n">in</span><span class="err">'</span><span class="p">,</span> <span class="nl">c_template</span><span class="p">:</span> <span class="err">'</span><span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">c</span><span class="p">.</span><span class="n">in</span><span class="err">'</span><span class="p">,</span> <span class="nl">install_header</span><span class="p">:</span> <span class="nb">true</span><span class="p">,</span> <span class="p">)</span></pre></td> </tr> </tbody> </table> </div> <p> For more information, see the <a class="ulink" href="https://mesonbuild.com/Gnome-module.html#gnomegenmarshal" target="_top">Meson documentation for <code class="literal">gnome.mkenums()</code></a>. </p> </div> <div class="refsect1"> <a name="id-1.5.2.9"></a><h2>Using glib-mkenums with Autotools</h2> <p> In order to use <span class="command"><strong>glib-mkenums</strong></span> in your project when using Autotools as the build system, you will first need to modify your <code class="filename">configure.ac</code> file to ensure you find the appropriate command using <span class="command"><strong>pkg-config</strong></span>, similarly as to how you discover the compiler and linker flags for GLib. </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3</pre></td> <td class="listing_code"><pre class="programlisting"><span class="n">PKG_PROG_PKG_CONFIG</span><span class="p">([</span><span class="mf">0.28</span><span class="p">])</span> <span class="n">PKG_CHECK_VAR</span><span class="p">([</span><span class="n">GLIB_MKENUMS</span><span class="p">],</span> <span class="p">[</span><span class="n">glib</span><span class="o">-</span><span class="mf">2.0</span><span class="p">],</span> <span class="p">[</span><span class="n">glib_mkenums</span><span class="p">])</span></pre></td> </tr> </tbody> </table> </div> <p> In your <code class="filename">Makefile.am</code> file you will typically use rules like these: </p> <div class="informalexample"> <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="listing_lines" align="right"><pre>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22</pre></td> <td class="listing_code"><pre class="programlisting"><span class="cp"># A list of headers to inspect</span> <span class="n">project_headers</span> <span class="o">=</span> \ <span class="n">project</span><span class="o">-</span><span class="n">foo</span><span class="p">.</span><span class="n">h</span> \ <span class="n">project</span><span class="o">-</span><span class="n">bar</span><span class="p">.</span><span class="n">h</span> \ <span class="n">project</span><span class="o">-</span><span class="n">baz</span><span class="p">.</span><span class="n">h</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="nl">h</span><span class="p">:</span> <span class="err">$</span><span class="p">(</span><span class="n">project_headers</span><span class="p">)</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span><span class="p">.</span><span class="n">in</span> <span class="err">$</span><span class="p">(</span><span class="n">AM_V_GEN</span><span class="p">)</span><span class="err">$</span><span class="p">(</span><span class="n">GLIB_MKENUMS</span><span class="p">)</span> \ <span class="o">--</span><span class="n">template</span><span class="o">=</span><span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span><span class="p">.</span><span class="n">in</span> \ <span class="o">--</span><span class="n">output</span><span class="o">=</span><span class="err">$@</span> \ <span class="err">$</span><span class="p">(</span><span class="n">project_headers</span><span class="p">)</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="nl">c</span><span class="p">:</span> <span class="err">$</span><span class="p">(</span><span class="n">project_headers</span><span class="p">)</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">c</span><span class="p">.</span><span class="n">in</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span> <span class="err">$</span><span class="p">(</span><span class="n">AM_V_GEN</span><span class="p">)</span><span class="err">$</span><span class="p">(</span><span class="n">GLIB_MKENUMS</span><span class="p">)</span> \ <span class="o">--</span><span class="n">template</span><span class="o">=</span><span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">c</span><span class="p">.</span><span class="n">in</span> \ <span class="o">--</span><span class="n">output</span><span class="o">=</span><span class="err">$@</span> \ <span class="err">$</span><span class="p">(</span><span class="n">project_headers</span><span class="p">)</span> <span class="cp"># Build the enum types files before every other target</span> <span class="n">BUILT_SOURCES</span> <span class="o">+=</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">c</span> <span class="n">CLEANFILES</span> <span class="o">+=</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">c</span> <span class="n">EXTRA_DIST</span> <span class="o">+=</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">h</span><span class="p">.</span><span class="n">in</span> <span class="k">enum</span><span class="o">-</span><span class="n">types</span><span class="p">.</span><span class="n">c</span><span class="p">.</span><span class="n">in</span></pre></td> </tr> </tbody> </table> </div> <p> In the example above, we have a variable called <code class="literal">project_headers</code> where we reference all header files we want to inspect for generating enumeration GTypes. In the <code class="filename">enum-types.h</code> rule we use <span class="command"><strong>glib-mkenums</strong></span> with a template called <code class="filename">enum-types.h.in</code> in order to generate the header file; similarly, in the <code class="filename">enum-types.c</code> rule we use a template called <code class="filename">enum-types.c.in</code>. </p> </div> <div class="refsect1"> <a name="id-1.5.2.10"></a><h2>See also</h2> <p> <span class="citerefentry"><span class="refentrytitle">glib-genmarshal</span>(1)</span> </p> </div> </div> <div class="footer"> <hr>Generated by GTK-Doc V1.32</div> </body> </html>