File: meson.build

package info (click to toggle)
libgit2-glib 0.99.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,692 kB
  • sloc: ansic: 17,155; python: 1,989; makefile: 21; sh: 7
file content (171 lines) | stat: -rw-r--r-- 4,980 bytes parent folder | download | duplicates (2)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
project(
  'libgit2-glib', 'c',
  version: '0.99.0.1',
  default_options: 'buildtype=debugoptimized',
  license: 'LGPL2+',
  meson_version: '>= 0.49.0',
)

libgit2_glib_version = meson.project_version()
version_array = libgit2_glib_version.split('.')
libgit2_glib_major_version = version_array[0].to_int()
libgit2_glib_minor_version = version_array[1].to_int()
libgit2_glib_micro_version = version_array[2].to_int()

libgit2_glib_api_version = '1.0'
libgit2_glib_api_name = '@0@-@1@'.format(meson.project_name(), libgit2_glib_api_version)

libgit2_glib_ns = 'Ggit'

libgit2_glib_buildtype = get_option('buildtype')

# The interface age is reset every time we add new API; this
# should only happen during development cycles, otherwise the
# interface age is the same as the micro version
if libgit2_glib_minor_version.is_odd()
  libgit2_glib_interface_age = 0
else
  libgit2_glib_interface_age = libgit2_glib_micro_version
endif

soversion = 0
# maintaining compatibility with the previous libtool versioning
# current = minor * 100 + micro - interface
# revision = interface
current = libgit2_glib_minor_version * 100 + libgit2_glib_micro_version - libgit2_glib_interface_age
revision = libgit2_glib_interface_age
libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
darwin_versions = [current + 1, '@0@.@1@'.format(current + 1, revision)]

libgit2_glib_prefix = get_option('prefix')
libgit2_glib_libdir = join_paths(libgit2_glib_prefix, get_option('libdir'))
libgit2_glib_datadir = join_paths(libgit2_glib_prefix, get_option('datadir'))

libgit2_glib_pkgincludedir = join_paths(get_option('includedir'), libgit2_glib_api_name, meson.project_name())

gnome = import('gnome')
pkg = import('pkgconfig')

top_inc = include_directories('.')

cc = meson.get_compiler('c')

# Compiler and Debugging flags
if cc.get_id() == 'msvc'
  # Compiler options taken from msvc_recommended_pragmas.h
  # in GLib, based on _Win32_Programming_ by Rector and Newcomer
  common_flags = ['-FImsvc_recommended_pragmas.h']
else
  common_flags = cc.get_supported_arguments([
    '-ffast-math',
    '-fstrict-aliasing',
    '-Wpointer-arith',
    '-Wmissing-declarations',
    '-Wformat=2',
    '-Wstrict-prototypes',
    '-Wmissing-prototypes',
    '-Wnested-externs',
    '-Wold-style-definition',
    '-Wdeclaration-after-statement',
    '-Wunused',
    '-Wuninitialized',
    '-Wshadow',
    '-Wmissing-noreturn',
    '-Wmissing-format-attribute',
    '-Wredundant-decls',
    '-Wlogical-op',
    '-Wcast-align',
    '-Wno-unused-local-typedefs',
    '-Werror=implicit',
    '-Werror=init-self',
    '-Werror=main',
    '-Werror=missing-braces',
    '-Werror=return-type',
    '-Werror=array-bounds',
    '-Werror=write-strings',
  ])
endif

if libgit2_glib_buildtype.contains('debug')
  common_flags += ['-DLIBGIT2_GLIB_ENABLE_DEBUG']

  if libgit2_glib_buildtype.contains('optimized')
    common_flags += ['-DG_DISABLE_CAST_CHECKS']
  endif
else
  common_flags += [
    '-DG_DISABLE_CAST_CHECKS',
    '-DG_DISABLE_CHECKS',
  ]
endif

# Workaround for meson's bug
# https://github.com/mesonbuild/meson/pull/1896
if get_option('b_ndebug') == 'true'
  common_flags += ['-DG_DISABLE_ASSERT']
endif

add_project_arguments(common_flags, language: 'c')

if cc.has_link_argument('-Wl,-Bsymbolic-functions')
  add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif


# Termios
have_termios = cc.has_header('termios.h')

# Required dependencies
glib_req = '2.44.0'

glib_dep = dependency('glib-2.0', version: '>=' + glib_req)
gobject_dep = dependency('gobject-2.0', version: '>=' + glib_req)
gio_dep = dependency('gio-2.0', version: '>=' + glib_req)

libgit2_dep = dependency('libgit2', version: '>= 0.25.0')

enable_gir = get_option('introspection')
if enable_gir
  # XXX: Not nice, but probably our best option
  enable_gir = find_program('g-ir-scanner', required: false).found()
endif

enable_vapi = get_option('vapi')
if enable_vapi
  assert(enable_gir, 'vapi support was requested, but introspection support is mandatory.')
  assert(add_languages('vala', required: false), 'vapi support was requested, but vala not found.')

  meson.add_install_script('meson_vapi_link.py', libgit2_glib_datadir)
endif

# Check for libgit2 ssh support
enable_ssh = get_option('ssh')
if enable_ssh
  libgit2_ssh_src = '''
    #include <git2.h>
    int
    main(int argc, const char *argv[])
    {
            git_libgit2_init ();
            return ((git_libgit2_features() & GIT_FEATURE_SSH) != 0) ? 0 : 1;
    }
  '''

  assert(cc.compiles(libgit2_ssh_src, name: 'libgit2 supports SSH'), 'libgit2 ssh support was requested, but not found. Use -Dssh=false to build without it.')
endif

# Check for python
enable_python = get_option('python')
if enable_python
  python = import('python3')

  meson.add_install_script('meson_python_compile.py', libgit2_glib_libdir)
endif

subdir('libgit2-glib')
subdir('examples')
subdir('tests')

if get_option('gtk_doc')
  subdir('docs/reference')
endif