LinuxCommandLibrary

glib-compile-resources

Compile XML resource descriptions into binary data

TLDR

Compile resources referenced in file.gresource.xml to a .gresource binary

$ glib-compile-resources [file.gresource.xml]
copy

Compile resources referenced in file.gresource.xml to a C source file
$ glib-compile-resources --generate-source [file.gresource.xml]
copy

Compile resources in file.gresource.xml to a chosen target file, with .c, .h or .gresource extension
$ glib-compile-resources --generate --target=[file.ext] [file.gresource.xml]
copy

Print a list of resource files referenced in file.gresource.xml
$ glib-compile-resources --generate-dependencies [file.gresource.xml]
copy

SYNOPSIS

glib-compile-resources [OPTIONS...] RESOURCE_XML_FILE

PARAMETERS

--generate
    Generate C source code for embedding the resource data in an application.

--target=FILENAME
    Output file name for the generated data, resource bundle, or source code.

--sourcedir=DIRECTORY
    Base directory for sources.

--dependency-file=FILENAME
    Write dependencies to the specified file.

--stripblanks
    Strip blank text nodes in XML files.

--verbose
    Enable verbose output.

--version
    Print the version number and exit.

--help
    Show help options.

RESOURCE_XML_FILE
    The XML file describing the resources to be compiled.

DESCRIPTION

glib-compile-resources is a command-line utility that compiles resource bundles from XML descriptions into binary resource files. These binary files can then be embedded into applications, allowing the application to access resources such as icons, UI descriptions, and other data without needing to distribute them separately.

The primary purpose of this tool is to efficiently package resources specified in a human-readable XML format into a compact, binary format optimized for fast lookup and retrieval during application runtime. This simplifies distribution and ensures that application resources are available, even when the application is installed in locations where external files cannot be easily accessed. The generated binary file is designed to be used with the GResource API provided by GLib.

CAVEATS

The behavior of glib-compile-resources depends heavily on the structure and contents of the XML file provided as input. Ensure that the XML file adheres to the GResource schema. Incorrectly formatted XML can lead to compilation errors or unexpected runtime behavior. Using the --generate option requires careful integration of the generated C source code into the application's build process.

USING WITH MESON

To use glib-compile-resources with Meson use `gnome.compile_resources` function.

HISTORY

glib-compile-resources was introduced as part of the GLib library to provide a standardized way to manage and embed application resources. Its development was driven by the need to simplify application deployment and ensure resource availability across different platforms and environments. The tool has evolved alongside the GResource API, adding features such as dependency tracking and code generation to improve developer workflows.

SEE ALSO

Copied to clipboard