summaryrefslogtreecommitdiff
path: root/tests/meson.build
blob: 9ddf5ef1382fdfd7f414906b7cfabaeeb7867f48 (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
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
test_regress_sources = files('scanner/regress.c')
test_regress_headers = files('scanner/regress.h')
test_marshalling_sources = files('gimarshallingtests.c')
test_marshalling_headers = files('gimarshallingtests.h')

test_regress_incdirs = include_directories(['.', 'scanner'])

installed_sources = [
  'scanner/annotation.c',
  'scanner/annotation.h',
  'scanner/drawable.c',
  'scanner/drawable.h',
  'scanner/foo.c',
  'scanner/foo.h',
  'scanner/regress.c',
  'scanner/regress.h',
  'scanner/utility.c',
  'scanner/utility.h',
  'scanner/warnlib.c',
  'scanner/warnlib.h',
  'gimarshallingtests.c',
  'gimarshallingtests.h',
  'gitestmacros.h',
]

install_data(installed_sources, install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0', 'tests'))

# Generate everything.h and everything.c:
test_everything_files = custom_target('everything',
  output: ['everything.h', 'everything.c'],
  depends: typelibs,
  command: [
    python,
    girscanner,
    '--generate-typelib-tests=Everything,@OUTPUT0@,@OUTPUT1@',
    '--function-decoration=_GI_TEST_EXTERN',
    '--include-first-in-src=config.h',
    '--include-last-in-header=gitestmacros.h',
  ]
)

test_everything_headers = [test_everything_files[0]]
test_everything_sources = [test_everything_files[1]]

everything_lib = shared_library('everything-1.0',
  sources: test_everything_sources,
  include_directories : configinc,
  c_args: gi_hidden_visibility_cflags,
  dependencies: [glib_dep, gobject_dep],
  version: '1.0.0',
)

gimarshallingtests_lib = shared_library('gimarshallingtests-1.0',
  sources: test_marshalling_sources,
  include_directories : configinc,
  c_args: gi_hidden_visibility_cflags,
  dependencies: [glib_dep, gobject_dep],
  version: '1.0.0',
)

test_gir_files = []
test_typelibs = []

# FIXME: When using glib as a subproject g-ir-scanner will not discover build
# flag of dependencies through pkg-config, instead they have to be specified
# manually like for example in gir/meson.build. This remain to be done here as
# well. Though, this could work differently altogether. Instead one could
# generate appropriate pkg-config files and point PKG_CONFIG_PATH to them,
# leaving all invocations of g-ir-scanner as is.
if glib_dep.type_name() == 'pkgconfig'
  test_gir_files += custom_target('gir-everything',
    input: test_everything_sources + test_everything_headers,
    output: 'Everything-1.0.gir',
    depends: [everything_lib] + typelibs,
    command: [
      python,
      girscanner,
      '--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=Everything',
      '--nsversion=1.0',
      '--include=Gio-2.0',
      '--library=everything-1.0',
      '-L', meson.current_build_dir(),
      '-I', meson.current_source_dir(),
      '@INPUT@',
    ]
  )

  test_gir_files += custom_target('gir-gimarshallingtests',
    input: test_marshalling_sources + test_marshalling_headers,
    output: 'GIMarshallingTests-1.0.gir',
    depends: [gimarshallingtests_lib] + typelibs,
    command: [
      python,
      girscanner,
      '--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=GIMarshallingTests',
      '--symbol-prefix=gi_marshalling_tests',
      '--nsversion=1.0',
      '--include=Gio-2.0',
      '--library=gimarshallingtests-1.0',
      '-L' + meson.current_build_dir(),
      '--c-include="tests/gimarshallingtests.h"',
      '@INPUT@',
    ]
  )

  foreach gir : test_gir_files
    test_typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(),
      input: gir,
      output: '@BASENAME@.typelib',
      depends: [gobject_gir, ],
      command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
                '--includedir', join_paths(meson.build_root(), 'gir'),
                '--includedir', meson.current_build_dir()
      ],
    )
  endforeach

  # FIXME: Remove? Those tests doesn't actually do anything for typelibs ...
  foreach typelib : test_typelibs
    gi_tester = files('gi-tester')
    typelib_name = typelib.full_path().split('/')[-1]
    test(
      'gi-tester' + typelib_name,
      python,
      args: [gi_tester, typelib]
    )
  endforeach

endif

### TODO: actually test
subdir('offsets')
subdir('warn')
subdir('repository')
subdir('scanner')