Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using generate_gir from gobject-introspection #11327

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ylatuya
Copy link

@ylatuya ylatuya commented Jan 23, 2023

From gobject-introspection itself the use of gnome.generate_gir is not possible leading to several hacks that are hard to maintain in order to support building gobject-introspection with submodules.
This change in combination with https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/380 uses a new gobject-introspection-no-typelibs-1.0 dependency to allow using the GI dependency prior to having the typelibs generated.

self.giscanner = state.find_tool('g-ir-scanner', 'gobject-introspection-1.0', 'g_ir_scanner')
self.gicompiler = state.find_tool('g-ir-compiler', 'gobject-introspection-1.0', 'g_ir_compiler')
if not self.gir_dep or not self.gir_dep.found():
for (dep, req) in [('gobject-introspection-no-typelibs-1.0', False), ('gobject-introspection-1.0', True)]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a bit more complicated because after g-i is done we want to switch to gobject-introspection-1.0. That way subprojects coming after g-i will have typelibs dependencies.

That means you should invert the order and check for gobject-introspection-1.0 first. If it is -no-typelib that has been found you should remember that and re-check for gobject-introspection-1.0 next time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibility is to do something like dep_name = 'gobject-introspection-no-typelibs-1.0' if state.subproject == 'gobject-introspection' else 'gobject-introspection-1.0' ... self.gir_dep = state.dependency(dep_name)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ylatuya I think the new version of your patch still have the same issue because it re-check the dependency only if not self.gir_dep:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I pushed it before reading your comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be handled correctly now

@ylatuya ylatuya force-pushed the fix-gi branch 3 times, most recently from 464ad70 to 1fd86e8 Compare January 24, 2023 17:11
From gobject-introspection itself the use of gnome.generate_gir is
not possible leading to several hacks that are hard to maintain in
order to support building gobject-introspection with submodules.

This change in combination with https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/380
uses a new `gobject-introspection-no-typelibs` dependency to allow
defining dependency to allow using the GI dependency prior to having
the typelibs generated.
Source for the gir_dep should be added to the GirTarget inputs
instead of the dependencies.

Traceback (most recent call last):
  File "/Users/andoni/git/meson/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
  File "/Users/andoni/git/meson/mesonbuild/msetup.py", line 309, in run
    app.generate()
  File "/Users/andoni/git/meson/mesonbuild/msetup.py", line 186, in generate
    self._generate(env)
  File "/Users/andoni/git/meson/mesonbuild/msetup.py", line 250, in _generate
    intr.backend.generate()
  File "/Users/andoni/git/meson/mesonbuild/backend/ninjabackend.py", line 614, in generate
    self.generate_target(t)
  File "/Users/andoni/git/meson/mesonbuild/backend/ninjabackend.py", line 801, in generate_target
    self.generate_custom_target(target)
  File "/Users/andoni/git/meson/mesonbuild/backend/ninjabackend.py", line 1104, in generate_custom_target
    for output in d.get_outputs():
AttributeError: 'File' object has no attribute 'get_outputs'
This allows adding a link_with to the gir_rep depedency that is
defined for internall use in gobject-introspection so it depends
on the giscanner python module target

```
  girepo_no_typelibs_dep = declare_dependency(
    dependencies: [girepo_dep],
    link_with: gir_giscanner_pymod,
    sources: gir_giscanner_built_files,
    variables: {
      'girdir': meson.current_build_dir() / 'gir',
    },
  )
```
@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #11327 (21b2ec3) into master (8d39c92) will decrease coverage by 3.60%.
The diff coverage is 7.69%.

@@            Coverage Diff             @@
##           master   #11327      +/-   ##
==========================================
- Coverage   68.85%   65.25%   -3.60%     
==========================================
  Files         414      207     -207     
  Lines       90284    45150   -45134     
  Branches    20709    10713    -9996     
==========================================
- Hits        62163    29462   -32701     
+ Misses      23434    13425   -10009     
+ Partials     4687     2263    -2424     
Impacted Files Coverage Δ
mesonbuild/modules/gnome.py 26.21% <7.69%> (-52.54%) ⬇️
mesonbuild/modules/qt6.py 0.00% <0.00%> (-100.00%) ⬇️
mesonbuild/scripts/clangtidy.py 0.00% <0.00%> (-93.34%) ⬇️
mesonbuild/scripts/hotdochelper.py 0.00% <0.00%> (-81.49%) ⬇️
mesonbuild/modules/wayland.py 0.00% <0.00%> (-79.69%) ⬇️
mesonbuild/scripts/itstool.py 0.00% <0.00%> (-66.67%) ⬇️
mesonbuild/modules/hotdoc.py 0.00% <0.00%> (-65.36%) ⬇️
mesonbuild/templates/dlangtemplates.py 37.93% <0.00%> (-62.07%) ⬇️
mesonbuild/scripts/coverage.py 0.00% <0.00%> (-42.58%) ⬇️
... and 259 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@xclaesse
Copy link
Member

xclaesse commented Feb 7, 2023

@ylatuya IIRC you said elsewhere that this does not work because we would need generate_gir() to also work with a lib coming from pkgconfig instead of from library(), right? Is that something we could fix easily, or are you abandoning this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants