cabal-gresource
Copyright(c) Rafał Kuźnia 2026
LicenseBSD3
Maintainerrafal.kuznia@protonmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Distribution.Simple.GResource

Description

There are two ways to integrate the module into your package's build, one for build-type: Hooks, second one for build-type: Custom. Unless you are constrained to use the Custom build type, using Hooks is the recommended approach.

To build and link a GResource file with your application, add x-gresource-xml-file and optionally x-gresource-source-dir to your executable stanza. The x-gresource-xml-file points to the XML manifest describing the GResource file content, while x-gresource-source-dir is the base path from which relative paths in the XML file will be resolved.

Synopsis

Integration hooks

gResourceSetupHooks :: SetupHooks Source #

Hook for building the GResource files with build-type: Hooks. Use in SetupHooks.hs to integrate into the build process.

module SetupHooks (setupHooks) where

import Distribution.Simple.GResource.Hooks (gResourceSetupHooks)
import Distribution.Simple.SetupHooks (SetupHooks)

setupHooks :: SetupHooks
setupHooks = gResourceSetupHooks

Add cabal-gresource to setup-depends:

build-type: Hooks

custom-setup
  setup-depends:
    base,
    Cabal-hooks,
    cabal-gresource

executable application:
  ...
  x-gresource-xml-file: resource/resource.xml
  x-gresource-source-dir: resource

Since: 0.1.0.0

gResourceUserHooks :: UserHooks -> UserHooks Source #

UserHooks for building GResource files with build-type: Custom. Use in Setup.hs to integrate into the build process.

import Distribution.Simple
import Distribution.Simple.GResource

main :: IO ()
main = defaultMainWithHooks (gResourceUserHooks simpleUserHooks)

Add cabal-gresource to setup-depends:

build-type: Custom

custom-setup
  setup-depends:
    base,
    Cabal,
    cabal-gresource

executable application:
  ...
  x-gresource-xml-file: resource/resource.xml
  x-gresource-source-dir: resource

Since: 0.1.0.0