forked from libratbag/piper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
128 lines (112 loc) · 4.36 KB
/
meson.build
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
project('piper',
version: '0.4',
license: 'GPL-2.0-or-later',
meson_version: '>= 0.42.0')
# The tag date of the project_version(), update when the version bumps.
version_date='2020-02-09'
# The DBus API version of ratbagd that we are compatible with. Anything
# higher or lower will not be compatible so make sure you bumpt that to the
# latest released ratbagd version whenever a piper release is made.
ratbagd_api_version = 1
# Dependencies
dependency('pygobject-3.0', required: true)
ratbagd = find_program('ratbagd', required: false)
ratbagd_required_version='0.13'
if not ratbagd.found()
message('''
*********************** WARNING **********************
* _???_ Dependency libratbag not found in $PATH! *
*(_)_(_) ratbagd must be installed and running *
* (o o) for Piper to work. *
*==\o/== *
******************************************************
''')
else
r = run_command(ratbagd, '--version')
if r.returncode() != 0 or r.stdout().version_compare('<' + ratbagd_required_version)
message('''
*********************** WARNING ****************************
* ( )( *
* (\-. ) ( ) ratbagd found in $PATH is too *
* / _`> .---------. old and will not work with *
* _) / _)= |'-------'| this version of Piper. Please *
*( / _/ |O O o| update libratbag/ratbagd. *
* `-.__(___)_ | o O . o | *
************************************************************
''')
endif
endif
# Gtk version required
gtk_major_version = 3
gtk_minor_version = 22
prefix = get_option('prefix')
datadir = join_paths(prefix, get_option('datadir'))
localedir = join_paths(prefix, get_option('localedir'))
pkgdatadir = join_paths(datadir, meson.project_name())
bindir = join_paths(prefix, get_option('bindir'))
podir = join_paths(meson.source_root(), 'po')
i18n = import('i18n')
subdir('data')
subdir('po')
# Find the directory to install our Python code
if meson.version().version_compare('<0.48.0')
python = import('python3')
py3 = python.find_python()
python_dir = python.sysconfig_path('purelib')
message('Getting Python3 install dir')
if not python_dir.endswith('site-packages')
error('Python3 purelib path seems invalid')
endif
else
pymod = import('python')
# external python modules that are required for running piper
python_modules = [
'lxml',
'evdev',
'cairo',
'gi',
]
if meson.version().version_compare('>=0.51')
py3 = pymod.find_installation(modules: python_modules)
else
py3 = pymod.find_installation()
foreach module: python_modules
if run_command(py3, '-c', 'import @0@'.format(module)).returncode() != 0
error('Failed to find required python module \'@0@\'.'.format(module))
endif
endforeach
endif
python_dir = py3.get_install_dir()
endif
install_subdir('piper',
install_dir: python_dir,
exclude_directories: '__pycache__')
config_piper = configuration_data()
config_piper.set('pkgdatadir', pkgdatadir)
config_piper.set('localedir', localedir)
config_piper.set('gtk_major_version', gtk_major_version)
config_piper.set('gtk_minor_version', gtk_minor_version)
config_piper.set('RATBAGD_API_VERSION', ratbagd_api_version)
config_piper.set('devel', '')
config_piper_devel = config_piper
config_piper_devel.set('pkgdatadir', join_paths(meson.build_root(), 'data'))
config_piper_devel.set('localedir', join_paths(meson.build_root(), 'po'))
config_piper_devel.set('devel', '''
sys.path.insert(1, '@0@')
print('Running from source tree, using local files')
'''.format(meson.source_root()))
configure_file(input: 'piper.in',
output: 'piper',
configuration: config_piper,
install_dir: bindir)
configure_file(input: 'piper.in',
output: 'piper.devel',
configuration: config_piper_devel)
meson.add_install_script('meson_install.sh')
flake8 = find_program('flake8', required: false)
if flake8.found()
test('flake8', flake8,
args: ['--ignore=E501,W504',
join_paths(meson.source_root(), 'piper'),
join_paths(meson.source_root(), 'piper.in')])
endif