From 242d9ed30d94ab5fc958920ff4dca4acd3f741ba Mon Sep 17 00:00:00 2001 From: NikLeberg Date: Wed, 17 Nov 2021 09:18:05 +0000 Subject: [PATCH] buildsystem: test for EXTERNAL_PKG_DIRS feature --- tests/external_pkg_dirs/Makefile | 6 ++++ tests/external_pkg_dirs/README.md | 16 +++++++++ .../external_pkgs/external_pkg/Kconfig | 9 +++++ .../external_pkgs/external_pkg/Makefile | 16 +++++++++ .../external_pkg/Makefile.include | 1 + .../external_pkg_not_used/Kconfig | 9 +++++ .../external_pkg_not_used/Makefile | 19 ++++++++++ .../external_pkg_not_used/Makefile.include | 1 + tests/external_pkg_dirs/main.c | 35 +++++++++++++++++++ 9 files changed, 112 insertions(+) create mode 100644 tests/external_pkg_dirs/Makefile create mode 100644 tests/external_pkg_dirs/README.md create mode 100644 tests/external_pkg_dirs/external_pkgs/external_pkg/Kconfig create mode 100644 tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile create mode 100644 tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile.include create mode 100644 tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Kconfig create mode 100644 tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile create mode 100644 tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile.include create mode 100644 tests/external_pkg_dirs/main.c diff --git a/tests/external_pkg_dirs/Makefile b/tests/external_pkg_dirs/Makefile new file mode 100644 index 0000000000..7c4b6420b9 --- /dev/null +++ b/tests/external_pkg_dirs/Makefile @@ -0,0 +1,6 @@ +include ../Makefile.tests_common + +EXTERNAL_PKG_DIRS += external_pkgs +USEPKG += external_pkg + +include $(RIOTBASE)/Makefile.include diff --git a/tests/external_pkg_dirs/README.md b/tests/external_pkg_dirs/README.md new file mode 100644 index 0000000000..e33e14ee8e --- /dev/null +++ b/tests/external_pkg_dirs/README.md @@ -0,0 +1,16 @@ +external_pkg_dirs +================= + +Test application for the EXTERNAL_PKG_DIRS feature of the buildsystem. +Two external packages are provided in `external_pkgs/`: `external_pkg` and +`external_pkg_not_used`. If the first package is not properly included, a define +from `CFLAGS` is missing and a precompiler error is triggered. If the second +package somehow ends up included it triggers a makefile error. + +Usage +===== + +Set `EXTERNAL_PKG_DIRS` inside Makefile to point to other paths where the +buildsystem can look for packages. Similar functionality to `EXTERNAL_PKG_DIRS`. +Be careful to not name these externally provided packages the same as existing +packages in `$(RIOTBASE)/pkg/`. diff --git a/tests/external_pkg_dirs/external_pkgs/external_pkg/Kconfig b/tests/external_pkg_dirs/external_pkgs/external_pkg/Kconfig new file mode 100644 index 0000000000..9239ba5685 --- /dev/null +++ b/tests/external_pkg_dirs/external_pkgs/external_pkg/Kconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2022 Niklaus Leuenberger +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +config PACKAGE_EXTERNAL_PKG + bool "external_pkg package" + depends on TEST_KCONFIG diff --git a/tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile b/tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile new file mode 100644 index 0000000000..cdd177ddbd --- /dev/null +++ b/tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile @@ -0,0 +1,16 @@ +PKG_NAME = external_pkg + +include $(RIOTBASE)/Makefile.base + +.PHONY: all prepare clean distclean + +all: prepare + +prepare: + @: + +clean:: + rm -rf $(BINDIR)/pkg/$(PKG_NAME) + +distclean:: + rm -rf $(BINDIR)/pkg/$(PKG_NAME) diff --git a/tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile.include b/tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile.include new file mode 100644 index 0000000000..77a1edeb6a --- /dev/null +++ b/tests/external_pkg_dirs/external_pkgs/external_pkg/Makefile.include @@ -0,0 +1 @@ +CFLAGS += -DTEST_EXTERNAL_PKG diff --git a/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Kconfig b/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Kconfig new file mode 100644 index 0000000000..7ad5849bd6 --- /dev/null +++ b/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Kconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2022 Niklaus Leuenberger +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +config PACKAGE_EXTERNAL_PKG_NOT_USED + bool "external_pkg_not_used package" + depends on TEST_KCONFIG diff --git a/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile b/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile new file mode 100644 index 0000000000..cb0674fbdb --- /dev/null +++ b/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile @@ -0,0 +1,19 @@ +PKG_NAME = external_pkg_not_used + +include $(RIOTBASE)/Makefile.base + +.PHONY: all prepare clean distclean + +all: + $(error target all for external_pkg_not_used executed) + +prepare: + $(error target prepare for external_pkg_not_used executed) + +clean:: + rm -rf $(BINDIR)/pkg/$(PKG_NAME) + $(error target clean for external_pkg_not_used executed) + +distclean:: + rm -rf $(BINDIR)/pkg/$(PKG_NAME) + $(error target distclean for external_pkg_not_used executed) diff --git a/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile.include b/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile.include new file mode 100644 index 0000000000..458386142f --- /dev/null +++ b/tests/external_pkg_dirs/external_pkgs/external_pkg_not_used/Makefile.include @@ -0,0 +1 @@ +CFLAGS += -DTEST_EXTERNAL_PKG_NOT_USED diff --git a/tests/external_pkg_dirs/main.c b/tests/external_pkg_dirs/main.c new file mode 100644 index 0000000000..7c65ecb139 --- /dev/null +++ b/tests/external_pkg_dirs/main.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021 Niklaus Leuenberger + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief This is a test for the EXTERNAL_PKG_DIRS variable. + * + * @author Niklaus Leuenberger + * + * @} + */ + +#include + +#ifndef TEST_EXTERNAL_PKG + #error "Required external package not included." +#endif + +#ifdef TEST_EXTERNAL_PKG_NOT_USED + #error "External package included that shouldn't be." +#endif + +int main(void) +{ + puts("If it compiles, it works!"); + return 0; +}