8000 py/py.mk: Enable file for USER_C_MODULES build. · Carglglz/micropython@334752f · GitHub
[go: up one dir, main page]

Skip to content

Commit 334752f

Browse files
committed
py/py.mk: Enable file for USER_C_MODULES build.
This enables setting a file path to select user C modules in a USER_C_MODULES directory, the same way CMake works. The file is a .mk file with the user modules required. USER_C_MODULES=<path/to/file>/my_user_modules.mk in my_user_modules.mk: USER_C_MODULES_PATH :=<path/to/user_modules> USER_C_MODULES := module_foo USER_C_MODULES += module_bar USER_C_MODULES += module_bar/submodule $(info USER_C_MODULES found in $(USER_C_MODULES_PATH): $(USER_C_MODULES)) $(foreach module, $(USER_C_MODULES), \ $(eval USERMOD_DIR = $(patsubst %/,%,$(USER_C_MODULES_PATH))/$(module))\ $(info Including User C Module from $(USERMOD_DIR))\ $(eval include $(USERMOD_DIR)/micropython.mk)\) Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
1 parent fa393fe commit 334752f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

py/py.mk

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ LD += -m32
2929
endif
3030

3131
# External modules written in C.
32-
ifneq ($(USER_C_MODULES),)
33-
# pre-define USERMOD variables as expanded so that variables are immediate
34-
# expanded as they're added to them
35-
36-
# Confirm the provided path exists, show abspath if not to make it clearer to fix.
37-
$(if $(wildcard $(USER_C_MODULES)/.),,$(error USER_C_MODULES doesn't exist: $(abspath $(USER_C_MODULES))))
38-
3932
# C/C++ files that are included in the QSTR/module build
4033
SRC_USERMOD_C :=
4134
SRC_USERMOD_CXX :=
@@ -52,11 +45,33 @@ LDFLAGS_USERMOD :=
5245
# added to SRC_USERMOD_C below
5346
SRC_USERMOD :=
5447

48+
ifneq ($(USER_C_MODULES),)
49+
# pre-define USERMOD variables as expanded so that variables are immediate
50+
# expanded as they're added to them
51+
52+
# Confirm the provided path exists, show abspath if not to make it clearer to fix.
53+
ifeq ($(wildcard $(USER_C_MODULES)/.),)
54+
55+
# Check if the provided path is a file
56+
ifeq ($(wildcard $(USER_C_MODULES)),)
57+
$(error USER_C_MODULES doesn't exist: $(abspath $(USER_C_MODULES)))
58+
59+
# USER_C_MODULES is a .mk file
60+
else
61+
USER_C_MODULES_PATH := $(dir $(USER_C_MODULES))
62+
$(eval include $(USER_C_MODULES))
63+
64+
USER_C_MODULES := $(patsubst %/,%,$(USER_C_MODULES_PATH))
65+
66+
endif
67+
68+
else
5569
$(foreach module, $(wildcard $(USER_C_MODULES)/*/micropython.mk), \
5670
$(eval USERMOD_DIR = $(patsubst %/,%,$(dir $(module))))\
5771
$(info Including User C Module from $(USERMOD_DIR))\
5872
$(eval include $(module))\
5973
)
74+
endif
6075

6176
SRC_USERMOD_C += $(SRC_USERMOD)
6277

0 commit comments

Comments
 (0)
0