Struggling with meson

I’ve been trying to learn how to create a GTK4 application using Vala, so far so good… But I’m facing problems when it comes to include the resource files…

This is the meson.build at the data directory:

resource_files = files('hola-mundo-gresource.xml')
resources = gnome.compile_resources(application_id, resource_files,
    	c_name: 'resources'
)

And this is the meson.build located at the src directory:

hola_mundo_sources =[
    resources,
    'Main.vala',
    'HolaMundo.vala',
    'Window.vala',
]

hola_mundo_args = [
	 '--gresources', resource_files,
]

dependencies = [
    dependency ('glib-2.0'),
    dependency ('gobject-2.0'),
    dependency ('gtk4'),
]

executable ('hola-mundo', hola_mundo_sources,
        dependencies: dependencies,
        c_args: [ '-DGETTEXT_PACKAGE="co.edu.uniquindio.HolaMundoGTK4"'],
        vala_args: hola_mundo_args,
        install: true
)

But when I try to build…

src/meson.build:1:0: ERROR: Unknown variable "resources".

It doesn’t seem to be able to find any resources variable yet I declared it in the data directory… I don’t know what am I doing wrong…

Any clue…?

1 Like

It seems there must be an order when using those meson.build files… I had subdir('src') before subdir('data') I swapped their order and I can build my project now :smiley:

project (
    'hola-mundo',
    'c', 'vala',
    version: '0.0.1'
)


application_id = 'co.edu.uniquindio.Hola-mundo'
gnome=import('gnome')

subdir('data')
subdir('src')
2 Likes

Yes that’s it: lines in meson.build files are processed in the order they appear in, so to have access to your resources generator variable you need to have it come first when using the subdir('foo')s.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.