Browse Source

all: Update extmod, ports, examples to build with new berkeley-db lib.

This provides a MicroPython-specific berkeley-db configuration in
extmod/berkeley-db/berkeley_db_config_port.h, and cleans up the include
path for this library.

Fixes issue #13092.

Signed-off-by: Damien George <damien@micropython.org>
pull/14099/head
Damien George 8 months ago
parent
commit
cd8eea2ae9
  1. 7
      examples/natmod/btree/Makefile
  2. 4
      examples/natmod/btree/btree_c.c
  3. 16
      extmod/berkeley-db/berkeley_db_config_port.h
  4. 16
      extmod/extmod.cmake
  5. 10
      extmod/extmod.mk
  6. 4
      extmod/modbtree.c
  7. 2
      ports/esp8266/Makefile

7
examples/natmod/btree/Makefile

@ -11,9 +11,10 @@ SRC = btree_c.c btree_py.py
ARCH = x64
BTREE_DIR = $(MPY_DIR)/lib/berkeley-db-1.xx
BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error="(void)" -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA)
CFLAGS += -I$(BTREE_DIR)/PORT/include
CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS)
BERKELEY_DB_CONFIG_FILE ?= \"extmod/berkeley-db/berkeley_db_config_port.h\"
CFLAGS += -I$(BTREE_DIR)/include
CFLAGS += -DBERKELEY_DB_CONFIG_FILE=$(BERKELEY_DB_CONFIG_FILE)
CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter
SRC += $(addprefix $(realpath $(BTREE_DIR))/,\
btree/bt_close.c \

4
examples/natmod/btree/btree_c.c

@ -39,6 +39,10 @@ void abort_(void) {
nlr_raise(mp_obj_new_exception(mp_load_global(MP_QSTR_RuntimeError)));
}
int puts(const char *s) {
return mp_printf(&mp_plat_print, "%s\n", s);
}
int native_errno;
#if defined(__linux__)
int *__errno_location (void)

16
extmod/berkeley-db/berkeley_db_config_port.h

@ -0,0 +1,16 @@
// Berkeley-db configuration.
#define __DBINTERFACE_PRIVATE 1
#define mpool_error printf
#define abort abort_
#define virt_fd_t void*
#ifdef MICROPY_BERKELEY_DB_DEFPSIZE
#define DEFPSIZE MICROPY_BERKELEY_DB_DEFPSIZE
#endif
#ifdef MICROPY_BERKELEY_DB_MINCACHE
#define MINCACHE MICROPY_BERKELEY_DB_MINCACHE
#endif
__attribute__((noreturn)) void abort_(void);

16
extmod/extmod.cmake

@ -132,27 +132,27 @@ if(MICROPY_PY_BTREE)
)
target_include_directories(micropy_extmod_btree PRIVATE
${MICROPY_LIB_BERKELEY_DIR}/PORT/include
${MICROPY_LIB_BERKELEY_DIR}/include
)
if(NOT BERKELEY_DB_CONFIG_FILE)
set(BERKELEY_DB_CONFIG_FILE "${MICROPY_DIR}/extmod/berkeley-db/berkeley_db_config_port.h")
endif()
target_compile_definitions(micropy_extmod_btree PRIVATE
__DBINTERFACE_PRIVATE=1
mpool_error=printf
abort=abort_
"virt_fd_t=void*"
BERKELEY_DB_CONFIG_FILE="${BERKELEY_DB_CONFIG_FILE}"
)
# The include directories and compile definitions below are needed to build
# modbtree.c and should be added to the main MicroPython target.
list(APPEND MICROPY_INC_CORE
"${MICROPY_LIB_BERKELEY_DIR}/PORT/include"
"${MICROPY_LIB_BERKELEY_DIR}/include"
)
list(APPEND MICROPY_DEF_CORE
MICROPY_PY_BTREE=1
__DBINTERFACE_PRIVATE=1
"virt_fd_t=void*"
BERKELEY_DB_CONFIG_FILE="${BERKELEY_DB_CONFIG_FILE}"
)
list(APPEND MICROPY_SOURCE_EXTMOD

10
extmod/extmod.mk

@ -381,8 +381,10 @@ endif
ifeq ($(MICROPY_PY_BTREE),1)
BTREE_DIR = lib/berkeley-db-1.xx
BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA)
INC += -I$(TOP)/$(BTREE_DIR)/PORT/include
BERKELEY_DB_CONFIG_FILE ?= \"extmod/berkeley-db/berkeley_db_config_port.h\"
CFLAGS_EXTMOD += -DBERKELEY_DB_CONFIG_FILE=$(BERKELEY_DB_CONFIG_FILE)
CFLAGS_EXTMOD += $(BTREE_DEFS_EXTRA)
INC += -I$(TOP)/$(BTREE_DIR)/include
SRC_THIRDPARTY_C += $(addprefix $(BTREE_DIR)/,\
btree/bt_close.c \
btree/bt_conv.c \
@ -401,9 +403,7 @@ SRC_THIRDPARTY_C += $(addprefix $(BTREE_DIR)/,\
)
CFLAGS_EXTMOD += -DMICROPY_PY_BTREE=1
# we need to suppress certain warnings to get berkeley-db to compile cleanly
# and we have separate BTREE_DEFS so the definitions don't interfere with other source code
$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter -Wno-deprecated-non-prototype -Wno-unknown-warning-option $(BTREE_DEFS)
$(BUILD)/extmod/modbtree.o: CFLAGS += $(BTREE_DEFS)
$(BUILD)/$(BTREE_DIR)/%.o: CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter -Wno-deprecated-non-prototype -Wno-unknown-warning-option
endif
################################################################################

4
extmod/modbtree.c

@ -57,8 +57,8 @@
#undef CIRCLEQ_INSERT_TAIL
#undef CIRCLEQ_REMOVE
#include <db.h>
#include <../../btree/btree.h>
#include "berkeley-db/db.h"
#include "berkeley-db/btree.h"
typedef struct _mp_obj_btree_t {
mp_obj_base_t base;

2
ports/esp8266/Makefile

@ -38,7 +38,7 @@ MICROPY_ROM_TEXT_COMPRESSION ?= 1
MICROPY_PY_SSL = 1
MICROPY_SSL_AXTLS = 1
AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
BTREE_DEFS_EXTRA = -DMICROPY_BERKELEY_DB_DEFPSIZE=1024 -DMICROPY_BERKELEY_DB_MINCACHE=3
FROZEN_MANIFEST ?= boards/manifest.py

Loading…
Cancel
Save