Add MESON_CROSS_BINARIES, MESON_CROSS_PROPERTIES as a colon separated list of meson properties which are exported into meson.cross.
Signed-off-by: Alex Kiernan <alex.kier...@gmail.com> --- Changes in v3: None Changes in v2: None meta/classes/meson.bbclass | 161 ++++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 75 deletions(-) diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass index 06034e8b4731..e778e37d7f69 100644 --- a/meta/classes/meson.bbclass +++ b/meta/classes/meson.bbclass @@ -34,88 +34,99 @@ MESON_CROSS_FILE = "" MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" MESON_CROSS_FILE_class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" -def meson_array(var, d): - items = d.getVar(var).split() - return repr(items[0] if len(items) == 1 else items) - -# Map our ARCH values to what Meson expects: -# http://mesonbuild.com/Reference-tables.html#cpu-families -def meson_cpu_family(var, d): - import re - arch = d.getVar(var) - if arch == 'powerpc': - return 'ppc' - elif arch == 'powerpc64' or arch == 'powerpc64le': - return 'ppc64' - elif arch == 'armeb': - return 'arm' - elif arch == 'aarch64_be': - return 'aarch64' - elif arch == 'mipsel': - return 'mips' - elif arch == 'mips64el': - return 'mips64' - elif re.match(r"i[3-6]86", arch): - return "x86" - elif arch == "microblazeel": - return "microblaze" - else: - return arch - -# Map our OS values to what Meson expects: -# https://mesonbuild.com/Reference-tables.html#operating-system-names -def meson_operating_system(var, d): - os = d.getVar(var) - if "mingw" in os: - return "windows" - else: - return os - -def meson_endian(prefix, d): - arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS") - sitedata = siteinfo_data_for_machine(arch, os, d) - if "endian-little" in sitedata: - return "little" - elif "endian-big" in sitedata: - return "big" - else: - bb.fatal("Cannot determine endianism for %s-%s" % (arch, os)) +MESON_CROSS_BINARIES ??= "c:CC \ + cpp:CXX \ + ar:AR \ + nm:NM \ + strip:STRIP \ + readelf:READELF" + +MESON_CROSS_PROPERTIES ??= "c_args:CFLAGS \ + c_link_args:LDFLAGS \ + cpp_args:CXXFLAGS \ + cpp_link_args:LDFLAGS" addtask write_config before do_configure -do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS" -do_write_config() { - # This needs to be Py to split the args into single-element lists - cat >${WORKDIR}/meson.cross <<EOF +python do_write_config() { + def meson_array(var): + items = d.getVar(var).split() + return repr(items[0] if len(items) == 1 else items) + + # Map our ARCH values to what Meson expects: + # http://mesonbuild.com/Reference-tables.html#cpu-families + def meson_cpu_family(var): + import re + arch = d.getVar(var) + if arch == 'powerpc': + return 'ppc' + elif arch == 'powerpc64' or arch == 'powerpc64le': + return 'ppc64' + elif arch == 'armeb': + return 'arm' + elif arch == 'aarch64_be': + return 'aarch64' + elif arch == 'mipsel': + return 'mips' + elif arch == 'mips64el': + return 'mips64' + elif re.match(r"i[3-6]86", arch): + return "x86" + elif arch == "microblazeel": + return "microblaze" + else: + return arch + + # Map our OS values to what Meson expects: + # https://mesonbuild.com/Reference-tables.html#operating-system-names + def meson_operating_system(var): + os = d.getVar(var) + if "mingw" in os: + return "windows" + else: + return os + + def meson_endian(prefix): + arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS") + sitedata = siteinfo_data_for_machine(arch, os, d) + if "endian-little" in sitedata: + return "little" + elif "endian-big" in sitedata: + return "big" + else: + bb.fatal("Cannot determine endianism for %s-%s" % (arch, os)) + + def meson_write_props(var, f): + for property in d.getVar(var).split(): + (k, v) = property.split(':') + print("{} = {}".format(k, meson_array(v)), file=f) + d.appendVarFlag("do_write_config", "vardeps", v) + + with open(oe.path.join(d.getVar('WORKDIR'), "meson.cross"), "w") as f: + print("""\ [binaries] -c = ${@meson_array('CC', d)} -cpp = ${@meson_array('CXX', d)} -ar = ${@meson_array('AR', d)} -nm = ${@meson_array('NM', d)} -strip = ${@meson_array('STRIP', d)} -readelf = ${@meson_array('READELF', d)} pkgconfig = 'pkg-config' -llvm-config = 'llvm-config${LLVMVERSION}' +llvm-config = 'llvm-config{}'""".format(d.getVar("LLVMVERSION")), file=f) + + meson_write_props('MESON_CROSS_BINARIES', f) + print("""\ [properties] needs_exe_wrapper = true -c_args = ${@meson_array('CFLAGS', d)} -c_link_args = ${@meson_array('LDFLAGS', d)} -cpp_args = ${@meson_array('CXXFLAGS', d)} -cpp_link_args = ${@meson_array('LDFLAGS', d)} -gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper' - -[host_machine] -system = '${@meson_operating_system('HOST_OS', d)}' -cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' -cpu = '${HOST_ARCH}' -endian = '${@meson_endian('HOST', d)}' - -[target_machine] -system = '${@meson_operating_system('TARGET_OS', d)}' -cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' -cpu = '${TARGET_ARCH}' -endian = '${@meson_endian('TARGET', d)}' -EOF +gtkdoc_exe_wrapper = '{}/gtkdoc-qemuwrapper'""".format(d.getVar('B')), file=f) + + meson_write_props('MESON_CROSS_PROPERTIES', f) + + print("[host_machine]", file=f) + print("system = '{}'".format(meson_operating_system('HOST_OS')), file=f) + print("cpu_family = '{}'".format(meson_cpu_family('HOST_ARCH')), file=f) + print("cpu = '{}'".format(d.getVar('HOST_ARCH')), file=f) + print("endian = '{}'".format(meson_endian('HOST')), file=f) + + print("[target_machine]", file=f) + print("system = '{}'".format(meson_operating_system('TARGET_OS')), file=f) + print("cpu_family = '{}'".format(meson_cpu_family('TARGET_ARCH')), file=f) + print("cpu = '{}'".format(d.getVar('TARGET_ARCH')), file=f) + print("endian = '{}'".format(meson_endian('TARGET')), file=f) } CONFIGURE_FILES = "meson.build" -- 2.17.1 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core