-
Notifications
You must be signed in to change notification settings - Fork 13
/
meson.build
78 lines (67 loc) · 2.62 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
project('ide-flatpak-wrapper')
bash = find_program('bash')
pymod = import('python')
python = pymod.find_installation('python3')
fs = import('fs')
editor = find_program(get_option('editor_binary'), required: false)
if editor.found()
editor_path = editor.path()
else
editor_path = get_option('editor_binary')
if editor_path == ''
error('Editor binary path is empty')
endif
endif
message('Using @0@ as editor binary'.format(editor_path))
if get_option('flatpak_id') == ''
flatpak_id = run_command('sh', '-c', 'echo $FLATPAK_ID', check: true).stdout().strip()
else
flatpak_id = get_option('flatpak_id')
endif
datadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
if get_option('sdk_version') == ''
sdk_version_cmd = run_command('sh', '-c', '. /etc/os-release && echo $VERSION_ID', check: true)
sdk_version_arr = sdk_version_cmd.stdout().strip().split('.')
sdk_version = '.'.join([sdk_version_arr[0], sdk_version_arr[1]])
else
sdk_version = get_option('sdk_version')
endif
editor_args = []
foreach arg : get_option('editor_args')
editor_args += '"@0@"'.format(arg)
endforeach
first_run_template = files(get_option('first_run_template'))
sdk_update_template = files(get_option('sdk_update_template'))
first_run_filename = fs.name(get_option('first_run_template'))
sdk_update_filename = fs.name(get_option('sdk_update_template'))
wrapper_data = configuration_data({
'BASH': bash.path(),
'EDITOR_BINARY': editor_path,
'EDITOR_ARGS': ' '.join(editor_args),
'EDITOR_TITLE': get_option('editor_title'),
'FIRST_RUN_README': join_paths(datadir, first_run_filename),
'SDK_UPDATE_README': join_paths(datadir, sdk_update_filename),
'FLAGFILE_PREFIX': get_option('flagfile_prefix'),
'SDK_VERSION': sdk_version,
'PROGRAM_NAME': get_option('program_name'),
'PYTHON_VERSION': python.language_version(),
'DEFAULT_LOGLEVEL': get_option('default_loglevel'),
})
readme_data = configuration_data({
'FLATPAK_ID': flatpak_id,
'EDITOR_TITLE': get_option('editor_title'),
'SDK_VERSION': sdk_version
})
configure_file(input: 'vscode.sh',
output: get_option('program_name'),
configuration: wrapper_data,
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x')
configure_file(input: first_run_template,
output: first_run_filename,
configuration: readme_data,
install_dir: datadir)
configure_file(input: sdk_update_template,
output: sdk_update_filename,
configuration: readme_data,
install_dir: datadir)