Browse Source

add lib/jscore:

import dutape js engine from https://github.com/svaarala/duktape

    4781b33420eba0f0dd4f9caa10dfc17622d3925e

    python tools/configure.py --source-directory src-input --output-directory src-lowmemory \
        --option-file config/examples/low_memory.yaml --architecture arm32 --compiler gcc

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 5 years ago
parent
commit
62d603266f
  1. 5
      lib/gcc_stubs.c
  2. 2558
      lib/jscore/duk_config.h
  3. 1889
      lib/jscore/duk_source_meta.json
  4. 97177
      lib/jscore/duktape.c
  5. 1441
      lib/jscore/duktape.h
  6. 6
      lib/rules.mk
  7. 28
      targets/stm32f429-disc/js.c
  8. 2
      targets/stm32f429-disc/target.h
  9. 2
      targets/stm32f429-disc/target.mk

5
lib/gcc_stubs.c

@ -10,6 +10,11 @@
#undef errno
extern int errno;
int * __errno()
{
return &errno;
}
/*
* Environment variables.
* A pointer to a list of environment variables and their values. For a minimal

2558
lib/jscore/duk_config.h

File diff suppressed because it is too large

1889
lib/jscore/duk_source_meta.json

File diff suppressed because it is too large

97177
lib/jscore/duktape.c

File diff suppressed because it is too large

1441
lib/jscore/duktape.h

File diff suppressed because it is too large

6
lib/rules.mk

@ -41,6 +41,12 @@ ifeq ($(TARGET_USE_WM8978), y)
lib_srcs += $(lib_dir)/wm8978.c
endif
ifeq ($(TARGET_USE_JS), y)
lib_srcs += $(lib_dir)/jscore/duktape.c \
TARGET_CFLAGS += -I$(lib_dir)/jscore
endif
ifeq ($(TARGET_USE_EFS), y)
lib_srcs += \
$(lib_dir)/efs/spiffs_cache.c \

28
targets/stm32f429-disc/js.c

@ -0,0 +1,28 @@
#include <stdio.h>
#include "duktape.h"
#include "cmd.h"
static duk_ret_t native_print(duk_context *ctx)
{
duk_push_string(ctx, " ");
duk_insert(ctx, 0);
duk_join(ctx, duk_get_top(ctx) - 1);
printf("%s\n", duk_safe_to_string(ctx, -1));
return 0;
}
static int do_jshello(cmd_tbl_t s, int argc, char *argv[])
{
duk_context *ctx = duk_create_heap_default();
duk_push_c_function(ctx, native_print, DUK_VARARGS);
duk_put_global_string(ctx, "print");
duk_eval_string(ctx, "print('welcome to use duktape!')");
duk_destroy_heap(ctx);
return 0;
}
CON_CMD(jshello, "hello from js", NULL, do_jshello);

2
targets/stm32f429-disc/target.h

@ -35,6 +35,8 @@
#define TARGET_I2S_TX_DMA_BUFSIZ (2048)
#endif
#define TARGET_HEAP_SIZE (81920)
/* efs attributes */
#define TARGET_EFS_CAPACITY 0x00100000
#define TARGET_EFS_ADDRESS 0x08100000

2
targets/stm32f429-disc/target.mk

@ -5,6 +5,7 @@ RAMSZ := 192k
TARGET_USE_USB := y
TARGET_USE_WM8978 := y
TARGET_USE_EFS := y
TARGET_USE_JS := y
OOCD_INTERFACE := stlink-v2-1
OOCD_TRANSPORT := hla_swd
@ -23,6 +24,7 @@ stm32f429_srcs := \
$(target_dir)/stmpe811.c \
$(target_dir)/retarget.c \
$(target_dir)/cmds.c \
$(target_dir)/js.c \
$(target)_objs := $(stm32f429_srcs:.c=.o)

Loading…
Cancel
Save