From patchwork Mon Nov 20 14:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 34853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33AC4C5AE5B for ; Mon, 20 Nov 2023 14:46:40 +0000 (UTC) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mx.groups.io with SMTP id smtpd.web10.51874.1700491594971403030 for ; Mon, 20 Nov 2023 06:46:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DUxuXu8+; spf=pass (domain: gmail.com, ip: 209.85.221.44, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-32f7c44f6a7so2971675f8f.1 for ; Mon, 20 Nov 2023 06:46:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700491593; x=1701096393; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5bZy+Gx0I3+tJrj05Rac0WLotK159bhY71sUU/vWKTQ=; b=DUxuXu8+vr8s+L4oR3iewS+abJJ9v3hlD3ouJ3YSV6i+1Szj382qbTVEFDwR075vH2 vmG4BSI5Iu0OTmB/5Z7QChsw20ju/WosUzdCMSlxCA2sOZKUlx0c13O/T1M1efen0Q5v NgGricZsSAR3mV0eElt3DfFohDlOuhQsq4dDxL/JvFV2kheM1WspH9IZm74n5n75jbEV YJf1R87jy3rPt5VwZLp7/UVGFAxXs5bX9c2eMACPrKeDD5wAOpRN7yfUXCoRH2UV6ATB xP4TWfYYOnAN3YXyeA/F6FuI3lXrDEt7nktI0WGAqxfeDGpAe5QJbt0bLnYfiVVgr/l/ C1RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700491593; x=1701096393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5bZy+Gx0I3+tJrj05Rac0WLotK159bhY71sUU/vWKTQ=; b=Di6mq85N4UtrkDEBBmO2YdtrYDFK++JYDTWXQtmuydZpcUA3JamvsUS5foseUMmAaq qY6PfmaOl8CylSDSOii379LLgb994fPDcpOCxBV6iWLMi7ND+TRFh251MFEOqo8qFbgC f0ErfA1PcoNOiUQo8YLnqf85GpHU1D6KpSIJnlANZH/MggRG+xEPoIFTW29IQs5cilng lojl5yM4J/deQ8m+2hbPZVWnYquMxNdWGxewlpsTMH4oSWoSD7VoVEWvFubBB7+ymjap UbGFKU+nqgLba4nKfs0YCUag4wmMuahEC8YKj8GWKG4MyvzneC74l6GwDE5JSSRcdeKO HBwA== X-Gm-Message-State: AOJu0YwM+PHHBExdqEENL5vNczPF6H+8tceu6TTg8J3rpcWfT6PmOwmv 7ro6ceK/suT5mfzUgL0eAk9/n4b+W1Y= X-Google-Smtp-Source: AGHT+IEseORSoBfcClNDMM/SYXQVv0IcqbDcyV1xiIHGwqEneamH0KzkHJRE2KU1kkzkFumc9b0vMA== X-Received: by 2002:a5d:64c2:0:b0:332:c65a:8f5d with SMTP id f2-20020a5d64c2000000b00332c65a8f5dmr2364929wri.35.1700491593237; Mon, 20 Nov 2023 06:46:33 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id a18-20020adfeed2000000b00327de0173f6sm11454848wrp.115.2023.11.20.06.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:46:32 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 1/2] cmake-qemu.bbclass: support qemu for cmake Date: Mon, 20 Nov 2023 15:46:27 +0100 Message-ID: <20231120144628.52664-2-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120144628.52664-1-adrian.freihofer@siemens.com> References: <20231120144628.52664-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 20 Nov 2023 14:46:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/190879 Define the CMAKE_CROSSCOMPILING_EMULATOR variable similar to what the meson bbclass does. This allows for example to execute cross compilied unit tests on the build machine when using an SDK. CMAKE_CROSSCOMPILING_EMULATOR is a semi colon separated list of paramters which could directly handle the -L and the -E parameters. Creating a wrapper script is not absolutely mandatory. But anyway lets do it similar to what the meson.bbclass does and also disable pseudo. Further information can be found in the camke documentation in the CMAKE_CROSSCOMPILING_EMULATOR section. Keep the code optional, as the core does not need this function and does not intend to use it in the future. [YOCTO #15214] Signed-off-by: Adrian Freihofer --- meta/classes-recipe/cmake-qemu.bbclass | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 meta/classes-recipe/cmake-qemu.bbclass diff --git a/meta/classes-recipe/cmake-qemu.bbclass b/meta/classes-recipe/cmake-qemu.bbclass new file mode 100644 index 0000000000..76b748f340 --- /dev/null +++ b/meta/classes-recipe/cmake-qemu.bbclass @@ -0,0 +1,28 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# +# Not all platforms are supported by Qemu. Using qemu-user therefore +# involves a certain risk, which is also the reason why this feature +# is not activated by default. + +inherit qemu + +CMAKE_EXEWRAPPER_ENABLED:class-native = "False" +CMAKE_EXEWRAPPER_ENABLED:class-nativesdk = "False" +CMAKE_EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}" +DEPENDS:append = "${@' qemu-native' if d.getVar('CMAKE_EXEWRAPPER_ENABLED') == 'True' else ''}" + +cmake_do_generate_toolchain_file:append:class-target() { + if [ "${CMAKE_EXEWRAPPER_ENABLED}" = "True" ]; then + # Write out a qemu wrapper that will be used as exe_wrapper so that camake + # can run target helper binaries through that. This also allows to execute ctest. + qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_HOST}', ['${STAGING_DIR_HOST}/${libdir}','${STAGING_DIR_HOST}/${base_libdir}'])}" + echo "#!/bin/sh" > "${WORKDIR}/cmake-qemuwrapper" + echo "$qemu_binary \"\$@\"" >> "${WORKDIR}/cmake-qemuwrapper" + chmod +x "${WORKDIR}/cmake-qemuwrapper" + echo "set( CMAKE_CROSSCOMPILING_EMULATOR ${WORKDIR}/cmake-qemuwrapper)" \ + >> ${WORKDIR}/toolchain.cmake + fi +} From patchwork Mon Nov 20 14:46:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 34854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D196C197A0 for ; Mon, 20 Nov 2023 14:46:40 +0000 (UTC) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.groups.io with SMTP id smtpd.web10.51876.1700491596224720706 for ; Mon, 20 Nov 2023 06:46:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JMpGgRAT; spf=pass (domain: gmail.com, ip: 209.85.128.54, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40a5a444c3eso13831075e9.2 for ; Mon, 20 Nov 2023 06:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700491594; x=1701096394; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2E0CTfbvl60Y3TW1jFrt/VbWt4JIFlwnWyvL3oJoQic=; b=JMpGgRAToNOYgBo2nrqxT7Aj7SQqUPa2Rf62xw2ZqSscXYotHVwp6FGGp0Wlhi6Ofl 4YwHbudhqJkXqyWK4rIlutUqKUwYsmnNFlfj4In7UKoT+AhhUNueYqpU4m4Dq9VY4F/X +LDPye8j10eS91mE4ycv+20MRgQeRNcQYlf/9yv+NwvEhVg+hACEJSxc2eXFMWc+7f5W 5/6i63DBFztGBOO9lJpjnUf8h4nI6aAZXenxQLBD7Bap+mxht1y6rgr78OtKh129RCIA Q0yTJqt8i0rN77P0/5zoVJ14JSjxMLnUbxZDNbVVzIWC4MsHOgQWo53UAUs1fugWqXcT sgHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700491594; x=1701096394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2E0CTfbvl60Y3TW1jFrt/VbWt4JIFlwnWyvL3oJoQic=; b=OAgBIeWVtvZreoxhHBOVIt4JZCZb50Tj6cSSzCRFo8MYEncLnv7qF7YG+BPr/jb2Rk N9oHGbE4+ch63t6PjcSCuaKkztFI5JPOGcrqLAfZYYtLDoOyAJOrV1oO4qgMf2981c4l bPAdQCOSQkAQo4DvikJcyCOL7Aa36+5Xj9u4QFOBSIvKsug3cyk66DOWcNLLicz2MOMl Kk30uRxekRj3B+LkIsxp73YxpdiDBXvzB1MXKXkgfNR9NtX5mGKG/6t8r5pQ3tgI13V5 kPy4g0lA2liT6mDYtmmprJjvKZxeWSI4kQmT3IIIZ7epD/rF8kStEFW52M801yl+OZT7 cX3A== X-Gm-Message-State: AOJu0YwCeiGO34eHjUYkHAh55i+DKCOm/W0ETyh14HXVo9BcLKGnRE2N 7wx/iEATjEe0f8gf2bXMF/3cQlXVjXo= X-Google-Smtp-Source: AGHT+IEdHuS5VwB4X0nOsCR5ED1UsjzOZkPProNTlee/QjfLqyS7dQl9e2AYA4JhNfsUTdqHYyjjMw== X-Received: by 2002:a5d:6d81:0:b0:332:ca14:f589 with SMTP id l1-20020a5d6d81000000b00332ca14f589mr1286561wrs.12.1700491594258; Mon, 20 Nov 2023 06:46:34 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id a18-20020adfeed2000000b00327de0173f6sm11454848wrp.115.2023.11.20.06.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:46:33 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 2/2] cmake.bbclass: optionally support qemu Date: Mon, 20 Nov 2023 15:46:28 +0100 Message-ID: <20231120144628.52664-3-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120144628.52664-1-adrian.freihofer@siemens.com> References: <20231120144628.52664-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 20 Nov 2023 14:46:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/190880 Provide an easy way to enable cmake-qemu e.g. on distro level for all recipes inheriting the cmake.bbclass. Therefore a new variable is introduced: OECMAKE_EXEWRAPPER_QEMU. If set to "1" all recipes built with CMake can use qemu to execute cross-compiled binaries on the build machine. One use case is the execution of cross-compiled unit tests or ptests, e.g. in an SDK context. Therefore, a variable that activates Qemu for all CMake recipes is much more useful than just providing the optional cmake-qemu.bbclass. Further information can be found in the CMake documentation in the CMAKE_CROSSCOMPILING_EMULATOR section. There are some use cases for qemu-user, but users should not be encouraged to use it as an alternative for clean cross-compilation. Since the core does not need it either it is optional. Signed-off-by: Adrian Freihofer --- meta/classes-recipe/cmake.bbclass | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta/classes-recipe/cmake.bbclass b/meta/classes-recipe/cmake.bbclass index d978b88944..4d8e2a206f 100644 --- a/meta/classes-recipe/cmake.bbclass +++ b/meta/classes-recipe/cmake.bbclass @@ -14,6 +14,10 @@ B = "${WORKDIR}/build" # The supported options are "Unix Makefiles" or "Ninja". OECMAKE_GENERATOR ?= "Ninja" +# qemu-user can be used for special use cases, but not by default +OECMAKE_EXEWRAPPER_QEMU ??= "0" +inherit ${@'cmake-qemu' if d.getVar('OECMAKE_EXEWRAPPER_QEMU') else ''} + python() { generator = d.getVar("OECMAKE_GENERATOR") if "Unix Makefiles" in generator: