diff --git a/interpreters/duktape/.gitignore b/interpreters/duktape/.gitignore new file mode 100644 index 000000000..ceb69124d --- /dev/null +++ b/interpreters/duktape/.gitignore @@ -0,0 +1 @@ +duktape-* diff --git a/interpreters/duktape/Kconfig b/interpreters/duktape/Kconfig new file mode 100644 index 000000000..4317b6a3f --- /dev/null +++ b/interpreters/duktape/Kconfig @@ -0,0 +1,20 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config INTERPRETERS_DUKTAPE + tristate "Duktape JavaScript interpreter" + default n + +if INTERPRETERS_DUKTAPE + +config INTERPRETERS_DUKTAPE_PRIORITY + int "Duktape interpreter priority" + default 100 + +config INTERPRETERS_DUKTAPE_STACKSIZE + int "Duktape interpreter stack size" + default 8192 + +endif diff --git a/interpreters/duktape/Make.defs b/interpreters/duktape/Make.defs new file mode 100644 index 000000000..7ae754db6 --- /dev/null +++ b/interpreters/duktape/Make.defs @@ -0,0 +1,23 @@ +############################################################################ +# interpreters/duktape/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifneq ($(CONFIG_INTERPRETERS_DUKTAPE),) +CONFIGURED_APPS += $(APPDIR)/interpreters/duktape +endif diff --git a/interpreters/duktape/Makefile b/interpreters/duktape/Makefile new file mode 100644 index 000000000..d93c01a22 --- /dev/null +++ b/interpreters/duktape/Makefile @@ -0,0 +1,56 @@ +############################################################################ +# interpreters/duktape/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +DUKTAPE_VERSION = 2.5.0 +DUKTAPE_UNPACK = duktape-$(DUKTAPE_VERSION) +DUKTAPE_TARBALL = duktape-$(DUKTAPE_VERSION).tar.xz +DUKTAPE_URL = https://github.com/svaarala/duktape/releases/ \ + download/v$(DUKTAPE_VERSION)/$(DUKTAPE_TARBALL) + +CSRCS = $(DUKTAPE_UNPACK)/src-noline/duktape.c + +MAINSRC = $(DUKTAPE_UNPACK)/examples/cmdline/duk_cmdline.c + +PROGNAME = duk +PRIORITY = $(CONFIG_INTERPRETERS_DUKTAPE_PRIORITY) +STACKSIZE = $(CONFIG_INTERPRETERS_DUKTAPE_STACKSIZE) +MODULE = $(CONFIG_INTERPRETERS_DUKTAPE) + +CFLAGS += -I$(DUKTAPE_UNPACK)/src-noline + +$(DUKTAPE_TARBALL): + @echo "Downloading $(DUKTAPE_TARBALL)" + @wget $(DUKTAPE_URL) + +$(DUKTAPE_UNPACK): $(DUKTAPE_TARBALL) + @echo "Unpacking $(DUKTAPE_TARBALL) to $(DUKTAPE_UNPACK)" + @tar xvfJ $(DUKTAPE_TARBALL) + @echo "Patching $(DUKTAPE_UNPACK)" + @patch -p0 < duk_cmdline.patch + +context:: $(DUKTAPE_UNPACK) + +distclean:: + $(call DELDIR, $(DUKTAPE_UNPACK)) + $(call DELFILE, $(DUKTAPE_TARBALL)) + +include $(APPDIR)/Application.mk diff --git a/interpreters/duktape/duk_cmdline.patch b/interpreters/duktape/duk_cmdline.patch new file mode 100644 index 000000000..e2a33944c --- /dev/null +++ b/interpreters/duktape/duk_cmdline.patch @@ -0,0 +1,12 @@ +diff --color -ur duktape-2.5.0/examples/cmdline/duk_cmdline.c duktape-2.5.0-modified/examples/cmdline/duk_cmdline.c +--- duktape-2.5.0/examples/cmdline/duk_cmdline.c 2019-11-25 06:04:27.000000000 +0800 ++++ duktape-2.5.0-modified/examples/cmdline/duk_cmdline.c 2020-08-06 17:03:30.630000000 +0800 +@@ -810,6 +810,8 @@ + + for (;;) { + int c = fgetc(stdin); ++ fputc(c, stdout); ++ fflush(stdout); + if (c == EOF) { + got_eof = 1; + break;