From 858f32e62e147265db9861d3bcab388d3e73907f Mon Sep 17 00:00:00 2001 From: Ernest Van Hoecke Date: Fri, 20 Feb 2026 15:08:55 +0100 Subject: [PATCH 1/2] tasks.sh: split $MAKE into $MAKE_VARS and $MAKE This allows using $MAKE_VARS elsewhere even without invoking make directly. For example, to call scripts/kconfig/merge_config.sh from a task and passing it the same environment variables. The existing behaviour is unaffected. Signed-off-by: Ernest Van Hoecke --- tasks.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks.sh b/tasks.sh index 0bd8afe..16427c6 100755 --- a/tasks.sh +++ b/tasks.sh @@ -55,7 +55,8 @@ done # Default context variables, can be overridden by local.sh or in environment. : ${WORKSPACE_DIR:=`realpath -s "${SCRIPT_DIR}/.."`} -: ${MAKE:="make -j`nproc` LLVM=1 LLVM_IAS=1 CC='ccache clang'"} +: ${MAKE_VARS:="LLVM=1 LLVM_IAS=1 CC='ccache clang'"} +: ${MAKE:="make -j`nproc` ${MAKE_VARS}"} : ${TARGET_ARCH:="x86_64"} : ${TARGET_GDB:="gdb-multiarch"} : ${SILENT_BUILD_FLAG="-s"} From 974c00fc1209abd654d6922c4c23482be651b7f5 Mon Sep 17 00:00:00 2001 From: Ernest Van Hoecke Date: Fri, 20 Feb 2026 15:17:26 +0100 Subject: [PATCH 2/2] tasks.sh: add command override hook for redefining tasks in local.sh Adds a local task override hook in tasks.sh that calls a function in local.sh and exits before the default tasks.sh task is run. This hook runs after all variables are defined, while local.sh has to be sourced before it to allow it to set defaults. The hook thus allows users to redefine commands in local.sh that use variables such as $MAKE and in the normal context. Signed-off-by: Ernest Van Hoecke --- README.md | 5 +++-- local.sh | 12 ++++++++++++ tasks.sh | 9 +++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d4b4674..82cb259 100644 --- a/README.md +++ b/README.md @@ -227,8 +227,9 @@ there). task basically just call `tasks.sh` with a different command flag. * `.vscode/tasks.sh` is a bash script with a big switch statement that implements all tasks exposed by `tasks.json`. They all share a common - preamble customizable - locally by local.sh. + preamble customizable locally by local.sh. Tasks can be overridden in + local.sh by defining a method called `task_()`. + Example: "start-wait-dbg" => `task_start_wait_dbg` * `.vscode/settings.jsonnet` [provides per-workspace configuration values to VSCode](https://code.visualstudio.com/docs/getstarted/settings) and its extensions. This is constructed by `tasks.sh` by evaluating diff --git a/local.sh b/local.sh index dda21bd..209bc19 100644 --- a/local.sh +++ b/local.sh @@ -12,6 +12,18 @@ ## Generate objects in a subdirectory # MAKE="$MAKE O=.vscode/build-$TARGET_ARCH/" +# +## Fully override any task by defining task_(). +## Hyphens in command names become underscores in function names. +## Example: override "defconfig" +# task_defconfig() { +# if [ ! -f "${WORKSPACE_DIR}/.config" ]; then +# eval ${MAKE} ARCH=${TARGET_ARCH} tinyconfig +# scripts/config --enable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT +# eval ${MAKE} ARCH=${TARGET_ARCH} olddefconfig +# fi +# } + ## Enable some random kernel CONFIG by default as part of the .config generation # if [ $COMMAND = "defconfig" ]; then # trap "scripts/config -e BPF_SYSCALL" EXIT diff --git a/tasks.sh b/tasks.sh index 16427c6..5304c2f 100755 --- a/tasks.sh +++ b/tasks.sh @@ -130,6 +130,15 @@ fi -append \"console=${SERIAL_TTY},115200 root=${ROOT_MNT} rw nokaslr init=/lib/systemd/systemd debug systemd.log_level=info ${KERNEL_CMDLINE_EXTRA}\" \ -drive file=${IMAGE_PATH},format=raw -kernel ${KERNEL_PATH} ${VM_START_ARGS}"} +# Optional local task override hook: +# Define task_() in local.sh to fully handle a task. +# Example: "start-wait-dbg" => task_start_wait_dbg +TASK_OVERRIDE_FN="task_${COMMAND//-/_}" +if declare -F "${TASK_OVERRIDE_FN}" > /dev/null; then + "${TASK_OVERRIDE_FN}" "$@" + exit $? +fi + case "${COMMAND}" in # Virtual machine life-cycle "start")