diff --git a/Kconfig b/Kconfig index 745bc773f567067a85ce6574fb41ce80833247d9..ce72294706c7af356caceb05edea8c2d26ca3304 100644 --- a/Kconfig +++ b/Kconfig @@ -30,3 +30,5 @@ source "lib/Kconfig" source "lib/Kconfig.debug" source "Documentation/Kconfig" + +source "vendor/Kconfig" diff --git a/Makefile b/Makefile index 795ca6c3503e7f55d6d86b9568b61b2be5000613..49fc2ddd08ae4aedec5c04ad6ab6ed5c04b389a9 100644 --- a/Makefile +++ b/Makefile @@ -653,6 +653,7 @@ drivers-y := drivers/ sound/ drivers-$(CONFIG_SAMPLES) += samples/ drivers-y += net/ virt/ libs-y := lib/ +vendor-$(CONFIG_OHOS_VENDOR) := vendor/ endif # KBUILD_EXTMOD # The all: target is the default when no target is given on the @@ -1155,16 +1156,16 @@ ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ vmlinux-dirs := $(patsubst %/,%,$(filter %/, \ - $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) $(vendor-y) \ $(libs-y) $(libs-m))) vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ $(patsubst %/,%,$(filter %/, $(core-) \ - $(drivers-) $(libs-)))) + $(drivers-) $(vendor-) $(libs-)))) subdir-modorder := $(addsuffix modules.order,$(filter %/, \ $(core-y) $(core-m) $(libs-y) $(libs-m) \ - $(drivers-y) $(drivers-m))) + $(drivers-y) $(drivers-m) $(vendor-y))) build-dirs := $(vmlinux-dirs) clean-dirs := $(vmlinux-alldirs) @@ -1179,6 +1180,7 @@ else KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y)) endif KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y)) +KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(vendor-y)) export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds diff --git a/drivers/hooks/Kconfig b/drivers/hooks/Kconfig index 547933c5975f32a1479df5e8ba6a1d15b125aa19..bff298adaf8e14e397db67a348bbfbd4255c59df 100644 --- a/drivers/hooks/Kconfig +++ b/drivers/hooks/Kconfig @@ -10,4 +10,7 @@ config VENDOR_HOOKS Allow vendor modules to attach to tracepoint "hooks" defined via DECLARE_TRACE or DECLARE_HOOK +config OHOS_VENDOR + def_bool $(success,$(srctree)/scripts/ohos-check-dir.sh $(srctree)/vendor) + endmenu diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index d9e0ceace6a64f35cdfe2819a591b6149edd3d38..9dc131de8dac9fda79eb475623d533cd4fc8b3f7 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -12,7 +12,9 @@ include scripts/Kbuild.include # The filename Kbuild has precedence over Makefile kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +ifneq ("$(wildcard $(kbuild-dir))", "") include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) +endif # Figure out what we need to build from the various variables # ========================================================================== diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 190f1117f35a2e7aa0c3ea4bcb4c98d1e4e96620..421bb2fa6e51228a7d7d1762c79c9570c38e5b65 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -10,6 +10,7 @@ #include #include #include +#include #include "lkc.h" @@ -20,11 +21,18 @@ int cdebug = PRINTD; +static const char *kconfig_white_list[] = { + "vendor/Kconfig", + "net/newip/Kconfig", + "net/newip/hooks/Kconfig", +}; + static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static bool zconf_endtoken(const char *tokenname, const char *expected_tokenname); +static bool zconf_in_whitelist(const char *path); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; @@ -367,7 +375,9 @@ menu_option_list: source_stmt: T_SOURCE T_WORD_QUOTE T_EOL { printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); - zconf_nextfile($2); + if (access(($2), F_OK) == 0 || zconf_in_whitelist($2) == false) { + zconf_nextfile($2); + } free($2); }; @@ -484,6 +494,16 @@ assign_val: %% +static bool zconf_in_whitelist(const char *path) +{ + int i; + for (i = 0; i < sizeof(kconfig_white_list) / sizeof(kconfig_white_list[0]); i++) { + if(strcmp(kconfig_white_list[i], path) == 0) + return true; + } + return false; +} + void conf_parse(const char *name) { struct symbol *sym; diff --git a/scripts/ohos-check-dir.sh b/scripts/ohos-check-dir.sh new file mode 100755 index 0000000000000000000000000000000000000000..2833618f9304c633308b527a7e7f7a52e4a3fe36 --- /dev/null +++ b/scripts/ohos-check-dir.sh @@ -0,0 +1,8 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 + +if [ -d "$1" ]; then + exit 0 +fi + +exit 1