From patchwork Wed Dec 24 15:07:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AdrianF X-Patchwork-Id: 77430 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 60FF5E776C0 for ; Wed, 24 Dec 2025 15:08:42 +0000 (UTC) Received: from mta-65-228.siemens.flowmailer.net (mta-65-228.siemens.flowmailer.net [185.136.65.228]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.122215.1766588917078602382 for ; Wed, 24 Dec 2025 07:08:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=adrian.freihofer@siemens.com header.s=fm2 header.b=GKusWuIL; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.65.228, mailfrom: fm-1329275-202512241508344df93cf541000207a5-qyiagr@rts-flowmailer.siemens.com) Received: by mta-65-228.siemens.flowmailer.net with ESMTPSA id 202512241508344df93cf541000207a5 for ; Wed, 24 Dec 2025 16:08:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=adrian.freihofer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=Qx3zpWlIYXMtydybpiGJrOQdb1H6KNnc30aO91WTDwI=; b=GKusWuILyLUB2iyofV5Q2rFlBfgARlcfFKUjX1OkNSeUIssThoPmECZZcpurhIXhzK4o+w UlwP/0jpzJJpxv2h094lq5BxNeuMviDMYQsAGBO50CuOL5hCkbsAB1xUkitgmpSmMPJ4AkGr r1GZ/pW1NY+LvB2JII73eTKEfGXPZPeNTJk3n2fNoebD86ZGWFXH790X0P+m/rpZ/UPqPPKE ddV0x2Nt9sWGEj/5vlMOwYk9TO97AnLM6F+oh54AdScPlrPIDI5CeecDDwWcPuwaT90t07HQ WxWhpJ6xVV0M5wiuuuPSGNfDGcRbcCWpsDtQnzOacqIHV2/VljhuGxhQ==; From: AdrianF To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 1/2] oe-setup-vscode: improve bitbake-setup compatibility Date: Wed, 24 Dec 2025 16:07:41 +0100 Message-ID: <20251224150805.3312684-2-adrian.freihofer@siemens.com> In-Reply-To: <20251224150805.3312684-1-adrian.freihofer@siemens.com> References: <20251224150805.3312684-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1329275:519-21489:flowmailer List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 24 Dec 2025 15:08:42 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/228543 From: Adrian Freihofer VSCode searches for the .vscode/settings.json file in the workspace folder and its parent folders. Or the other way round, VSCode needs to be started in a folder which contains the .vscode/settings.json file. With bitbake-setup the .vscode/settings.json file created by oe-setup-vscode is located for example in bitbake-builds/poky-master/layers/oe-init-build-env-dir/.vscode/settings.json. Layers looks like this: bitbake logs meta-yocto oe-init-build-env-dir -> openembedded-core .oe-layers.json oe-scripts -> openembedded-core/scripts openembedded-core setup-build -> openembedded-core/scripts/oe-setup-build yocto-docs Since oe-init-build-env-dir is a sym-link to openembedded-core the .vscode folder is effectively located in openembedded-core/.vscode. Starting VSCode in oe-init-build-env-dir picks up the settings.json file correctly but the VSCode Bitake plugin cannot find bitbake. Bitbake is located in a folder at the same level as openembedded-core. So the path to bitbake is not anymore workspaceFolder/bitbake but ../bitbake relative to the workspace folder. To fix this, we now dynamically determine the actual location of bitbake by using `which bitbake` and adjusting the bitbake.pathToBitbakeFolder setting accordingly. This minimal fix makes VSCode usable without running into issues with OOM exceptions due to indexing the build folder or bitbake not found errors. But the user experience is still much worse than with the simple poky layout. Only the openembedded-core layer is visible in the workspace folder. The other layers are not visible which means this setup is not really usable yet. The .vscode/settings.json file is created at the wrong path. This should be improved in future iterations. Signed-off-by: Adrian Freihofer --- scripts/oe-setup-vscode | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/oe-setup-vscode b/scripts/oe-setup-vscode index b8642780d5..6818641d42 100755 --- a/scripts/oe-setup-vscode +++ b/scripts/oe-setup-vscode @@ -22,13 +22,14 @@ fi VSCODE_SETTINGS=$VSCODEDIR/settings.json ws_builddir="$(echo "$BUILDDIR" | sed -e "s|$OEINIT|\${workspaceFolder}|g")" +bb_dir="$(dirname "$(which bitbake)" | sed 's|/bin$||')" # If BUILDDIR is in scope of VSCode ensure VSCode does not try to index the build folder. # This would lead to a busy CPU and finally to an OOM exception. mkdir -p "$VSCODEDIR" cat < "$VSCODE_SETTINGS" { - "bitbake.pathToBitbakeFolder": "\${workspaceFolder}/bitbake", + "bitbake.pathToBitbakeFolder": "$bb_dir", "bitbake.pathToEnvScript": "\${workspaceFolder}/oe-init-build-env", "bitbake.pathToBuildFolder": "$ws_builddir", "bitbake.commandWrapper": "", From patchwork Wed Dec 24 15:07:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AdrianF X-Patchwork-Id: 77429 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 5FF67E77379 for ; Wed, 24 Dec 2025 15:08:42 +0000 (UTC) Received: from mta-65-228.siemens.flowmailer.net (mta-65-228.siemens.flowmailer.net [185.136.65.228]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.122216.1766588917078681423 for ; Wed, 24 Dec 2025 07:08:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=adrian.freihofer@siemens.com header.s=fm2 header.b=nV3NrXv5; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.65.228, mailfrom: fm-1329275-20251224150834282098c5f200020762-rmmoba@rts-flowmailer.siemens.com) Received: by mta-65-228.siemens.flowmailer.net with ESMTPSA id 20251224150834282098c5f200020762 for ; Wed, 24 Dec 2025 16:08:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=adrian.freihofer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=cSOH4Cbtmy2JybnDwf6Z3raCrldb6liB8BmCqbh6sSY=; b=nV3NrXv5QxZW4HpHmE1zGlKoQWokRUQExZRs+xk9I9eGJl3NgJ/Fcp377FIqLLzk+84S39 4YkbDo57TDlnwBhUl60uAxNvVlXMmxzi2yAHrOKtZhXtIsJ9A+ywEWOSsfOVhIXRIcVL5CuS 6b0K2jpldUZgW8kkQ0Xsun2ooRxb1+j+fadBlgBPRfDPr4+bd5sBNk+GV5OH8O1lIZV8T0RP +Z8BZ50hD0IQWPFk6nL2/25nppZJXRreT/SIZXATMOG9brVPSW3EEcjYAiw97ZWftlXln4Z0 YfqLYcIzIvKn/prHmWsT9iUFWJ1EoNx7QL6iMXFafibmcBZ2HkZ49ClQ==; From: AdrianF To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 2/2] oe-setup-vscode: improve VSCode bitbake-setup compatibility Date: Wed, 24 Dec 2025 16:07:42 +0100 Message-ID: <20251224150805.3312684-3-adrian.freihofer@siemens.com> In-Reply-To: <20251224150805.3312684-1-adrian.freihofer@siemens.com> References: <20251224150805.3312684-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1329275:519-21489:flowmailer List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 24 Dec 2025 15:08:42 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/228542 From: Adrian Freihofer VSCode is started in the workspace folder where the .vscode directory is located. With the new bitbake-setup based build layout, this starts VSCode in the openembedded-core directory, which means only files in that layer are visible. This is not usable for most projects which span multiple layers. Enhance the VSCode setup to work with the new bitbake-setup layout by moving the .vscode directory location from poky-master/layers/oe-init-build-env-dir/.vscode to poky-master/.vscode bringing all layers back into the scope of VSCode. The oe-init-build-env script now detects the build layout by checking for the presence of a layers directory, and adjusts the .vscode location accordingly. Additionally, the file exclusion patterns have been refined to improve VSCode performance: - Separated files.exclude from search.exclude patterns for better control - Added exclusions for oe-init-build-env-dir and oe-scripts directories - Prevented indexing of build artifacts and temporary files The configuration now also detects whether to use oe-init-build-env or init-build-env based on the detected build mode. Usage example: 1. bitbake-setup creates a directory structure like: poky-master/ layers/ openembedded-core/ meta-yourlayer/ build/ init-build-env 2. Create the .vscode directory in poky-master by running: . build/init-build-env The settings.json contains: "bitbake.pathToBitbakeFolder": ".../poky-master/layers/bitbake", "bitbake.pathToBuildFolder": "${workspaceFolder}/build", "bitbake.pathToEnvScript": "${workspaceFolder}/build/init-build-env", "bitbake.workingDirectory": "${workspaceFolder}", 3. Start VSCode in poky-master Note: Starting VSCode before the .vscode directory exists may cause VSCode to index the entire workspace, leading to high CPU and memory usage. Future improvements could include creating a minimal .vscode directory during bitbake-setup initialization. Signed-off-by: Adrian Freihofer --- oe-init-build-env | 16 ++++++++-- scripts/oe-setup-vscode | 68 +++++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/oe-init-build-env b/oe-init-build-env index 82382f2707..6547cdd297 100755 --- a/oe-init-build-env +++ b/oe-init-build-env @@ -49,8 +49,20 @@ export OEROOT } # Generate an initial configuration for VSCode and the yocto-bitbake plugin. -if command -v code > /dev/null && [ ! -d "$OEROOT/.vscode" ]; then - oe-setup-vscode "$OEROOT" "$BUILDDIR" +if command -v code > /dev/null ; then + # bitbake-setup mode + if [ -d "$BUILDDIR/../layers" ]; then + echo "bitbake-setup mode detected for VSCode setup." + if [ ! -d "$BUILDDIR/../.vscode" ]; then + oe-setup-vscode "$BUILDDIR/../" "$BUILDDIR" + fi + # poky mode + else + echo "poky mode detected for VSCode setup." + if [ ! -d "$OEROOT/.vscode" ]; then + oe-setup-vscode "$OEROOT" "$BUILDDIR" + fi + fi fi unset OEROOT diff --git a/scripts/oe-setup-vscode b/scripts/oe-setup-vscode index 6818641d42..0fea1c4808 100755 --- a/scripts/oe-setup-vscode +++ b/scripts/oe-setup-vscode @@ -20,47 +20,52 @@ if [ ! -d "$OEINIT" ] || [ ! -d "$BUILDDIR" ]; then exit 1 fi -VSCODE_SETTINGS=$VSCODEDIR/settings.json +mkdir -p "$VSCODEDIR" +VSCODE_SETTINGS_TMP=$(mktemp -p "$VSCODEDIR") ws_builddir="$(echo "$BUILDDIR" | sed -e "s|$OEINIT|\${workspaceFolder}|g")" + +# poky mode or bitbake-setup mode +ws_build_env="\${workspaceFolder}/oe-init-build-env" +if [ -f "$BUILDDIR/init-build-env" ]; then + ws_build_env="${ws_builddir}/init-build-env" +fi + bb_dir="$(dirname "$(which bitbake)" | sed 's|/bin$||')" +files_exclude="\"**/_build/**\": true, + \"**/.git/**\": true, + \"**/cache/**\": true, + \"**/downloads/**\": true, + \"**/node_modules/**\": true, + \"**/oe-init-build-env-dir/**\": true, + \"**/oe-scripts/**\": true, + \"**/sstate-cache/**\": true, + \"**/workspace/attic/**\": true" + +search_exclude="\"**/buildhistory/**\": true, + \"**/oe-logs/**\": true, + \"**/oe-workdir/**\": true, + \"**/tmp*/**\": true, + \"**/workspace/sources/**\": true" + # If BUILDDIR is in scope of VSCode ensure VSCode does not try to index the build folder. # This would lead to a busy CPU and finally to an OOM exception. -mkdir -p "$VSCODEDIR" -cat < "$VSCODE_SETTINGS" +cat < "$VSCODE_SETTINGS_TMP" { "bitbake.pathToBitbakeFolder": "$bb_dir", - "bitbake.pathToEnvScript": "\${workspaceFolder}/oe-init-build-env", "bitbake.pathToBuildFolder": "$ws_builddir", - "bitbake.commandWrapper": "", + "bitbake.pathToEnvScript": "$ws_build_env", "bitbake.workingDirectory": "\${workspaceFolder}", "files.exclude": { - "**/.git/**": true, - "**/_build/**": true, - "**/buildhistory/**": true, - "**/cache/**": true, - "**/downloads/**": true, - "**/node_modules/**": true, - "**/oe-logs/**": true, - "**/oe-workdir/**": true, - "**/sstate-cache/**": true, - "**/tmp*/**": true, - "**/workspace/attic/**": true, - "**/workspace/sources/**": true + $files_exclude + }, + "search.exclude": { + $files_exclude, + $search_exclude }, "files.watcherExclude": { - "**/.git/**": true, - "**/_build/**": true, - "**/buildhistory/**": true, - "**/cache/**": true, - "**/downloads/**": true, - "**/node_modules/**": true, - "**/oe-logs/**": true, - "**/oe-workdir/**": true, - "**/sstate-cache/**": true, - "**/tmp*/**": true, - "**/workspace/attic/**": true, - "**/workspace/sources/**": true + $files_exclude, + $search_exclude }, "python.analysis.exclude": [ "**/_build/**", @@ -74,11 +79,14 @@ cat < "$VSCODE_SETTINGS" "**/sstate-cache/**", "**/tmp*/**", "**/workspace/attic/**", - "**/workspace/sources/**" + "**/workspace/sources/**", + "**/oe-init-build-env-dir/**", + "**/oe-scripts/**" ] } EOMsettings +mv -f "$VSCODE_SETTINGS_TMP" "$VSCODEDIR/settings.json" # Ask the user if the yocto-bitbake extension should be installed VSCODE_EXTENSIONS=$VSCODEDIR/extensions.json