-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
86 lines (67 loc) · 1.87 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
project('rdylib',
'rust',
'c',
version: '0.1.0',
meson_version : '>= 0.58')
if get_option('debug')
target = 'debug'
else
target = 'release'
endif
pkgconfig = import('pkgconfig')
cargo = find_program('cargo', version:'>=1.40')
rustc = find_program('rustc', version:'>=1.52')
gio_dep = dependency('gio-2.0')
output = []
system = build_machine.system()
extension = 'a'
#if system == 'windows'
# extension = 'lib'
#endif
output += ['lib' + meson.project_name() + '.' + extension]
buildtype = 'native'
if meson.is_cross_build()
buildtype = 'cross'
endif
conf = configuration_data()
conf.set_quoted('VERSION', meson.project_version())
configure_file(
input: 'config.rs.in',
output: 'config.rs',
configuration: conf
)
cargo_wrapper = find_program('build-aux/cargo_wrapper.py')
rdylib_lib = custom_target('rdylib.tmp',
build_by_default: true,
build_always_stale: true,
output: output,
console: true,
depfile: 'rdylib.dep',
command: [cargo_wrapper,
'--build-dir', meson.current_build_dir(),
'--source-dir', meson.current_source_dir(),
'--root-dir', meson.global_build_root(),
'--build-type', target,
'--depfile', '@DEPFILE@',
'--exts', extension,
'--buildtype', buildtype
])
install_headers('include/rdylib.h', subdir: 'rdylib')
rdylibinc = include_directories('include')
lib = library('rdylib',
link_whole: rdylib_lib,
install: true,
dependencies: [
gio_dep,
],
)
pkgconfig.generate(lib,
subdirs: 'rdylib'
)
rdylib_dep = declare_dependency(link_with: lib, include_directories: [rdylibinc])
meson.override_dependency('rdylib', rdylib_dep)
executable ('main', 'main.c', dependencies: [rdylib_dep], install: true)
devenv = environment()
devenv.set('CARGO_HOME', meson.project_build_root() / 'cargo-home')
devenv.set('CARGO_TARGET_DIR', meson.project_build_root() / 'target')
meson.add_devenv(devenv)