@@ -108,29 +108,31 @@ function toolchain_file(bt::CMake, p::AbstractPlatform; is_host::Bool=false)
108
108
end
109
109
end
110
110
111
- meson_c_args (p:: AbstractPlatform ) = [" '-I/workspace/destdir/include'" ]
112
- meson_cxx_args (p:: AbstractPlatform ) = meson_c_args (p)
113
- meson_objc_args (p:: AbstractPlatform ) = push! (meson_c_args (p), " '-x'" , " 'objective-c'" )
114
- meson_fortran_args (p:: AbstractPlatform ) = meson_c_args (p)
115
-
116
- function meson_c_link_args (p:: AbstractPlatform )
117
- libdir = " /workspace/destdir/" * (Sys. iswindows (p) ? " bin" : " lib" )
111
+ meson_c_args (p:: AbstractPlatform , envs:: Dict{String,String} ; is_host:: Bool = false ) =
112
+ [" '-I$(envs[is_host ? " host_includedir" : " includedir" ]) '" ]
113
+ meson_cxx_args (p:: AbstractPlatform , envs:: Dict{String,String} ; is_host:: Bool = false ) = meson_c_args (p, envs; is_host)
114
+ meson_objc_args (p:: AbstractPlatform , envs:: Dict{String,String} ; is_host:: Bool = false ) = push! (meson_c_args (p, envs; is_host), " '-x'" , " 'objective-c'" )
115
+ meson_fortran_args (p:: AbstractPlatform , envs:: Dict{String,String} ; is_host:: Bool = false ) = meson_c_args (p, envs; is_host)
116
+
117
+ function meson_c_link_args (p:: AbstractPlatform , envs:: Dict{String,String} ; is_host:: Bool = false )
118
+ prefix, libdir = envs[is_host ? " host_prefix" : " prefix" ], envs[is_host ? " host_libdir" : " libdir" ]
118
119
if arch (p) == " powerpc64le" && Sys. islinux (p)
119
- return [" '-L$(libdir) '" , " '-Wl,-rpath-link,/workspace/destdir /lib64'" ]
120
+ return [" '-L$(libdir) '" , " '-Wl,-rpath-link,$(prefix) /lib64'" ]
120
121
else
121
122
return [" '-L$(libdir) '" ]
122
123
end
123
124
end
124
- meson_cxx_link_args (p:: AbstractPlatform ) = meson_c_link_args (p)
125
- meson_objc_link_args (p:: AbstractPlatform ) = meson_c_link_args (p)
126
- meson_fortran_link_args (p:: AbstractPlatform ) = meson_c_link_args (p)
125
+ meson_cxx_link_args (p:: AbstractPlatform , envs :: Dict{String,String} ; is_host :: Bool = false ) = meson_c_link_args (p, envs; is_host )
126
+ meson_objc_link_args (p:: AbstractPlatform , envs :: Dict{String,String} ; is_host :: Bool = false ) = meson_c_link_args (p, envs; is_host )
127
+ meson_fortran_link_args (p:: AbstractPlatform , envs :: Dict{String,String} ; is_host :: Bool = false ) = meson_c_link_args (p, envs; is_host )
127
128
128
129
# We can run native programs only if the platform matches the default host
129
130
# platform, but when this is `x86_64-linux-musl` we can run executables for
130
131
# * i686-linux-gnu
131
132
# * x86_64-linux-gnu
132
133
# * x86_64-linux-musl
133
- function meson_is_foreign (p:: AbstractPlatform )
134
+ function meson_is_foreign (p:: AbstractPlatform ; is_host:: Bool = false )
135
+ is_host && return " false"
134
136
if platforms_match (p, default_host_platform) ||
135
137
(platforms_match (default_host_platform, Platform (" x86_64" , " linux" ; libc= " musl" ))
136
138
&& Sys. islinux (p) && proc_family (p) == " intel" &&
@@ -165,7 +167,8 @@ function meson_cpu_family(p::AbstractPlatform)
165
167
end
166
168
end
167
169
168
- function toolchain_file (bt:: Meson , p:: AbstractPlatform )
170
+ function toolchain_file (bt:: Meson , p:: AbstractPlatform , envs:: Dict{String,String} ;
171
+ is_host:: Bool = false )
169
172
target = triplet (p)
170
173
aatarget = aatriplet (p)
171
174
@@ -181,16 +184,21 @@ function toolchain_file(bt::Meson, p::AbstractPlatform)
181
184
strip = '/opt/bin/$(target) /$(aatarget) -strip'
182
185
pkgconfig = '/usr/bin/pkg-config'
183
186
187
+ [built-in options]
188
+ c_args = [$(join (meson_c_args (p, envs; is_host), " , " )) ]
189
+ cpp_args = [$(join (meson_cxx_args (p, envs; is_host), " , " )) ]
190
+ fortran_args = [$(join (meson_fortran_args (p, envs; is_host), " , " )) ]
191
+ objc_args = [$(join (meson_objc_args (p, envs; is_host), " , " )) ]
192
+ c_link_args = [$(join (meson_c_link_args (p, envs; is_host), " , " )) ]
193
+ cpp_link_args = [$(join (meson_cxx_link_args (p, envs; is_host), " , " )) ]
194
+ fortran_link_args = [$(join (meson_fortran_link_args (p, envs; is_host), " , " )) ]
195
+ objc_link_args = [$(join (meson_objc_link_args (p, envs; is_host), " , " )) ]
196
+ prefix = '$(envs[is_host ? " host_prefix" : " prefix" ]) '
197
+
184
198
[properties]
185
- c_args = [$(join (meson_c_args (p), " , " )) ]
186
- cpp_args = [$(join (meson_cxx_args (p), " , " )) ]
187
- fortran_args = [$(join (meson_fortran_args (p), " , " )) ]
188
- objc_args = [$(join (meson_objc_args (p), " , " )) ]
189
- c_link_args = [$(join (meson_c_link_args (p), " , " )) ]
190
- cpp_link_args = [$(join (meson_cxx_link_args (p), " , " )) ]
191
- fortran_link_args = [$(join (meson_fortran_link_args (p), " , " )) ]
192
- objc_link_args = [$(join (meson_objc_link_args (p), " , " )) ]
193
- needs_exe_wrapper = $(meson_is_foreign (p))
199
+ needs_exe_wrapper = $(meson_is_foreign (p; is_host))
200
+ cmake_toolchain_file = '$(envs[is_host ? " CMAKE_HOST_TOOLCHAIN" : " CMAKE_TARGET_TOOLCHAIN" ]) '
201
+ cmake_defaults = false
194
202
195
203
[build_machine]
196
204
system = 'linux'
@@ -203,13 +211,10 @@ function toolchain_file(bt::Meson, p::AbstractPlatform)
203
211
cpu_family = '$(meson_cpu_family (p)) '
204
212
cpu = '$(meson_cpu (p)) '
205
213
endian = 'little'
206
-
207
- [paths]
208
- prefix = '/workspace/destdir'
209
214
"""
210
215
end
211
216
212
- function generate_toolchain_files! (platform:: AbstractPlatform ;
217
+ function generate_toolchain_files! (platform:: AbstractPlatform , envs :: Dict{String,String} ;
213
218
toolchains_path:: AbstractString ,
214
219
host_platform:: AbstractPlatform = default_host_platform,
215
220
)
@@ -229,8 +234,8 @@ function generate_toolchain_files!(platform::AbstractPlatform;
229
234
write (joinpath (dir, " host_$(aatriplet (p)) _$(compiler) .cmake" ), toolchain_file (CMake {compiler} (), p; is_host= true ))
230
235
end
231
236
end
232
- write (joinpath (dir, " $(aatriplet (p)) _clang.meson" ), toolchain_file (Meson {:clang} (), p))
233
- write (joinpath (dir, " $(aatriplet (p)) _gcc.meson" ), toolchain_file (Meson {:gcc} (), p))
237
+ write (joinpath (dir, " $(aatriplet (p)) _clang.meson" ), toolchain_file (Meson {:clang} (), p, envs; is_host = platforms_match (p, host_platform) ))
238
+ write (joinpath (dir, " $(aatriplet (p)) _gcc.meson" ), toolchain_file (Meson {:gcc} (), p, envs; is_host = platforms_match (p, host_platform) ))
234
239
235
240
symlink_if_exists (target, link) = ispath (joinpath (dir, target)) && symlink (target, link)
236
241
0 commit comments