diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-06-16 08:46:52 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-10-08 10:42:41 -0700 |
| commit | 2e63336bf3e58eb3364bd8f7eedddbbc40ee6f69 (patch) | |
| tree | 36263b00ad974ffb9f4cd497afe5aa6e3625a3bb /docs/markdown | |
| parent | 6c05dabc47389f471c435394c13981d92f288d9b (diff) | |
| download | meson-2e63336bf3e58eb3364bd8f7eedddbbc40ee6f69.tar.gz | |
vala: Add method to get generated GIR from a build_target
Fixes: #2296
Fixes: #4481
Fixes: #5968
Diffstat (limited to 'docs/markdown')
| -rw-r--r-- | docs/markdown/Vala.md | 25 | ||||
| -rw-r--r-- | docs/markdown/snippets/vala-target-extra-methods.md | 9 |
2 files changed, 33 insertions, 1 deletions
diff --git a/docs/markdown/Vala.md b/docs/markdown/Vala.md index af9426352..ff7a7c736 100644 --- a/docs/markdown/Vala.md +++ b/docs/markdown/Vala.md @@ -318,6 +318,7 @@ foo_h = foo_lib.vala_header() This header can now be used like any other generated header to create an order-only dependency. + ### Depending on VAPI header *(since 1.10.0)* @@ -329,6 +330,15 @@ foo_lib = shared_library(...) foo_vapi = foo_lib.vala_vapi() ``` +### Depending on generated GIR + +*(since 1.10.0)* + +```meson +foo_lib = shared_library(..., vala_gir : 'foo.gir') +foo_gir = foo_lib.vala_gir() +``` + ### GObject Introspection and language bindings A 'binding' allows another programming language to use a library @@ -363,6 +373,21 @@ directory (i.e. `share/gir-1.0` for GIRs). The fourth element in the To then generate a typelib file use a custom target with the `g-ir-compiler` program and a dependency on the library: +*Since Meson 1.10*, use the `.vala_gir()` method to get a handle to the generated `.gir` file: + +```meson +g_ir_compiler = find_program('g-ir-compiler') +custom_target('foo typelib', command: [g_ir_compiler, '--output', '@OUTPUT@', '@INPUT@'], + input: foo_lib.vala_gir(), + output: 'Foo-1.0.typelib', + install: true, + install_dir: get_option('libdir') / 'girepository-1.0') +``` + + +*Before Meson 1.10*, calculating the path to the input is required, as is adding a +manual dependency to the vala target: + ```meson g_ir_compiler = find_program('g-ir-compiler') custom_target('foo typelib', command: [g_ir_compiler, '--output', '@OUTPUT@', '@INPUT@'], diff --git a/docs/markdown/snippets/vala-target-extra-methods.md b/docs/markdown/snippets/vala-target-extra-methods.md index 72d89e56e..526f557a2 100644 --- a/docs/markdown/snippets/vala-target-extra-methods.md +++ b/docs/markdown/snippets/vala-target-extra-methods.md @@ -1,7 +1,7 @@ ## Vala BuildTarget dependency enhancements A BuildTarget that has Vala sources can now get a File dependency for its -generated header and generated vapi. +generated header, vapi, and gir files. ```meson lib = library('foo', 'foo.vala') @@ -9,6 +9,13 @@ lib_h = lib.vala_header() lib_s = static_lib('static', 'static.c', lib_h) lib_vapi = lib.vala_vapi() + +custom_target( + 'foo-typelib', + command : ['g-ir-compiler', '--output', '@OUTPUT@', '@INPUT@'], + input : lib.vala_gir(), + output : 'Foo-1.0.typelib' +) ``` `static.c` will not start compilation until `lib.h` is generated. |
