meson icon indicating copy to clipboard operation
meson copied to clipboard

gnome.compile_schemas() only considers schemas in srcdir

Open fmuellner opened this issue 8 years ago • 7 comments

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.

fmuellner avatar Aug 19 '17 10:08 fmuellner

In order to do this we would have to copy all schemas to the build dir then compile.

TingPing avatar Aug 19 '17 15:08 TingPing

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.

fmuellner avatar Aug 19 '17 16:08 fmuellner

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.

TingPing avatar Aug 19 '17 16:08 TingPing

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.

TingPing avatar Aug 19 '17 17:08 TingPing

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 ...

fmuellner avatar Aug 19 '17 23:08 fmuellner

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.

mcatanzaro avatar Jul 14 '18 16:07 mcatanzaro

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,
)

chergert avatar Jul 10 '24 19:07 chergert