summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/meson.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes-recipe/meson.bbclass')
-rw-r--r--meta/classes-recipe/meson.bbclass28
1 files changed, 25 insertions, 3 deletions
diff --git a/meta/classes-recipe/meson.bbclass b/meta/classes-recipe/meson.bbclass
index 03fa2c06eb..c8b3e1ec29 100644
--- a/meta/classes-recipe/meson.bbclass
+++ b/meta/classes-recipe/meson.bbclass
@@ -9,7 +9,6 @@ inherit python3native meson-routines qemu
9DEPENDS:append = " meson-native ninja-native" 9DEPENDS:append = " meson-native ninja-native"
10 10
11EXEWRAPPER_ENABLED:class-native = "False" 11EXEWRAPPER_ENABLED:class-native = "False"
12EXEWRAPPER_ENABLED:class-nativesdk = "False"
13EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}" 12EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}"
14DEPENDS:append = "${@' qemu-native' if d.getVar('EXEWRAPPER_ENABLED') == 'True' else ''}" 13DEPENDS:append = "${@' qemu-native' if d.getVar('EXEWRAPPER_ENABLED') == 'True' else ''}"
15 14
@@ -23,6 +22,9 @@ MESON_SOURCEPATH = "${S}"
23# The target to build in do_compile. If unset the default targets are built. 22# The target to build in do_compile. If unset the default targets are built.
24MESON_TARGET ?= "" 23MESON_TARGET ?= ""
25 24
25# Since 0.60.0 you can specify custom tags to install
26MESON_INSTALL_TAGS ?= ""
27
26def noprefix(var, d): 28def noprefix(var, d):
27 return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) 29 return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
28 30
@@ -60,6 +62,14 @@ def rust_tool(d, target_var):
60 cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() 62 cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split()
61 return "rust = %s" % repr(cmd) 63 return "rust = %s" % repr(cmd)
62 64
65def bindgen_args(d):
66 args = '${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}'
67 # For SDK packages TOOLCHAIN_OPTIONS don't contain full sysroot path
68 if bb.data.inherits_class("nativesdk", d):
69 args += ' --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE}${prefix_nativesdk}'
70 items = d.expand(args).split()
71 return repr(items[0] if len(items) == 1 else items)
72
63addtask write_config before do_configure 73addtask write_config before do_configure
64do_write_config[vardeps] += "CC CXX AR NM STRIP READELF OBJCOPY CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS EXEWRAPPER_ENABLED" 74do_write_config[vardeps] += "CC CXX AR NM STRIP READELF OBJCOPY CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS EXEWRAPPER_ENABLED"
65do_write_config() { 75do_write_config() {
@@ -91,6 +101,7 @@ cpp_link_args = ${@meson_array('LDFLAGS', d)}
91[properties] 101[properties]
92needs_exe_wrapper = true 102needs_exe_wrapper = true
93sys_root = '${STAGING_DIR_HOST}' 103sys_root = '${STAGING_DIR_HOST}'
104bindgen_clang_arguments = ${@bindgen_args(d)}
94 105
95[host_machine] 106[host_machine]
96system = '${@meson_operating_system('HOST_OS', d)}' 107system = '${@meson_operating_system('HOST_OS', d)}'
@@ -127,7 +138,7 @@ cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)}
127EOF 138EOF
128} 139}
129 140
130do_write_config:append:class-target() { 141write_qemuwrapper() {
131 # Write out a qemu wrapper that will be used as exe_wrapper so that meson 142 # Write out a qemu wrapper that will be used as exe_wrapper so that meson
132 # can run target helper binaries through that. 143 # can run target helper binaries through that.
133 qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" 144 qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}"
@@ -145,6 +156,14 @@ EOF
145 chmod +x ${WORKDIR}/meson-qemuwrapper 156 chmod +x ${WORKDIR}/meson-qemuwrapper
146} 157}
147 158
159do_write_config:append:class-target() {
160 write_qemuwrapper
161}
162
163do_write_config:append:class-nativesdk() {
164 write_qemuwrapper
165}
166
148# Tell externalsrc that changes to this file require a reconfigure 167# Tell externalsrc that changes to this file require a reconfigure
149CONFIGURE_FILES = "meson.build" 168CONFIGURE_FILES = "meson.build"
150 169
@@ -175,7 +194,10 @@ meson_do_compile() {
175} 194}
176 195
177meson_do_install() { 196meson_do_install() {
178 meson install --destdir ${D} --no-rebuild 197 if [ "x${MESON_INSTALL_TAGS}" != "x" ] ; then
198 meson_install_tags="--tags ${MESON_INSTALL_TAGS}"
199 fi
200 meson install --destdir ${D} --no-rebuild $meson_install_tags
179} 201}
180 202
181EXPORT_FUNCTIONS do_configure do_compile do_install 203EXPORT_FUNCTIONS do_configure do_compile do_install