summaryrefslogtreecommitdiffstats
path: root/subprojects/libgd/meson_readme.md
blob: c3e7f26eaed0b63c439644d05146f800c6693fda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
See README for general information. Read below for usage with Meson.

Usage
=====

libgd is intended to be used as a submodule from other projects. This requires passing default_options to the subproject
which was added in Meson 0.38.0. To see a full list of options you can run `mesonconf $your_build_dir`. If building a
non-static library `pkglibdir` must be set to a private location to install to which you will also want to pass (an absolute path)
with the `install_rpath` keyword to any executables. For introspection files you also must set `pkgdatadir`.

So given a Meson project using git you would run this to do initial setup:

```
mkdir subprojects
git submodule add https://git.gnome.org/browse/libgd subprojects/libgd
```

Then from within your `meson.build` file:

Static Library
--------------

```meson
libgd = subproject('libgd',
  default_options: [
    'with-tagged-entry=true'
  ]
)
# Pass as dependency to another target
libgd_dep = libgd.get_variable('libgd_dep')
```

```c
#include "libgd/gd.h"

int main(int argc, char **argv)
{
  gd_ensure_types(); /* As a test */
  return 0;
}
```

Introspection
-------------

```meson
pkglibdir = join_paths(get_option('libdir'), meson.project_name())
pkgdatadir = join_paths(get_option('datadir'), meson.project_name())
libgd = subproject('libgd',
  default_options: [
    'pkglibdir=' + pkglibdir,
    'pkgdatadir=' + pkgdatadir,
    'with-tagged-entry=true',
    'with-introspection=true',
    'static=false',
  ]
)
```

```python
import os
import gi
gi.require_version('GIRepository', '2.0')
from gi.repository import GIRepository
pkglibdir = '/usr/lib/foo' # This would be defined at build time
pkggirdir = os.path.join(pkglibdir, 'girepository-1.0')
GIRepository.Repository.prepend_search_path(pkggirdir)
GIRepository.Repository.prepend_library_path(pkglibdir)
gi.require_version('Gd', '1.0')
```

Vala
----

```meson
pkglibdir = join_paths(get_option('libdir'), meson.project_name())
libgd = subproject('libgd',
  default_options: [
    'pkglibdir=' + pkglibdir,
    'with-tagged-entry=true',
    'with-vapi=true'
  ]
)
# Pass as dependency to a Vala target
libgd_vapi_dep = libgd.get_variable('libgd_vapi_dep')
```

<!-- TODO: Make a Vala example -->