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
|
giscanner_files = [
'__init__.py',
'annotationmain.py',
'annotationparser.py',
'ast.py',
'cachestore.py',
'ccompiler.py',
'codegen.py',
'docmain.py',
'docwriter.py',
'dumper.py',
'introspectablepass.py',
'girparser.py',
'girwriter.py',
'gdumpparser.py',
'libtoolimporter.py',
'maintransformer.py',
'mdextensions.py',
'message.py',
'msvccompiler.py',
'pkgconfig.py',
'shlibs.py',
'scannermain.py',
'sectionparser.py',
'sourcescanner.py',
'testcodegen.py',
'transformer.py',
'utils.py',
'xmlwriter.py',
]
pkglibdir = join_paths(get_option('libdir'), meson.project_name())
giscannerdir = join_paths(pkglibdir, 'giscanner')
giscanner_built_files = []
giscanner_conf_data = configuration_data()
giscanner_conf_data.set('VERSION', meson.project_version())
giscanner_built_files += configure_file(input: '_version.py.in',
output: '_version.py',
install_dir : giscannerdir,
configuration: giscanner_conf_data)
foreach f : giscanner_files
giscanner_built_files += configure_file(input : f, output : f,
install_dir : giscannerdir,
configuration : giscanner_conf_data)
endforeach
install_subdir('doctemplates', install_dir: giscannerdir)
# XXX: this doesn't track the input, but there is nothing to copy many files
# in meson.
doc_templates = custom_target('copy-templates',
input : 'doctemplates',
output : 'doctemplates',
command : [
python, '-c',
'import sys, shutil;' +
'shutil.rmtree(sys.argv[2], ignore_errors=True);' +
'shutil.copytree(sys.argv[1], sys.argv[2])',
'@INPUT@', '@OUTPUT@'])
flex = find_program('flex', 'win_flex')
bison = find_program('bison', 'win_bison')
scannerparser = custom_target('scannerparser',
input: 'scannerparser.y',
output: ['scannerparser.c', 'scannerparser.h'],
command: [bison, '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
)
scannerlexer = custom_target('scannerlexer',
input: 'scannerlexer.l',
output: 'scannerlexer.c',
command: [flex, '-o', '@OUTPUT@', '@INPUT@']
)
giscanner_args = []
if not cc.has_header('unistd.h')
giscanner_args += '-DYY_NO_UNISTD_H'
endif
custom_c_args = []
if cc.get_id() != 'msvc'
custom_c_args = cc.get_supported_arguments([
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
])
endif
giscanner_lib = static_library('giscanner',
sources: [
'sourcescanner.c',
scannerparser,
scannerlexer,
],
c_args: giscanner_args + custom_c_args,
include_directories : configinc,
dependencies: [glib_dep, gobject_dep, gio_dep, gmodule_dep],
)
# https://github.com/mesonbuild/meson/issues/4117
if host_machine.system() == 'windows'
python_ext_dep = python.dependency()
else
python_ext_dep = python.dependency().partial_dependency(compile_args: true)
endif
if not python_ext_dep.found()
# For example if Python is 32bit but we require a 64bit variant
error('Python installation not useable')
endif
giscanner_pymod = python.extension_module('_giscanner', ['giscannermodule.c'],
link_with: giscanner_lib,
c_args: gi_hidden_visibility_cflags + custom_c_args,
include_directories : configinc,
dependencies: [glib_dep, gobject_dep, gio_dep, gmodule_dep,
python_ext_dep],
install: true,
install_dir: giscannerdir,
)
|