py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.

This new config option allows to control whether MicroPython uses its own
internal printf or not (if not, an external one should be linked in).
Accompanying this new option is the inclusion of lib/utils/printf.c in the
core list of source files, so that ports no longer need to include it
themselves.
crypto-aes
Delio Brignoli 6 years ago committed by Damien George
parent cac8dc3414
commit e2ac8bb3f1
  1. 1
      bare-arm/mpconfigport.h
  2. 1
      cc3200/application.mk
  3. 1
      esp8266/Makefile
  4. 6
      lib/utils/printf.c
  5. 1
      minimal/Makefile
  6. 5
      py/mpconfig.h
  7. 1
      py/py.mk
  8. 1
      qemu-arm/mpconfigport.h
  9. 1
      stmhal/Makefile
  10. 1
      teensy/Makefile
  11. 1
      unix/Makefile

@ -42,6 +42,7 @@
#define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_USE_INTERNAL_PRINTF (0)
// type definitions for the specific machine

@ -154,7 +154,6 @@ APP_LIB_SRC_C = $(addprefix lib/,\
timeutils/timeutils.c \
utils/pyexec.c \
utils/pyhelp.c \
utils/printf.c \
)
APP_STM_SRC_C = $(addprefix stmhal/,\

@ -128,7 +128,6 @@ LIB_SRC_C = $(addprefix lib/,\
timeutils/timeutils.c \
utils/pyexec.c \
utils/pyhelp.c \
utils/printf.c \
fatfs/ff.c \
fatfs/option/ccsbcs.c \
)

@ -24,6 +24,10 @@
* THE SOFTWARE.
*/
#include "py/mpconfig.h"
#if MICROPY_USE_INTERNAL_PRINTF
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
@ -127,3 +131,5 @@ int snprintf(char *str, size_t size, const char *fmt, ...) {
va_end(ap);
return ret;
}
#endif //MICROPY_USE_INTERNAL_PRINTF

@ -46,7 +46,6 @@ SRC_C = \
main.c \
uart_core.c \
lib/utils/stdout_helpers.c \
lib/utils/printf.c \
lib/utils/pyexec.c \
lib/libc/string0.c \
lib/mp-readline/readline.c \

@ -581,6 +581,11 @@ typedef double mp_float_t;
#define MICROPY_USE_INTERNAL_ERRNO (0)
#endif
// Whether to use internally defined *printf() functions (otherwise external ones)
#ifndef MICROPY_USE_INTERNAL_PRINTF
#define MICROPY_USE_INTERNAL_PRINTF (1)
#endif
// Support for user-space VFS mount (selected ports)
#ifndef MICROPY_FSUSERMOUNT
#define MICROPY_FSUSERMOUNT (0)

@ -223,6 +223,7 @@ PY_O_BASENAME = \
../extmod/vfs_fat_misc.o \
../extmod/moduos_dupterm.o \
../lib/embed/abort_.o \
../lib/utils/printf.o \
# prepend the build destination prefix to the py object files
PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))

@ -23,6 +23,7 @@
#define MICROPY_PY_IO (0)
#define MICROPY_PY_SYS_EXIT (1)
#define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_USE_INTERNAL_PRINTF (0)
// type definitions for the specific machine

@ -111,7 +111,6 @@ SRC_LIB = $(addprefix lib/,\
timeutils/timeutils.c \
utils/pyexec.c \
utils/pyhelp.c \
utils/printf.c \
)
SRC_C = \

@ -110,7 +110,6 @@ LIB_SRC_C = $(addprefix lib/,\
mp-readline/readline.c \
utils/pyexec.c \
utils/pyhelp.c \
utils/printf.c \
)
SRC_TEENSY = $(addprefix core/,\

@ -157,7 +157,6 @@ endif
LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \
utils/printf.c \
timeutils/timeutils.c \
)

Loading…
Cancel
Save