summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDelio Brignoli <brignoli.delio@gmail.com>2016-08-21 11:33:37 +0200
committerDamien George <damien.p.george@gmail.com>2016-09-05 12:18:53 +1000
commite2ac8bb3f14b076a29244022865e3b47c6c0800a (patch)
treeba02f53ca3f6b488084df68d78e1d5dd9ee99d46
parentcac8dc34149686679b67037d393d3ea1c6aff779 (diff)
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.
-rw-r--r--bare-arm/mpconfigport.h1
-rw-r--r--cc3200/application.mk1
-rw-r--r--esp8266/Makefile1
-rw-r--r--lib/utils/printf.c6
-rw-r--r--minimal/Makefile1
-rw-r--r--py/mpconfig.h5
-rw-r--r--py/py.mk1
-rw-r--r--qemu-arm/mpconfigport.h1
-rw-r--r--stmhal/Makefile1
-rw-r--r--teensy/Makefile1
-rw-r--r--unix/Makefile1
11 files changed, 14 insertions, 6 deletions
diff --git a/bare-arm/mpconfigport.h b/bare-arm/mpconfigport.h
index 7c448d13c..79b2b7328 100644
--- a/bare-arm/mpconfigport.h
+++ b/bare-arm/mpconfigport.h
@@ -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
diff --git a/cc3200/application.mk b/cc3200/application.mk
index dca6fcbc6..300262c97 100644
--- a/cc3200/application.mk
+++ b/cc3200/application.mk
@@ -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/,\
diff --git a/esp8266/Makefile b/esp8266/Makefile
index 521cbb472..1dfcec809 100644
--- a/esp8266/Makefile
+++ b/esp8266/Makefile
@@ -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 \
)
diff --git a/lib/utils/printf.c b/lib/utils/printf.c
index 308525b6e..303edfcca 100644
--- a/lib/utils/printf.c
+++ b/lib/utils/printf.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
diff --git a/minimal/Makefile b/minimal/Makefile
index 02096f9f0..0cecd1c0f 100644
--- a/minimal/Makefile
+++ b/minimal/Makefile
@@ -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 \
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 455f870ac..e33a41f7a 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -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)
diff --git a/py/py.mk b/py/py.mk
index abea7215b..37b98de92 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -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))
diff --git a/qemu-arm/mpconfigport.h b/qemu-arm/mpconfigport.h
index 57277b156..1f23148c2 100644
--- a/qemu-arm/mpconfigport.h
+++ b/qemu-arm/mpconfigport.h
@@ -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
diff --git a/stmhal/Makefile b/stmhal/Makefile
index e06eed1cc..881c073f1 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -111,7 +111,6 @@ SRC_LIB = $(addprefix lib/,\
timeutils/timeutils.c \
utils/pyexec.c \
utils/pyhelp.c \
- utils/printf.c \
)
SRC_C = \
diff --git a/teensy/Makefile b/teensy/Makefile
index 7b34ba90e..0ab07121c 100644
--- a/teensy/Makefile
+++ b/teensy/Makefile
@@ -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/,\
diff --git a/unix/Makefile b/unix/Makefile
index 3afa80dfa..49b605f12 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -157,7 +157,6 @@ endif
LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \
- utils/printf.c \
timeutils/timeutils.c \
)