Skip to content

Commit 182a06a

Browse files
committed
interpreters: add Tcl support
Tcl is added usin The Jim Interpreter. Jim is an opensource small-footprint implementation of the Tcl programming language. It implements a large subset of Tcl and adds new features like references with garbage collection, closures, built-in Object Oriented Programming system, Functional Programming commands, first-class arrays and UTF-8 support. Signed-off-by: Carlos Sánchez de La Lama <csanchezdll@gmail.com>
1 parent 62d04ed commit 182a06a

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

interpreters/jimtcl/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config INTERPRETERS_JIMTCL
7+
bool "The Jim (TCL) Intepreter"
8+
default n
9+
---help---
10+
Enable support for The Jim interpreter.
11+
Jim is an opensource small-footprint implementation of the
12+
Tcl programming language.

interpreters/jimtcl/Make.defs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ifneq ($(CONFIG_INTERPRETERS_JIMTCL),)
2+
CONFIGURED_APPS += $(APPDIR)/interpreters/jimtcl
3+
endif

interpreters/jimtcl/Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
include $(APPDIR)/Make.defs
2+
3+
PROGNAME = jimsh
4+
PRIORITY = 100
5+
STACKSIZE = 8192
6+
7+
JIMTCL_VERSION = 0.83
8+
JIMTCL_TARBALL = $(JIMTCL_VERSION).tar.gz
9+
JIMTCL_UNPACK = jimtcl
10+
JIMTCL_URL_BASE = https://github.com/msteveb/jimtcl/archive/refs/tags
11+
JIMTCL_URL = $(JIMTCL_URL_BASE)/$(JIMTCL_TARBALL)
12+
JIMTCL_SRC = $(JIMTCL_UNPACK)
13+
14+
MAINSRC = $(JIMTCL_SRC)$(DELIM)jimsh.c
15+
16+
# Obtain object list from jimtcl Makefile
17+
JIMTCL_OBJS := $(shell test -f $(JIMTCL_SRC)$(DELIM)Makefile \
18+
&& ( cat $(JIMTCL_SRC)$(DELIM)Makefile; \
19+
printf 'print-%%:\n\techo $$($$*)' ) \
20+
| $(MAKE) -f - -s print-OBJS) initjimsh.o
21+
22+
EXTOBJS := $(addprefix $(JIMTCL_SRC)$(DELIM), $(JIMTCL_OBJS))
23+
24+
CFLAGS += -I$(JIMTCL_SRC)
25+
26+
$(JIMTCL_SRC)$(DELIM)%.o: $(JIMTCL_SRC)$(DELIM)Makefile
27+
$(Q) $(MAKE) -C $(JIMTCL_SRC) $*.o
28+
29+
$(JIMTCL_SRC)$(DELIM)jimsh.c: $(JIMTCL_SRC)$(DELIM)Makefile
30+
31+
$(JIMTCL_SRC)$(DELIM)_initjimsh.c: $(JIMTCL_SRC)$(DELIM)Makefile
32+
$(Q) $(MAKE) -C $(JIMTCL_SRC) $(notdir $@)
33+
34+
$(JIMTCL_SRC)$(DELIM)Makefile:
35+
$(Q) cd $(dir $@) \
36+
&& ./configure --host=$(patsubst %-,%,$(CROSSDEV)) \
37+
CFLAGS="$(CFLAGS)"
38+
39+
# Get the source code and apply a small patch because environ is
40+
# not settable in Nuttx. This is not required for basic jimtcl
41+
# but build would fail without commenting it out.
42+
$(JIMTCL_TARBALL):
43+
$(Q) echo "Downloading $(JIMTCL_TARBALL)"
44+
$(Q) curl -O -L $(JIMTCL_URL)
45+
$(Q) echo "Unpacking $(JIMTCL_TARBALL) to $(JIMTCL_UNPACK)"
46+
$(Q) tar -xvzf $(JIMTCL_TARBALL)
47+
$(Q) mv jimtcl-$(JIMTCL_VERSION) $(JIMTCL_UNPACK)
48+
$(Q) sed -i '/^void Jim_SetEnviron/,/^}/{s/^/\/* /;s/$$/ *\//}' \
49+
$(JIMTCL_SRC)$(DELIM)jim.c
50+
51+
# Download and unpack tarball if no git repo found
52+
ifeq ($(wildcard $(JIMTCL_UNPACK)/.git),)
53+
context:: $(JIMTCL_TARBALL)
54+
endif
55+
56+
clean::
57+
$(Q) test -f $(JIMTCL_SRC)$(DELIM)Makefile \
58+
&& $(MAKE) -C $(JIMTCL_SRC) clean
59+
60+
distclean:: clean
61+
$(call DELDIR, $(JIMTCL_UNPACK))
62+
$(call DELFILE, $(JIMTCL_TARBALL))
63+
64+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)