aboutsummaryrefslogtreecommitdiff
path: root/py/dynruntime.mk
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-11-30 23:03:09 +1100
committerDamien George <damien.p.george@gmail.com>2019-12-12 20:15:28 +1100
commitabc642973db46fbce7494d34ea0ef2539b339be0 (patch)
treefbf026f0dc669ec38a0c447eb1de1cbfb6820e28 /py/dynruntime.mk
parentff58961944f4f2380e9610a4d18c53c08f68060e (diff)
py/dynruntime: Add support for float API to make/get floats.
We don't want to add a feature flag to .mpy files that indicate float support because it will get complex and difficult to use. Instead the .mpy is built using whatever precision it chooses (float or double) and the native glue API will convert between this choice and what the host runtime actually uses.
Diffstat (limited to 'py/dynruntime.mk')
-rw-r--r--py/dynruntime.mk10
1 files changed, 10 insertions, 0 deletions
diff --git a/py/dynruntime.mk b/py/dynruntime.mk
index b01b80e0d..8b65745af 100644
--- a/py/dynruntime.mk
+++ b/py/dynruntime.mk
@@ -46,6 +46,7 @@ ifeq ($(ARCH),x86)
CROSS =
CFLAGS += -m32 -fno-stack-protector
MPY_CROSS_FLAGS += -mcache-lookup-bc
+MICROPY_FLOAT_IMPL ?= double
else ifeq ($(ARCH),x64)
@@ -53,12 +54,14 @@ else ifeq ($(ARCH),x64)
CROSS =
CFLAGS += -fno-stack-protector
MPY_CROSS_FLAGS += -mcache-lookup-bc
+MICROPY_FLOAT_IMPL ?= double
else ifeq ($(ARCH),armv7m)
# thumb
CROSS = arm-none-eabi-
CFLAGS += -mthumb -mcpu=cortex-m3
+MICROPY_FLOAT_IMPL ?= none
else ifeq ($(ARCH),armv7emsp)
@@ -66,6 +69,7 @@ else ifeq ($(ARCH),armv7emsp)
CROSS = arm-none-eabi-
CFLAGS += -mthumb -mcpu=cortex-m4
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
+MICROPY_FLOAT_IMPL ?= float
else ifeq ($(ARCH),armv7emdp)
@@ -73,23 +77,29 @@ else ifeq ($(ARCH),armv7emdp)
CROSS = arm-none-eabi-
CFLAGS += -mthumb -mcpu=cortex-m7
CFLAGS += -mfpu=fpv5-d16 -mfloat-abi=hard
+MICROPY_FLOAT_IMPL ?= double
else ifeq ($(ARCH),xtensa)
# xtensa
CROSS = xtensa-lx106-elf-
CFLAGS += -mforce-l32
+MICROPY_FLOAT_IMPL ?= none
else ifeq ($(ARCH),xtensawin)
# xtensawin
CROSS = xtensa-esp32-elf-
CFLAGS +=
+MICROPY_FLOAT_IMPL ?= float
else
$(error architecture '$(ARCH)' not supported)
endif
+MICROPY_FLOAT_IMPL_UPPER = $(shell echo $(MICROPY_FLOAT_IMPL) | tr '[:lower:]' '[:upper:]')
+CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_$(MICROPY_FLOAT_IMPL_UPPER)
+
CFLAGS += $(CFLAGS_EXTRA)
################################################################################