summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2021-11-19 14:51:40 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-23 10:53:15 +0000
commit08a86c364636b3914bf0e2efceedb774dff97f00 (patch)
tree2652a433a91dbabd7d96f59767a4d676ad71712d
parenta20e6a8a85071e05b371d4f5a04a2557667828cd (diff)
downloadpoky-08a86c364636b3914bf0e2efceedb774dff97f00.tar.gz
classes/meson: Add optional rust definitions
Adds the rust tools to the cross and native files if present so that projects that use both rust and meson can build (From OE-Core rev: 0ec40fa3aff233bd0dde0461299150786da956ef) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/meson.bbclass11
1 files changed, 10 insertions, 1 deletions
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index 4ba70de3dc..a7981e481f 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -36,8 +36,15 @@ MESON_CROSS_FILE = ""
36MESON_CROSS_FILE:class-target = "--cross-file ${WORKDIR}/meson.cross" 36MESON_CROSS_FILE:class-target = "--cross-file ${WORKDIR}/meson.cross"
37MESON_CROSS_FILE:class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" 37MESON_CROSS_FILE:class-nativesdk = "--cross-file ${WORKDIR}/meson.cross"
38 38
39def rust_tool(d, target_var):
40 rustc = d.getVar('RUSTC')
41 if not rustc:
42 return ""
43 cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split()
44 return "rust = %s" % repr(cmd)
45
39addtask write_config before do_configure 46addtask write_config before do_configure
40do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS" 47do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS"
41do_write_config() { 48do_write_config() {
42 # This needs to be Py to split the args into single-element lists 49 # This needs to be Py to split the args into single-element lists
43 cat >${WORKDIR}/meson.cross <<EOF 50 cat >${WORKDIR}/meson.cross <<EOF
@@ -54,6 +61,7 @@ llvm-config = 'llvm-config${LLVMVERSION}'
54cups-config = 'cups-config' 61cups-config = 'cups-config'
55g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper' 62g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper'
56g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper' 63g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper'
64${@rust_tool(d, "HOST_SYS")}
57 65
58[built-in options] 66[built-in options]
59c_args = ${@meson_array('CFLAGS', d)} 67c_args = ${@meson_array('CFLAGS', d)}
@@ -88,6 +96,7 @@ strip = ${@meson_array('BUILD_STRIP', d)}
88readelf = ${@meson_array('BUILD_READELF', d)} 96readelf = ${@meson_array('BUILD_READELF', d)}
89objcopy = ${@meson_array('BUILD_OBJCOPY', d)} 97objcopy = ${@meson_array('BUILD_OBJCOPY', d)}
90pkgconfig = 'pkg-config-native' 98pkgconfig = 'pkg-config-native'
99${@rust_tool(d, "BUILD_SYS")}
91 100
92[built-in options] 101[built-in options]
93c_args = ${@meson_array('BUILD_CFLAGS', d)} 102c_args = ${@meson_array('BUILD_CFLAGS', d)}