1project( 2 'libgit2-glib', 'c', 3 version: '0.99.0.1', 4 default_options: 'buildtype=debugoptimized', 5 license: 'LGPL2+', 6 meson_version: '>= 0.49.0', 7) 8 9libgit2_glib_version = meson.project_version() 10version_array = libgit2_glib_version.split('.') 11libgit2_glib_major_version = version_array[0].to_int() 12libgit2_glib_minor_version = version_array[1].to_int() 13libgit2_glib_micro_version = version_array[2].to_int() 14 15libgit2_glib_api_version = '1.0' 16libgit2_glib_api_name = '@0@-@1@'.format(meson.project_name(), libgit2_glib_api_version) 17 18libgit2_glib_ns = 'Ggit' 19 20libgit2_glib_buildtype = get_option('buildtype') 21 22# The interface age is reset every time we add new API; this 23# should only happen during development cycles, otherwise the 24# interface age is the same as the micro version 25if libgit2_glib_minor_version.is_odd() 26 libgit2_glib_interface_age = 0 27else 28 libgit2_glib_interface_age = libgit2_glib_micro_version 29endif 30 31soversion = 0 32# maintaining compatibility with the previous libtool versioning 33# current = minor * 100 + micro - interface 34# revision = interface 35current = libgit2_glib_minor_version * 100 + libgit2_glib_micro_version - libgit2_glib_interface_age 36revision = libgit2_glib_interface_age 37libversion = '@0@.@1@.@2@'.format(soversion, current, revision) 38darwin_versions = [current + 1, '@0@.@1@'.format(current + 1, revision)] 39 40libgit2_glib_prefix = get_option('prefix') 41libgit2_glib_libdir = join_paths(libgit2_glib_prefix, get_option('libdir')) 42libgit2_glib_datadir = join_paths(libgit2_glib_prefix, get_option('datadir')) 43 44libgit2_glib_pkgincludedir = join_paths(get_option('includedir'), libgit2_glib_api_name, meson.project_name()) 45 46gnome = import('gnome') 47pkg = import('pkgconfig') 48 49top_inc = include_directories('.') 50 51cc = meson.get_compiler('c') 52 53# Compiler and Debugging flags 54if cc.get_id() == 'msvc' 55 # Compiler options taken from msvc_recommended_pragmas.h 56 # in GLib, based on _Win32_Programming_ by Rector and Newcomer 57 common_flags = ['-FImsvc_recommended_pragmas.h'] 58else 59 common_flags = cc.get_supported_arguments([ 60 '-ffast-math', 61 '-fstrict-aliasing', 62 '-Wpointer-arith', 63 '-Wmissing-declarations', 64 '-Wformat=2', 65 '-Wstrict-prototypes', 66 '-Wmissing-prototypes', 67 '-Wnested-externs', 68 '-Wold-style-definition', 69 '-Wdeclaration-after-statement', 70 '-Wunused', 71 '-Wuninitialized', 72 '-Wshadow', 73 '-Wmissing-noreturn', 74 '-Wmissing-format-attribute', 75 '-Wredundant-decls', 76 '-Wlogical-op', 77 '-Wcast-align', 78 '-Wno-unused-local-typedefs', 79 '-Werror=implicit', 80 '-Werror=init-self', 81 '-Werror=main', 82 '-Werror=missing-braces', 83 '-Werror=return-type', 84 '-Werror=array-bounds', 85 '-Werror=write-strings', 86 ]) 87endif 88 89if libgit2_glib_buildtype.contains('debug') 90 common_flags += ['-DLIBGIT2_GLIB_ENABLE_DEBUG'] 91 92 if libgit2_glib_buildtype.contains('optimized') 93 common_flags += ['-DG_DISABLE_CAST_CHECKS'] 94 endif 95else 96 common_flags += [ 97 '-DG_DISABLE_CAST_CHECKS', 98 '-DG_DISABLE_CHECKS', 99 ] 100endif 101 102# Workaround for meson's bug 103# https://github.com/mesonbuild/meson/pull/1896 104if get_option('b_ndebug') == 'true' 105 common_flags += ['-DG_DISABLE_ASSERT'] 106endif 107 108add_project_arguments(common_flags, language: 'c') 109 110if cc.has_link_argument('-Wl,-Bsymbolic-functions') 111 add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c') 112endif 113 114 115# Termios 116have_termios = cc.has_header('termios.h') 117 118# Required dependencies 119glib_req = '2.44.0' 120 121glib_dep = dependency('glib-2.0', version: '>=' + glib_req) 122gobject_dep = dependency('gobject-2.0', version: '>=' + glib_req) 123gio_dep = dependency('gio-2.0', version: '>=' + glib_req) 124 125libgit2_dep = dependency('libgit2', version: '>= 0.25.0') 126 127enable_gir = get_option('introspection') 128if enable_gir 129 # XXX: Not nice, but probably our best option 130 enable_gir = find_program('g-ir-scanner', required: false).found() 131endif 132 133enable_vapi = get_option('vapi') 134if enable_vapi 135 assert(enable_gir, 'vapi support was requested, but introspection support is mandatory.') 136 assert(add_languages('vala', required: false), 'vapi support was requested, but vala not found.') 137 138 meson.add_install_script('meson_vapi_link.py', libgit2_glib_datadir) 139endif 140 141# Check for libgit2 ssh support 142enable_ssh = get_option('ssh') 143if enable_ssh 144 libgit2_ssh_src = ''' 145 #include <git2.h> 146 int 147 main(int argc, const char *argv[]) 148 { 149 git_libgit2_init (); 150 return ((git_libgit2_features() & GIT_FEATURE_SSH) != 0) ? 0 : 1; 151 } 152 ''' 153 154 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.') 155endif 156 157# Check for python 158enable_python = get_option('python') 159if enable_python 160 python = import('python3') 161 162 meson.add_install_script('meson_python_compile.py', libgit2_glib_libdir) 163endif 164 165subdir('libgit2-glib') 166subdir('examples') 167subdir('tests') 168 169if get_option('gtk_doc') 170 subdir('docs/reference') 171endif 172