@@ -60,51 +60,62 @@ set(MICROPY_SOURCE_EXTMOD
6060
6161if (MICROPY_PY_BTREE)
6262 set (MICROPY_LIB_BERKELEY_DIR "${MICROPY_DIR} /lib/berkeley-db-1.xx" )
63+ string (CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/berkeley-db-1.xx)
6364
64- add_library (micropy_extmod_btree OBJECT
65- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_close.c
66- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_conv.c
67- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_debug.c
68- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_delete.c
69- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_get.c
70- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_open.c
71- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_overflow.c
72- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_page.c
73- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_put.c
74- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_search.c
75- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_seq.c
76- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_split.c
77- ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_utils.c
78- ${MICROPY_LIB_BERKELEY_DIR} /mpool/mpool.c
79- )
65+ if (ECHO_SUBMODULES OR ECHO_QUERY_VARIANTS)
66+ # No-op, we're just doing submodule/variant discovery.
67+ # Cannot run the add_library/target_include_directories rules (even though
68+ # the build won't run) because IDF will attempt verify the files exist.
69+ elseif (NOT EXISTS ${MICROPY_LIB_BERKELEY_DIR} /README)
70+ # Regular build, submodule not initialised -- fail with a clear error.
71+ message (FATAL_ERROR " MICROPY_PY_BTREE is enabled but the berkeley-db submodule is not initialised.\n Run 'make BOARD=${MICROPY_BOARD} submodules'" )
72+ else ()
73+ # Regular build, we have the submodule.
74+ add_library (micropy_extmod_btree OBJECT
75+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_close.c
76+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_conv.c
77+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_debug.c
78+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_delete.c
79+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_get.c
80+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_open.c
81+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_overflow.c
82+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_page.c
83+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_put.c
84+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_search.c
85+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_seq.c
86+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_split.c
87+ ${MICROPY_LIB_BERKELEY_DIR} /btree/bt_utils.c
88+ ${MICROPY_LIB_BERKELEY_DIR} /mpool/mpool.c
89+ )
8090
81- target_include_directories (micropy_extmod_btree PRIVATE
82- ${MICROPY_LIB_BERKELEY_DIR} /PORT/include
83- )
91+ target_include_directories (micropy_extmod_btree PRIVATE
92+ ${MICROPY_LIB_BERKELEY_DIR} /PORT/include
93+ )
8494
85- target_compile_definitions (micropy_extmod_btree PRIVATE
86- __DBINTERFACE_PRIVATE=1
87- mpool_error=printf
88- abort=abort_
89- "virt_fd_t=void*"
90- )
95+ target_compile_definitions (micropy_extmod_btree PRIVATE
96+ __DBINTERFACE_PRIVATE=1
97+ mpool_error=printf
98+ abort=abort_
99+ "virt_fd_t=void*"
100+ )
91101
92- # The include directories and compile definitions below are needed to build
93- # modbtree.c and should be added to the main MicroPython target.
102+ # The include directories and compile definitions below are needed to build
103+ # modbtree.c and should be added to the main MicroPython target.
94104
95- list (APPEND MICROPY_INC_CORE
96- "${MICROPY_LIB_BERKELEY_DIR} /PORT/include"
97- )
105+ list (APPEND MICROPY_INC_CORE
106+ "${MICROPY_LIB_BERKELEY_DIR} /PORT/include"
107+ )
98108
99- list (APPEND MICROPY_DEF_CORE
100- MICROPY_PY_BTREE=1
101- __DBINTERFACE_PRIVATE=1
102- "virt_fd_t=void*"
103- )
109+ list (APPEND MICROPY_DEF_CORE
110+ MICROPY_PY_BTREE=1
111+ __DBINTERFACE_PRIVATE=1
112+ "virt_fd_t=void*"
113+ )
104114
105- list (APPEND MICROPY_SOURCE_EXTMOD
106- ${MICROPY_EXTMOD_DIR} /modbtree.c
107- )
115+ list (APPEND MICROPY_SOURCE_EXTMOD
116+ ${MICROPY_EXTMOD_DIR} /modbtree.c
117+ )
118+ endif ()
108119endif ()
109120
110121# Library for mbedtls
0 commit comments