summaryrefslogtreecommitdiff
path: root/tools/meson.build
blob: f272c95559c264cb0c682882613fcde9e34ecac0 (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
libdir_abs = join_paths(get_option('prefix'), get_option('libdir'))
datadir_abs = join_paths(get_option('prefix'), get_option('datadir'))

tools = [
  ['g-ir-scanner', 'scannermain', 'scanner_main'],
  ['g-ir-annotation-tool', 'annotationmain', 'annotation_main'],
]
if with_doctool
  tools += [['g-ir-doc-tool', 'docmain', 'doc_main']]
endif

if cc.get_id() == 'msvc'
  python_cmd = '/usr/bin/env ' + python.path()
else
  python_cmd = '/usr/bin/env python@0@'.format(python.language_version().split('.')[0])
endif

tool_output = []
foreach tool : tools
  tools_conf = configuration_data()
  tools_conf.set('libdir', libdir_abs)
  tools_conf.set('datarootdir', datadir_abs)
  tools_conf.set('gir_dir_prefix', gir_dir_prefix)
  tools_conf.set('PYTHON_CMD', python_cmd)

  tools_conf.set('TOOL_MODULE', tool[1])
  tools_conf.set('TOOL_FUNCTION', tool[2])
  tool_bin = configure_file(
    input: 'g-ir-tool-template.in',
    output: tool[0],
    configuration: tools_conf,
    install_dir: get_option('bindir'),
  )
  tool_output += tool_bin
  # Provide tools for others when we're a subproject and they use the Meson GNOME module
  if not get_option('gi_cross_use_prebuilt_gi')
    meson.override_find_program(tool[0], tool_bin)
  endif
endforeach

girscanner = tool_output[0]
has_girdoctool = false
if with_doctool
  girdoctool = tool_output[-1]
  has_girdoctool = true
endif

custom_c_args = []
if cc.get_id() != 'msvc'
  custom_c_args = cc.get_supported_arguments(['-Wno-missing-field-initializers'])
endif


gircompiler = executable('g-ir-compiler', 'compiler.c',
  dependencies: [
    girepo_internals_dep,
    girepo_dep,
  ],
  install: true,
  c_args: custom_c_args,
)

girgenerate = executable('g-ir-generate', 'generate.c',
  dependencies: [
    girepo_internals_dep,
    girepo_dep,
  ],
  install: true,
  c_args: custom_c_args,
)

girinspect = executable('g-ir-inspect', 'g-ir-inspect.c',
  dependencies: girepo_dep,
  install: true,
  c_args: custom_c_args,
)

if not get_option('gi_cross_use_prebuilt_gi')
  meson.override_find_program('g-ir-compiler', gircompiler)
  meson.override_find_program('g-ir-generate', girgenerate)
  meson.override_find_program('g-ir-inspect', girinspect)
endif