-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
133 lines (113 loc) · 2.55 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
129
130
131
132
133
#
# Global Project Setup
#
project(
'meson-cargo',
'c',
license: 'Apache',
meson_version: '>=1.0.0',
version: '1.0.0',
)
project_description = 'Meson Integration of Cargo based Rust Code'
#
# Dependency Resolution
#
bin_cargo = find_program(
'cargo',
native: true,
required: true,
version: '>=1.64',
)
bin_cp = find_program(
'cp',
native: true,
required: true,
)
bin_jq = find_program(
'jq',
native: true,
required: true,
version: '>=1.6',
)
bin_build = find_program(
'./src/build.sh',
native: true,
required: true,
)
bin_dist = find_program(
'./src/dist.sh',
native: true,
required: true,
)
bin_vendor = find_program(
'./src/vendor.sh',
native: true,
required: true,
)
#
# Config: profile
#
use_profile = get_option('profile')
if use_profile == ''
use_buildtype = get_option('buildtype')
if use_buildtype == 'debug'
use_profile = 'dev'
elif use_buildtype == 'debugoptimized' or use_buildtype == 'release'
use_profile = 'release'
endif
endif
#
# Config: target
#
use_target = get_option('target')
#
# Config: vendor
#
use_vendor = get_option('vendor')
if use_vendor == 'auto'
use_wrap_mode = get_option('wrap_mode')
use_vendor = use_wrap_mode == 'nodownload' ? 'yes' : 'no'
endif
#
# Config: vendordir
#
use_vendordir = get_option('vendordir')
#
# Build Target
#
build_cmd = [bin_build, '@OUTDIR@', '@INPUT0@']
build_env = {
'MCARGO_BIN_CARGO': bin_cargo.full_path(),
'MCARGO_BIN_CP': bin_cp.full_path(),
'MCARGO_BIN_JQ': bin_jq.full_path(),
'MCARGO_CRATE_TYPE': 'staticlib',
'MCARGO_OFFLINE': use_vendor,
'MCARGO_TARGET_DIR': meson.project_build_root() / 'cargo-target',
'MCARGO_VENDOR_DIR': meson.global_source_root() / use_vendordir,
} + (use_profile == '' ? {} : {
'MCARGO_PROFILE': use_profile,
}) + (use_target == '' ? {} : {
'MCARGO_TARGET': use_target,
})
build_dict = {
'build_always_stale': true,
'command': build_cmd,
'console': true,
'env': build_env,
}
#
# Vendoring Target
#
vendor_cmd = [bin_vendor]
vendor_env = {
'MCARGO_BIN_CARGO': bin_cargo.full_path(),
'MCARGO_VENDOR_DIR': meson.global_source_root() / use_vendordir,
}
vendor_dict = {
'command': vendor_cmd,
'env': vendor_env,
}
#
# Dist Target
#
dist_cmd = [bin_dist, bin_cargo.full_path(), use_vendordir]