interpreters: Add initial duktape support
Signed-off-by: Huang Qi <huangqi3@xiaomi.com> Change-Id: I8909551d565ce9d1ae25607367a005eee13c3860
This commit is contained in:
parent
eaeceb516b
commit
06b64634bf
1
interpreters/duktape/.gitignore
vendored
Normal file
1
interpreters/duktape/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
duktape-*
|
20
interpreters/duktape/Kconfig
Normal file
20
interpreters/duktape/Kconfig
Normal file
@ -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
|
23
interpreters/duktape/Make.defs
Normal file
23
interpreters/duktape/Make.defs
Normal file
@ -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
|
56
interpreters/duktape/Makefile
Normal file
56
interpreters/duktape/Makefile
Normal file
@ -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
|
12
interpreters/duktape/duk_cmdline.patch
Normal file
12
interpreters/duktape/duk_cmdline.patch
Normal file
@ -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;
|
Loading…
Reference in New Issue
Block a user