summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-11 10:49:20 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-11 10:49:20 -0600
commit999c029f446203e0a77b01db03503d7ca6111558 (patch)
tree02eda7397f42f406d50d3317b2c2a9e3373051bc
parent00b64ed8bb241b10737968a3518c929e329f9c37 (diff)
downloadnuttx-999c029f446203e0a77b01db03503d7ca6111558.tar.gz
nuttx-999c029f446203e0a77b01db03503d7ca6111558.tar.bz2
nuttx-999c029f446203e0a77b01db03503d7ca6111558.zip
Micro Python: Add logic to automatically download the Micro Python tarball at download
-rw-r--r--apps/interpreters/Kconfig4
-rw-r--r--apps/interpreters/README.txt20
-rw-r--r--apps/interpreters/micropython/Kconfig12
-rw-r--r--apps/interpreters/micropython/Makefile51
-rw-r--r--nuttx/tools/cfgdefine.c2
-rw-r--r--nuttx/tools/cfgparser.c2
6 files changed, 67 insertions, 24 deletions
diff --git a/apps/interpreters/Kconfig b/apps/interpreters/Kconfig
index 115876eb6..949752d62 100644
--- a/apps/interpreters/Kconfig
+++ b/apps/interpreters/Kconfig
@@ -3,8 +3,8 @@
# see misc/tools/kconfig-language.txt.
#
-source "$APPSDIR/interpreters/ficl/Kconfig"
source "$APPSDIR/interpreters/bas/Kconfig"
+source "$APPSDIR/interpreters/ficl/Kconfig"
config INTERPRETERS_PCODE
bool "Pascal p-code interpreter"
@@ -17,3 +17,5 @@ config INTERPRETERS_PCODE
if INTERPRETERS_PCODE
endif
+
+source "$APPSDIR/interpreters/micropython/Kconfig"
diff --git a/apps/interpreters/README.txt b/apps/interpreters/README.txt
index 7062a8094..5f776a508 100644
--- a/apps/interpreters/README.txt
+++ b/apps/interpreters/README.txt
@@ -19,18 +19,30 @@ micropython
https://micropython.org/
- NOTE that Micro Python is not included in this directory. Before building
- this example, you must first download Micro Python from:
+ NOTE that Micro Python is not included in this directory. Be default,
+ it will be downloaded at build time from the github . You can avoid
+ this download by pre-installing Micro Python. Before building, just
+ download Micro Python from:
https://micropython.org/download/
+ https://github.com/micropython/micropython/releases
- Or clone from the GIT repository:
+ Or clone from the GIT repository at:
https://github.com/micropython/
+ https://github.com/micropython/micropython
- This port was contributed by Dave Marples using Micro Python circu
+ The Micro Python code should reside in directory should be
+ apps/interpreters/micropython/micropython-$(CONFIG_INTERPRETERS_MICROPYTHON_VERSION)
+
+ This port was contributed by Dave Marples using Micro Python circa
1.3.8. It may not be compatible with other versions.
+ NOTE: Right now, Micro Python will not build on Windows with a Windows
+ native toolchain due to usage of POSIX paths in the Micro Python build
+ system. It should build correctly on Linux or under Cygwin with the
+ NuttX buildroot tools.
+
pcode
-----
diff --git a/apps/interpreters/micropython/Kconfig b/apps/interpreters/micropython/Kconfig
index 82f345148..0c42b33f0 100644
--- a/apps/interpreters/micropython/Kconfig
+++ b/apps/interpreters/micropython/Kconfig
@@ -11,6 +11,14 @@ config INTERPRETERS_MICROPYTHON
if INTERPRETERS_MICROPYTHON
+config INTERPRETERS_MICROPYTHON_URL
+ string "URL where Micro Python can be downloaded"
+ default "https://github.com/micropython/micropython/archive"
+
+config INTERPRETERS_MICROPYTHON_VERSION
+ string "Version number"
+ default "1.3.8"
+
config INTERPRETERS_MICROPYTHON_APPNAME
string "Executable name"
default "micropython"
@@ -26,9 +34,9 @@ config INTERPRETERS_MICROPYTHON_PRIORITY
default 100
depends on NSH_BUILTIN_APPS
-CONFIG_INTERPRETERS_MICROPYTHON_PROGNAME
+config INTERPRETERS_MICROPYTHON_PROGNAME
string "Program name"
default "micropython"
depends on BUILD_KERNEL
-endif # INTERPRETERS_MICROPYTHON \ No newline at end of file
+endif # INTERPRETERS_MICROPYTHON
diff --git a/apps/interpreters/micropython/Makefile b/apps/interpreters/micropython/Makefile
index 99df4031f..9042043f8 100644
--- a/apps/interpreters/micropython/Makefile
+++ b/apps/interpreters/micropython/Makefile
@@ -34,13 +34,24 @@
#
###########################################################################
-TOP ?= ../../../../micropython
-TOPDIR ?= ../../../nuttx
-APPDIR ?= ../../../apps
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+WD := ${shell pwd | sed -e 's/ /\\ /g'}
-MICROPYTHON_DIR = $(TOP)/py
+CONFIG_INTERPRETERS_MICROPYTHON_URL ?= "https://github.com/micropython/micropython/archive"
+CONFIG_INTERPRETERS_MICROPYTHON_VERSION ?= "1.3.8"
+MICROPYTHON_VERSION = $(patsubst "%",%,$(strip $(CONFIG_INTERPRETERS_MICROPYTHON_VERSION)))
-include $(MICROPYTHON_DIR)/mkenv.mk
+MICROPYTHON_TARBALL = v$(MICROPYTHON_VERSION).tar.gz
+WGET ?= wget
+
+MICROPYTHON_UNPACKNAME = micropython-$(MICROPYTHON_VERSION)
+UNPACK ?= tar -zxf
+
+MICROPYTHON_PATH = $(WD)/$(MICROPYTHON_UNPACKNAME)/py
+-include $(MICROPYTHON_PATH)/mkenv.mk
# qstr definitions (must come before including py.mk)
@@ -48,17 +59,13 @@ QSTR_DEFS = qstrdefsport.h
# include py core make definitions
-include $(MICROPYTHON_DIR)/py.mk
-
--include $(TOPDIR)/.config
--include $(TOPDIR)/Make.defs
-include $(APPDIR)/Make.defs
+-include $(MICROPYTHON_PATH)/py.mk
# c99 is needed for micropython
CFLAGS+=-std=c99 -Wno-shadow -Wno-strict-prototypes
-INC = -I. -I$(TOP) -I$(PY_SRC) -I$(BUILD)
+INC = -I. -I$(WD) -I$(PY_SRC) -I$(BUILD)
CFLAGS +=$(INC)
@@ -105,12 +112,21 @@ ROOTDEPPATH = --dep-path .
all: .built
-.built: $(OBJ)
+$(MICROPYTHON_TARBALL):
+ @echo "Downloading: $(MICROPYTHON_TARBALL)"
+ $(Q) $(WGET) $(CONFIG_INTERPRETERS_MICROPYTHON_URL)/$(MICROPYTHON_TARBALL)
+
+$(MICROPYTHON_UNPACKNAME): $(MICROPYTHON_TARBALL)
+ @echo "Unpacking: $(MICROPYTHON_TARBALL) -> $(MICROPYTHON_UNPACKNAME)"
+ $(Q) $(UNPACK) $(MICROPYTHON_TARBALL)
+ @touch $(MICROPYTHON_UNPACKNAME)
+
+.built: $(MICROPYTHON_UNPACKNAME) $(OBJ)
$(call ARCHIVE, $(BIN), $(OBJ))
@touch .built
ifeq ($(CONFIG_BUILD_KERNEL),y)
-$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJ) $(MAINOBJ)
+$(BIN_DIR)$(DELIM)$(PROGNAME): $(MICROPYTHON_UNPACKNAME) $(OBJ) $(MAINOBJ)
@echo "LD: $(PROGNAME)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
@@ -124,7 +140,7 @@ ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),micropython_main)
-context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
+context: $(MICROPYTHON_UNPACKNAME) $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
else
context:
endif
@@ -135,9 +151,14 @@ endif
depend: .depend
+clean:
+
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
+ $(call DELDIR, $(MICROPYTHON_UNPACKNAME))
+ $(call DELFILE, .downloaded)
+ $(call DELFILE, .$(MICROPYTHON_TARBALL))
-include $(MICROPYTHON_DIR)/mkrules.mk
+-include $(MICROPYTHON_PATH)/mkrules.mk
-include Make.dep
diff --git a/nuttx/tools/cfgdefine.c b/nuttx/tools/cfgdefine.c
index c1a473630..80975b7aa 100644
--- a/nuttx/tools/cfgdefine.c
+++ b/nuttx/tools/cfgdefine.c
@@ -42,7 +42,7 @@
#include "cfgdefine.h"
/****************************************************************************
- * Definitions
+ * Pre-processor Definitions
****************************************************************************/
/****************************************************************************
diff --git a/nuttx/tools/cfgparser.c b/nuttx/tools/cfgparser.c
index 7c1c44ca0..8ac52a589 100644
--- a/nuttx/tools/cfgparser.c
+++ b/nuttx/tools/cfgparser.c
@@ -44,7 +44,7 @@
#include "cfgparser.h"
/****************************************************************************
- * Definitions
+ * Pre-processor Definitions
****************************************************************************/
/****************************************************************************