summaryrefslogtreecommitdiff
path: root/tests/offsets/meson.build
blob: 71f4c8a485c37fb36831763b1094cab9cbb09cce (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
test_offsets_sources = files('offsets.c')
test_offsets_headers = files('offsets.h')

test_offsets_inc = include_directories('.', '..')

test_offsets_lib = shared_library('offsets-1.0',
  sources: test_offsets_sources,
  include_directories : [configinc, test_offsets_inc],
  c_args: gi_hidden_visibility_cflags,
  dependencies: [glib_dep, gobject_dep],
  version: '1.0.0',
)

if glib_dep.type_name() == 'pkgconfig'

  test_offsets_gir = custom_target('gir-offsets',
    input: test_offsets_sources + test_offsets_headers,
    output: 'Offsets-1.0.gir',
    depends: [test_offsets_lib] + typelibs,
    command: [
      python,
      girscanner,
      '--quiet',
      '--output=@OUTPUT@',
      '--no-libtool',
      '--reparse-validate',
      '--add-include-path', join_paths(meson.source_root(), 'gir'),
      '--add-include-path', join_paths(meson.build_root(), 'gir'),
      '--warn-all',
      '--warn-error',
      '--namespace=Offsets',
      '--nsversion=1.0',
      '--include=GObject-2.0',
      '--library=offsets-1.0',
      '-L', meson.current_build_dir(),
      '-I', meson.current_source_dir(),
      '-I', join_paths(meson.source_root(), 'tests'),
      extra_giscanner_args,
      '@INPUT@',
    ]
  )

  test_offsets_typelib = custom_target(
    'generate-typelib-offsets',
    input: test_offsets_gir,
    output: '@BASENAME@.typelib',
    depends: [gobject_gir, ],
    command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
              '--includedir', join_paths(meson.build_root(), 'gir'),
              '--includedir', meson.current_build_dir()
    ],
  )

  gitestoffsets_exe = executable('gitestoffsets',
    'gitestoffsets.c', 
    include_directories : test_offsets_inc,
    dependencies: [girepo_dep],
  )

  test_offsets_env = environment()
  test_offsets_env.set('top_builddir', join_paths(meson.build_root(), 'gir'))
  test_offsets_env.set('builddir', meson.current_build_dir())
  if host_system == 'windows'
    test_offsets_env.prepend('PATH', join_paths(meson.build_root(), 'girepository'))
  endif

  test('test_offsets.py',
    python, 
    args: files('test_offsets.py'),
    env: test_offsets_env,
    depends: [gitestoffsets_exe, test_offsets_typelib],
  )

endif