From 3d5499f90aeb9c58afcd9ea80ed8a6fd62ea4e25 Mon Sep 17 00:00:00 2001 From: Brett Nicholas <7547222+bigbrett@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:45:39 -0700 Subject: [PATCH] address review feedback --- docs/hooks.md | 2 +- include/hooks.h | 8 ++++++++ options.mk | 14 +++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/hooks.md b/docs/hooks.md index d8ada5cf..48223eb9 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -51,7 +51,7 @@ wolfBoot_panic() (called on any fatal error) ## Build Configuration -First, Enable hooks in your `.config` +First, enable hooks in your `.config`: ```makefile # Path to a single .c file containing your hook implementations diff --git a/include/hooks.h b/include/hooks.h index a0602eea..9e027c9d 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -28,6 +28,10 @@ #ifndef WOLFBOOT_HOOKS_H #define WOLFBOOT_HOOKS_H +#ifdef __cplusplus +extern "C" { +#endif + struct wolfBoot_image; #ifdef WOLFBOOT_HOOK_LOADER_PREINIT @@ -46,4 +50,8 @@ void wolfBoot_hook_boot(struct wolfBoot_image *boot_img); void wolfBoot_hook_panic(void); #endif +#ifdef __cplusplus +} +#endif + #endif /* WOLFBOOT_HOOKS_H */ diff --git a/options.mk b/options.mk index ef1c1e80..94de9fec 100644 --- a/options.mk +++ b/options.mk @@ -1154,20 +1154,28 @@ endif # wolfBoot hooks framework # WOLFBOOT_HOOKS_FILE: path to a single .c file containing hook definitions -ifneq ($(WOLFBOOT_HOOKS_FILE),) - OBJS += $(patsubst %.c,%.o,$(WOLFBOOT_HOOKS_FILE)) -endif +WOLFBOOT_HOOKS_ENABLED := ifeq ($(WOLFBOOT_HOOK_LOADER_PREINIT),1) CFLAGS += -DWOLFBOOT_HOOK_LOADER_PREINIT + WOLFBOOT_HOOKS_ENABLED := 1 endif ifeq ($(WOLFBOOT_HOOK_LOADER_POSTINIT),1) CFLAGS += -DWOLFBOOT_HOOK_LOADER_POSTINIT + WOLFBOOT_HOOKS_ENABLED := 1 endif ifeq ($(WOLFBOOT_HOOK_BOOT),1) CFLAGS += -DWOLFBOOT_HOOK_BOOT + WOLFBOOT_HOOKS_ENABLED := 1 endif ifeq ($(WOLFBOOT_HOOK_PANIC),1) CFLAGS += -DWOLFBOOT_HOOK_PANIC + WOLFBOOT_HOOKS_ENABLED := 1 +endif +ifneq ($(WOLFBOOT_HOOKS_ENABLED),) + ifeq ($(WOLFBOOT_HOOKS_FILE),) + $(error WOLFBOOT_HOOKS_FILE must be set to a .c file when hooks are enabled) + endif + OBJS += $(patsubst %.c,%.o,$(WOLFBOOT_HOOKS_FILE)) endif # Cert chain verification options