From b0b2665cead5da9efdc6f376c13ab756b7a77e38 Mon Sep 17 00:00:00 2001 From: Matt Schulte Date: Tue, 7 Nov 2023 11:03:59 -0800 Subject: [PATCH] [make] Add ability to deny modules from being used Certain projects may want to prevent the usage of certain modules from being used. Here are two examples of when this may occur: 1. The Project has it's own fdt library and does not want developer's using the version of libfdt included with LK 2. The project does not want developers using mincrypt. `DENY_MODULES` is a list which developers can set in their own project makefiles which is checked on each module inclusion. If that module is on the deny list, it causes a build failure. --- engine.mk | 3 +++ make/module.mk | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/engine.mk b/engine.mk index e56d1b23f..66b36747d 100644 --- a/engine.mk +++ b/engine.mk @@ -165,6 +165,9 @@ BUILDID ?= # comment out or override if you want to see the full output of each command NOECHO ?= @ +# Any modules you want to explictly prevent from being used +DENY_MODULES := + # try to include the project file -include project/$(PROJECT).mk ifndef TARGET diff --git a/make/module.mk b/make/module.mk index 8a10712a9..bf7618052 100644 --- a/make/module.mk +++ b/make/module.mk @@ -46,6 +46,10 @@ $(error MODULE $(MODULE) is probably setting OBJS, change to MODULE_SRCS) endif endif +ifneq ($(filter $(MODULE),$(DENY_MODULES)),) +$(error MODULE $(MODULE) is not allowed by PROJECT $(PROJECT)'s DENY_MODULES list) +endif + MODULE_SRCDIR := $(MODULE) MODULE_BUILDDIR := $(call TOBUILDDIR,$(MODULE_SRCDIR))