meson.build 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #********************************************************************+
  2. # Copyright 2016-2017 Daniel 'grindhold' Brendle
  3. #
  4. # This file is part of liboparl.
  5. #
  6. # liboparl is free software: you can redistribute it and/or
  7. # modify it under the terms of the GNU Lesser General Public License
  8. # as published by the Free Software Foundation, either
  9. # version 3 of the License, or (at your option) any later
  10. # version.
  11. #
  12. # liboparl is distributed in the hope that it will be
  13. # useful, but WITHOUT ANY WARRANTY; without even the implied
  14. # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. # PURPOSE. See the GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with liboparl.
  19. # If not, see http://www.gnu.org/licenses/.
  20. #*********************************************************************
  21. project ('oparl', 'vala', 'c', meson_version: '>=0.40.0', license: 'LGPL')
  22. compiler = meson.get_compiler('vala')
  23. if compiler.version().version_compare('<0.32.0')
  24. error('vala must be >= 0.32.0')
  25. endif
  26. # build options
  27. opt_build_valadoc = get_option('build_valadoc')
  28. opt_build_test = get_option('build_test')
  29. pkgconfig = import('pkgconfig')
  30. api = '0.4'
  31. revision = api + '.0'
  32. glib = dependency('glib-2.0')
  33. gobject = dependency('gobject-2.0')
  34. json_glib = dependency('json-glib-1.0')
  35. gio = dependency('gio-2.0')
  36. subdir('po')
  37. oparl_lib_source = [
  38. 'src/oparl.vala',
  39. 'src/body.vala',
  40. 'src/person.vala',
  41. 'src/membership.vala',
  42. 'src/meeting.vala',
  43. 'src/system.vala',
  44. 'src/object.vala',
  45. 'src/organization.vala',
  46. 'src/agenda_item.vala',
  47. 'src/paper.vala',
  48. 'src/consultation.vala',
  49. 'src/legislative_term.vala',
  50. 'src/location.vala',
  51. 'src/file.vala'
  52. ]
  53. oparl_test_source = [
  54. 'test/main.vala',
  55. 'test/fixtures.vala',
  56. 'test/object.vala',
  57. 'test/system.vala',
  58. 'test/body.vala',
  59. 'test/legislative_term.vala',
  60. 'test/location.vala',
  61. 'test/organization.vala',
  62. 'test/person.vala',
  63. 'test/membership.vala',
  64. 'test/meeting.vala',
  65. 'test/agenda_item.vala',
  66. 'test/paper.vala',
  67. 'test/consultation.vala',
  68. 'test/file.vala',
  69. 'test/test_helper.vala',
  70. ]
  71. libtype = 'so'
  72. if (host_machine.system() == 'darwin')
  73. libtype = 'dylib'
  74. endif
  75. oparl_lib = library('oparl-'+api, oparl_lib_source,
  76. dependencies: [glib, gobject, gio, json_glib],
  77. vala_args: ['--gir=../OParl-'+api+'.gir'],
  78. c_args: ['-DGETTEXT_PACKAGE="liboparl"'],
  79. install: true)
  80. g_ir_compiler = find_program('g-ir-compiler')
  81. custom_target('oparl-typelib',
  82. command: [
  83. g_ir_compiler,
  84. '--output', '@OUTPUT@', meson.current_build_dir() + '/OParl-'+api+'.gir',
  85. '--shared-library', get_option('prefix') + '/' + get_option('libdir') + '/liboparl-'+api+'.'+libtype
  86. ],
  87. output: 'OParl-'+api+'.typelib',
  88. depends: oparl_lib,
  89. install: true,
  90. install_dir: get_option('libdir') + '/girepository-1.0')
  91. if opt_build_test == true
  92. oparl_test = executable('oparl_test', oparl_test_source,
  93. dependencies: [glib,gobject, json_glib, gio],
  94. link_with: oparl_lib)
  95. test('testlib', oparl_test)
  96. endif
  97. if opt_build_valadoc == true
  98. valadoc = find_program('valadoc')
  99. custom_target('apidocs',
  100. input: oparl_lib_source,
  101. command: [valadoc, '-o', 'devhelp/oparl-'+api, '--doclet', 'devhelp', '@INPUT@',
  102. '--pkg','json-glib-1.0', '--force'],
  103. output: 'devhelp',
  104. build_by_default: true
  105. )
  106. endif
  107. oparl_dep = declare_dependency(
  108. link_with: oparl_lib,
  109. include_directories: include_directories('.')
  110. )
  111. libs = oparl_lib # the library/libraries users need to link against
  112. h = ['..','pkgconfig'] # subdirectories of ${prefix}/${includedir} to add to header path
  113. pkgconfig.generate(libraries : libs,
  114. subdirs : h,
  115. version : revision,
  116. name : 'liboparl',
  117. filebase : meson.current_build_dir()+'/oparl-' + api,
  118. requires : 'glib-2.0 gobject-2.0 gio-2.0 json-glib-1.0',
  119. description : 'A library to access OParl civic information endpoints.')
  120. run_command('touch', meson.current_build_dir()+'/oparl-'+api+'.h')
  121. install_headers(meson.current_build_dir()+'/oparl-'+api+'.h')
  122. if opt_build_valadoc == true
  123. install_subdir(meson.current_build_dir()+'/devhelp/oparl-'+api+'/oparl-'+api, install_dir: get_option('datadir')+'/devhelp/books')
  124. endif
  125. run_command('touch', meson.current_build_dir()+'/oparl-'+api+'.vapi')
  126. run_command('cp', meson.current_source_dir()+'/oparl-'+api+'.deps', meson.current_build_dir()+'/oparl-'+api+'.deps')
  127. install_data('oparl-'+api+'.deps', install_dir: get_option('datadir') + '/vala/vapi')
  128. install_data(meson.current_build_dir()+'/oparl-'+api+'.vapi', install_dir: get_option('datadir') + '/vala/vapi')