From 0a5e9e0889f18af9a9dd9b0c8f19a31a27be9bb8 Mon Sep 17 00:00:00 2001 From: ArtichautCosmique Date: Sun, 26 Sep 2021 20:37:56 +0200 Subject: [PATCH] [apps/code][mpy][makefile] Fix size error on n0100 (#30) --- Makefile | 17 ++++++++++++++++- apps/code/python_toolbox.cpp | 15 +++++++++------ build/config.mak | 1 + python/Makefile | 7 ++++++- python/port/genhdr/qstrdefs.in.h | 2 ++ python/port/mod/ulab/ulab.h | 6 ------ python/port/mpconfigport.h | 18 +++++++++++++++++- python/port/port.cpp | 2 ++ 8 files changed, 53 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 4f54b9284..d3b59008c 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,18 @@ include build/variants.mak include build/helpers.mk ifeq (${MODEL}, n0100) - EPSILON_APPS := $(filter-out reader,$(EPSILON_APPS)) + ifeq ($(filter reader,$(apps_list)),) + $(warning reader app included, removing it on n0100. ) + EPSILON_APPS := $(filter-out reader,$(EPSILON_APPS)) + endif + ifneq ($(words $(EPSILON_I18N)), 1) + $(warning Only use 1 language on n0100, defaulting to en. ) + EPSILON_I18N := en + endif + ifeq ($(INCLUDE_ULAB), 1) + $(warning Removing uLab on n0100. ) + INCLUDE_ULAB := 0 + endif endif ifeq (${MODEL}, n0110) @@ -26,6 +37,10 @@ ifdef FORCE_EXTERNAL apps_list = ${EPSILON_APPS} endif +ifeq ($(INCLUDE_ULAB), 1) + SFLAGS += -DINCLUDE_ULAB +endif + ifdef HOME_DISPLAY_EXTERNALS ifneq ($(filter external,$(apps_list)),) SFLAGS += -DHOME_DISPLAY_EXTERNALS diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 34056c8a4..f78040216 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -135,7 +135,9 @@ const ToolboxMessageTree MatplotlibPyplotModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandColorGray, I18n::Message::PythonColorGray, false) }; - const ToolboxMessageTree NumpyNdarrayModuleChildren[] = { +#if defined(INCLUDE_ULAB) + +const ToolboxMessageTree NumpyNdarrayModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyArray), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyArange), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandNumpyConcatenate), @@ -254,7 +256,6 @@ const ToolboxMessageTree NumpyModuleChildren[] = { ToolboxMessageTree::Node(I18n::Message::NumpyLinalgModule, NumpyLinalgModuleChildren) }; -#if !defined(DEVICE_N0100) const ToolboxMessageTree ScipyLinalgModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandScipyLinalgFunction, I18n::Message::PythonScipyLinalgFunction, false, I18n::Message::PythonCommandScipyLinalgFunctionWithoutArg), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandScipyLinalgChoSolve), @@ -291,16 +292,14 @@ const ToolboxMessageTree ScipyModuleChildren[] = { ToolboxMessageTree::Node(I18n::Message::ScipySpecialModule, ScipySpecialModuleChildren), }; -#endif - const ToolboxMessageTree UlabModuleChildren[] = { ToolboxMessageTree::Node(I18n::Message::NumpyModule, NumpyModuleChildren), -#if !defined(DEVICE_N0100) ToolboxMessageTree::Node(I18n::Message::ScipyModule, ScipyModuleChildren), -#endif ToolboxMessageTree::Leaf(I18n::Message::UlabDocumentation, I18n::Message::UlabDocumentationLink) }; +#endif + const ToolboxMessageTree TurtleModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportTurtle, I18n::Message::PythonImportTurtle, false), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromTurtle, I18n::Message::PythonImportTurtle, false), @@ -406,7 +405,9 @@ const ToolboxMessageTree modulesChildren[] = { ToolboxMessageTree::Node(I18n::Message::MathModule, MathModuleChildren), ToolboxMessageTree::Node(I18n::Message::CmathModule, CMathModuleChildren), ToolboxMessageTree::Node(I18n::Message::MatplotlibPyplotModule, MatplotlibPyplotModuleChildren), +#if defined(INCLUDE_ULAB) ToolboxMessageTree::Node(I18n::Message::UlabModule, UlabModuleChildren), +#endif ToolboxMessageTree::Node(I18n::Message::TurtleModule, TurtleModuleChildren), ToolboxMessageTree::Node(I18n::Message::RandomModule, RandomModuleChildren), ToolboxMessageTree::Node(I18n::Message::KandinskyModule, KandinskyModuleChildren), @@ -678,9 +679,11 @@ KDCoordinate PythonToolbox::rowHeight(int j) { bool PythonToolbox::selectLeaf(int selectedRow) { ToolboxMessageTree * node = (ToolboxMessageTree *)m_messageTreeModel->childAtIndex(selectedRow); +#if defined(INCLUDE_ULAB) if(node->text() == I18n::Message::UlabDocumentationLink){ return true; } +#endif m_selectableTableView.deselectTable(); if(node->insertedText() == I18n::Message::IonSelector){ m_ionKeys.setSender(sender()); diff --git a/build/config.mak b/build/config.mak index 97caa8945..4ca2f781e 100644 --- a/build/config.mak +++ b/build/config.mak @@ -16,3 +16,4 @@ EPSILON_GETOPT ?= 0 ESCHER_LOG_EVENTS_BINARY ?= 0 THEME_NAME ?= omega_light THEME_REPO ?= local +INCLUDE_ULAB ?= 1 diff --git a/python/Makefile b/python/Makefile index 15a770c73..6f534bf01 100644 --- a/python/Makefile +++ b/python/Makefile @@ -154,6 +154,11 @@ port_src += $(addprefix python/port/,\ mod/turtle/modturtle.cpp \ mod/turtle/modturtle_table.c \ mod/turtle/turtle.cpp \ + mphalport.c \ +) + +ifeq ($(INCLUDE_ULAB), 1) +port_src += $(addprefix python/port/,\ mod/ulab/scipy/linalg/linalg.c \ mod/ulab/scipy/optimize/optimize.c \ mod/ulab/scipy/signal/signal.c \ @@ -180,8 +185,8 @@ port_src += $(addprefix python/port/,\ mod/ulab/user/user.c \ mod/ulab/utils/utils.c \ mod/ulab/ulab.c \ - mphalport.c \ ) +endif # Workarounds diff --git a/python/port/genhdr/qstrdefs.in.h b/python/port/genhdr/qstrdefs.in.h index eed86bcce..0642276c9 100644 --- a/python/port/genhdr/qstrdefs.in.h +++ b/python/port/genhdr/qstrdefs.in.h @@ -604,6 +604,7 @@ Q(username) Q(rename) Q(listdir) +#if defined(INCLUDE_ULAB) // ulab QSTRs Q(threshold) Q(edgeitems) @@ -721,3 +722,4 @@ Q(from_int16_buffer) Q(from_uint16_buffer) Q(from_int32_buffer) Q(from_uint32_buffer) +#endif diff --git a/python/port/mod/ulab/ulab.h b/python/port/mod/ulab/ulab.h index 032768542..93cb77abe 100644 --- a/python/port/mod/ulab/ulab.h +++ b/python/port/mod/ulab/ulab.h @@ -34,13 +34,7 @@ // Determines, whether scipy is defined in ulab. The sub-modules and functions // of scipy have to be defined separately -#ifndef ULAB_HAS_SCIPY -#if defined(DEVICE_N0100) -#define ULAB_HAS_SCIPY (0) -#else #define ULAB_HAS_SCIPY (1) -#endif -#endif // The maximum number of dimensions the firmware should be able to support // Possible values lie between 1, and 4, inclusive diff --git a/python/port/mpconfigport.h b/python/port/mpconfigport.h index 07a6e3e99..ba9baba18 100644 --- a/python/port/mpconfigport.h +++ b/python/port/mpconfigport.h @@ -136,6 +136,19 @@ extern const struct _mp_obj_module_t modpyplot_module; extern const struct _mp_obj_module_t modtime_module; extern const struct _mp_obj_module_t modos_module; extern const struct _mp_obj_module_t modturtle_module; + +#if !defined(INCLUDE_ULAB) + +#define MICROPY_PORT_BUILTIN_MODULES \ + { MP_ROM_QSTR(MP_QSTR_ion), MP_ROM_PTR(&modion_module) }, \ + { MP_ROM_QSTR(MP_QSTR_kandinsky), MP_ROM_PTR(&modkandinsky_module) }, \ + { MP_ROM_QSTR(MP_QSTR_matplotlib), MP_ROM_PTR(&modmatplotlib_module) }, \ + { MP_ROM_QSTR(MP_QSTR_matplotlib_dot_pyplot), MP_ROM_PTR(&modpyplot_module) }, \ + { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&modtime_module) }, \ + { MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&modos_module) }, \ + { MP_ROM_QSTR(MP_QSTR_turtle), MP_ROM_PTR(&modturtle_module) }, \ + +#else extern const struct _mp_obj_module_t ulab_user_cmodule; #define MICROPY_PORT_BUILTIN_MODULES \ @@ -146,7 +159,10 @@ extern const struct _mp_obj_module_t ulab_user_cmodule; { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&modtime_module) }, \ { MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&modos_module) }, \ { MP_ROM_QSTR(MP_QSTR_turtle), MP_ROM_PTR(&modturtle_module) }, \ - { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) }, \ + { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) }, \ + +#endif + // Enable setjmp in debug mode. This is to avoid some optimizations done // specifically for x86_64 using inline assembly, which makes the debug binary diff --git a/python/port/port.cpp b/python/port/port.cpp index e90b9de0b..76c707372 100644 --- a/python/port/port.cpp +++ b/python/port/port.cpp @@ -61,7 +61,9 @@ extern "C" { #include "mphalport.h" #include "mod/turtle/modturtle.h" #include "mod/matplotlib/pyplot/modpyplot.h" +#if defined(INCLUDE_ULAB) #include "mod/ulab/ulab.h" +#endif } #include