File tree 11 files changed +48
-11
lines changed
11 files changed +48
-11
lines changed Original file line number Diff line number Diff line change 10
10
runs-on : ubuntu-24.04
11
11
env :
12
12
MPY_DIR : ./micropython
13
- MICROPYTHON_BIN : ./micropython/ports/unix/build-standard /micropython
13
+ MICROPYTHON_BIN : ./micropython/ports/unix/build-nomodules /micropython
14
14
steps :
15
15
- uses : actions/checkout@v4
16
16
with :
29
29
run : pip install -r requirements.txt
30
30
- name : Setup MicroPython X86
31
31
working-directory : micropython
32
- run : source tools/ci.sh && ci_unix_32bit_setup && ci_unix_standard_build
33
- - name : Run test and build module x64
32
+ run : |
33
+ source tools/ci.sh && ci_unix_32bit_setup && ci_unix_standard_build
34
+ mv ./ports/unix/build-standard/ ./ports/unix/build-nomodules/
35
+ - name : Build custom firmware with user modules, and tests. Unix/x64
36
+ run : make check_unix V=1
37
+ - name : Build .mpy modules and run tests Unix/x64
34
38
run : make check ARCH=x64 V=1
35
39
- name : Setup MicroPython ARM
36
40
working-directory : micropython
Original file line number Diff line number Diff line change @@ -8,7 +8,13 @@ VERSION := $(shell git describe --tags --always)
8
8
9
9
MPY_DIR_ABS = $(abspath $(MPY_DIR ) )
10
10
11
+ C_MODULES_SRC_PATH = $(abspath ./src)
12
+ MANIFEST_PATH = $(abspath ./src/manifest.py)
13
+
14
+ PORT =unix
11
15
MODULES_PATH = ./dist/$(ARCH ) _$(MPY_ABI_VERSION )
16
+ PORT_DIR = ./dist/ports/$(PORT )
17
+ UNIX_MICROPYTHON = ./dist/ports/unix/micropython
12
18
13
19
$(MODULES_PATH ) /emlearn_trees.mpy :
14
20
make -C src/emlearn_trees/ ARCH=$(ARCH ) MPY_DIR=$(MPY_DIR_ABS ) V=1 clean dist
@@ -61,7 +67,20 @@ emlearn_iir_q15.results: $(MODULES_PATH)/emlearn_iir_q15.mpy
61
67
emlearn_arrayutils.results : $(MODULES_PATH ) /emlearn_arrayutils.mpy
62
68
MICROPYPATH=$(MODULES_PATH ) $(MICROPYTHON_BIN ) tests/test_arrayutils.py
63
69
64
- .PHONY : clean
70
+ $(PORT_DIR ) :
71
+ mkdir -p $@
72
+
73
+ $(UNIX_MICROPYTHON ) : $(PORT_DIR )
74
+ make -C $(MPY_DIR ) /ports/unix V=1 USER_C_MODULES=$(C_MODULES_SRC_PATH ) FROZEN_MANIFEST=$(MANIFEST_PATH ) CFLAGS_EXTRA=' -Wno-unused-function -Wno-unused-function' -j4
75
+ cp $(MPY_DIR ) /ports/unix/build-standard/micropython $@
76
+
77
+ unix : $(UNIX_MICROPYTHON )
78
+
79
+ check_unix : $(UNIX_MICROPYTHON )
80
+ $(UNIX_MICROPYTHON ) tests/test_trees.py
81
+ $(UNIX_MICROPYTHON ) tests/test_iir.py
82
+
83
+ .PHONY : clean unix
65
84
66
85
clean :
67
86
make -C src/emlearn_trees/ ARCH=$(ARCH ) MPY_DIR=$(MPY_DIR_ABS ) V=1 clean
Original file line number Diff line number Diff line change 1
- emlearn >= 0.21.1
1
+ emlearn >= 0.21.2
2
2
scikit-learn >= 1.0.0
3
3
ar >= 1.0.0
4
4
pyelftools >= 0.31
Original file line number Diff line number Diff line change @@ -33,6 +33,6 @@ $(DIST_FILE): $(MOD).mpy $(DIST_DIR)
33
33
include $(MPY_DIR ) /py/dynruntime.mk
34
34
35
35
36
- CFLAGS += -I$(EMLEARN_DIR )
36
+ CFLAGS += -I$(EMLEARN_DIR ) -Wno-unused-function
37
37
38
38
dist : $(DIST_FILE )
Original file line number Diff line number Diff line change @@ -32,6 +32,6 @@ $(DIST_FILE): $(MOD).mpy $(DIST_DIR)
32
32
# Include to get the rules for compiling and linking the module
33
33
include $(MPY_DIR ) /py/dynruntime.mk
34
34
35
- CFLAGS += -I$(EMLEARN_DIR )
35
+ CFLAGS += -I$(EMLEARN_DIR ) -Wno-unused-function
36
36
37
37
dist : $(DIST_FILE )
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ LIBGCC_FILENAME = $(shell $(CROSS)gcc $(CFLAGS) -print-libgcc-file-name)
41
41
$(info $(LIBGCC_FILENAME))
42
42
43
43
CFLAGS += -I$(CMSIS_DSP_DIR ) /Include
44
+ CFLAGS += -Wno-unused-function
44
45
45
46
$(CMSIS_DSP_DIR ) /iir_q15.patched :
46
47
cd $(CMSIS_DSP_DIR ) && git apply -v ../df1_q15_disable_dsp.patch
Original file line number Diff line number Diff line change @@ -33,6 +33,6 @@ $(DIST_DIR):
33
33
$(DIST_FILE ) : $(MOD ) .mpy $(DIST_DIR )
34
34
cp $< $@
35
35
36
- CFLAGS += -I$(EMLEARN_DIR )
36
+ CFLAGS += -I$(EMLEARN_DIR ) -Wno-unused-function
37
37
38
38
dist : $(DIST_FILE )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ DIST_DIR := ../../dist/$(ARCH)_$(MPY_ABI_VERSION)
19
19
MOD = emlearn_trees
20
20
21
21
# Source files (.c or .py)
22
- SRC = trees.c trees .py
22
+ SRC = trees.c emlearn_trees .py
23
23
24
24
# Releases
25
25
DIST_FILE = $(DIST_DIR ) /$(MOD ) .mpy
@@ -32,6 +32,6 @@ $(DIST_FILE): $(MOD).mpy $(DIST_DIR)
32
32
# Include to get the rules for compiling and linking the module
33
33
include $(MPY_DIR ) /py/dynruntime.mk
34
34
35
- CFLAGS += -I$(EMLEARN_DIR ) -DDYNAMIC_RUNTIME=1
35
+ CFLAGS += -I$(EMLEARN_DIR ) -Wno-unused-function
36
36
37
37
dist : $(DIST_FILE )
Original file line number Diff line number Diff line change 1
1
2
+ # When used as external C module, the .py is the top-level import,
3
+ # and we need to merge the native module symbols at import time
4
+ # When used as dynamic native modules (.mpy), .py and native code is merged at build time
5
+ try :
6
+ from emlearn_trees_c import *
7
+ except ImportError as e :
8
+ pass
2
9
3
10
def load_model (builder , f ):
4
11
Original file line number Diff line number Diff line change @@ -332,7 +332,8 @@ const mp_obj_module_t emlearn_trees_cmodule = {
332
332
.globals = (mp_obj_dict_t * )& emlearn_trees_globals ,
333
333
};
334
334
335
- MP_REGISTER_MODULE (MP_QSTR_emlearn_trees , emlearn_trees_cmodule );
335
+ // External module name is XXX_c to allow .py file to be the entrypoint
336
+ MP_REGISTER_MODULE (MP_QSTR_emlearn_trees_c , emlearn_trees_cmodule );
336
337
337
338
#endif
338
339
Original file line number Diff line number Diff line change
1
+
2
+ # Manifest is used to include .py files for external C module build
3
+ # NOTE: this is a different mechanism than
4
+ # Ref https://docs.micropython.org/en/latest/reference/manifest.html
5
+ module ("emlearn_trees.py" , base_path = './emlearn_trees' )
You can’t perform that action at this time.
0 commit comments