meson
meson copied to clipboard
gnome.compile_schemas() only considers schemas in srcdir
GSettings schemas are commonly created from a template file to substitute the gettext-domain at build time. If such a schema needs to be compiled for unit tests, it is currently necessary to use a custom target, as the gnome.compile_schemas() convenience method doesn't find the generated schema in the build directory.
In order to do this we would have to copy all schemas to the build dir then compile.
That is one option. Another would be to expose the directory argument passed to glib-compile-schemas, or to add an option to use the the build dir instead of the source dir. It's probably even possible to detect whether any targets look like a schema, and pick the build dir automatically in that case.
Also off topic but:
to substitute the gettext-domain at build time
Is that really needed? Most projects never change their domain name in the entire lifetime of the project.
It's probably even possible to detect whether any targets look like a schema
I'm not sure that is a good design, like what if a schema is added to a directory after configure time. Maybe we could just support passing a list of sources to the function where no sources is current behavior and with sources it properly marks them as dependencies and uses the build directory copying any non-built sources if needed.
Also off topic but:
to substitute the gettext-domain at build time Is that really needed? Most projects never change their domain name in the entire lifetime of the project.
No, it's not really needed. It's just a common pattern in gnome applications, so I decided to put it up for discussion before starting to change it in my own projects ...
No, it's not really needed. It's just a common pattern in gnome applications, so I decided to put it up for discussion before starting to change it in my own projects ...
FWIW I consider this bad practice since it requires generating the final gschema file via a configure replacement, which would otherwise be unnecessary.
Randomly came across this and figured I'd leave a note because why not. Builder has for ages had at least one build-time configurable value in schemas which requires us to copy into the build directory.
In general though, we just run a custom_target which makes things easier.
gschemas_compiled = custom_target('gschemas.compiled',
output: 'gschemas.compiled',
command: ['glib-compile-schemas', meson.current_build_dir()],
depend_files: schema_files,
build_by_default: true,
install: false,
)